com.sun.tools.apt.mirror.declaration
Class ClassDeclarationImpl
java.lang.Object
com.sun.tools.apt.mirror.declaration.DeclarationImpl
com.sun.tools.apt.mirror.declaration.MemberDeclarationImpl
com.sun.tools.apt.mirror.declaration.TypeDeclarationImpl
com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl
- All Implemented Interfaces:
- ClassDeclaration, Declaration, MemberDeclaration, TypeDeclaration
- Direct Known Subclasses:
- EnumDeclarationImpl
public class ClassDeclarationImpl
- extends TypeDeclarationImpl
- implements ClassDeclaration
Implementation of ClassDeclaration
|
Method Summary |
void |
accept(DeclarationVisitor v)
Applies a visitor to this declaration. |
<A extends java.lang.annotation.Annotation>
A |
|
getAnnotation(java.lang.Class<A> annoType)
Returns the annotation of this declaration having the specified
type. The annotation may be either inherited or directly
present on this declaration.
The annotation returned by this method could contain an element
whose value is of type Class.
This value cannot be returned directly: information necessary to
locate and load a class (such as the class loader to use) is
not available, and the class might not be loadable at all.
Attempting to read a Class object by invoking the relevant
method on the returned annotation
will result in a MirroredTypeException,
from which the corresponding TypeMirror may be extracted.
Similarly, attempting to read a Class[]-valued element
will result in a MirroredTypesException.
Note: This method is unlike
others in this and related interfaces. It operates on run-time
reflective information -- representations of annotation types
currently loaded into the VM -- rather than on the mirrored
representations defined by and used throughout these
interfaces. It is intended for callers that are written to
operate on a known, fixed set of annotation types.
Overridden by ClassDeclarationImpl to handle @Inherited.
Overridden here to handle @Inherited. |
java.util.Collection<ConstructorDeclaration> |
getConstructors()
Returns the constructors of this class. |
java.util.Collection<MethodDeclaration> |
getMethods()
Returns the methods that are directly declared by this class or
interface. Includes annotation type elements. Excludes
implicitly declared methods of an interface, such as
toString, that correspond to the methods of
java.lang.Object. |
ClassType |
getSuperclass()
Returns the class type directly extended by this class. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ClassDeclarationImpl
ClassDeclarationImpl(AptEnv env,
Symbol.ClassSymbol sym)
getAnnotation
public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> annoType)
- Returns the annotation of this declaration having the specified
type. The annotation may be either inherited or directly
present on this declaration.
The annotation returned by this method could contain an element
whose value is of type Class.
This value cannot be returned directly: information necessary to
locate and load a class (such as the class loader to use) is
not available, and the class might not be loadable at all.
Attempting to read a Class object by invoking the relevant
method on the returned annotation
will result in a MirroredTypeException,
from which the corresponding TypeMirror may be extracted.
Similarly, attempting to read a Class[]-valued element
will result in a MirroredTypesException.
Note: This method is unlike
others in this and related interfaces. It operates on run-time
reflective information -- representations of annotation types
currently loaded into the VM -- rather than on the mirrored
representations defined by and used throughout these
interfaces. It is intended for callers that are written to
operate on a known, fixed set of annotation types.
Overridden by ClassDeclarationImpl to handle @Inherited.
Overridden here to handle @Inherited.
- Specified by:
getAnnotation in interface Declaration- Overrides:
getAnnotation in class DeclarationImpl
- Type Parameters:
A - the annotation type- Parameters:
annoType - the Class object corresponding to
the annotation type
- Returns:
- the annotation of this declaration having the specified type
- See Also:
Declaration.getAnnotationMirrors()
getSuperclass
public ClassType getSuperclass()
- Returns the class type directly extended by this class.
The only class with no superclass is java.lang.Object,
for which this method returns null.
- Specified by:
getSuperclass in interface ClassDeclaration
- Returns:
- the class type directly extended by this class, or null
if there is none
getConstructors
public java.util.Collection<ConstructorDeclaration> getConstructors()
- Returns the constructors of this class.
This includes the default constructor if this class has
no constructors explicitly declared.
- Specified by:
getConstructors in interface ClassDeclaration
- Returns:
- the constructors of this class
- See Also:
DeclarationFilter
getMethods
public java.util.Collection<MethodDeclaration> getMethods()
- Returns the methods that are directly declared by this class or
interface. Includes annotation type elements. Excludes
implicitly declared methods of an interface, such as
toString, that correspond to the methods of
java.lang.Object.
- Specified by:
getMethods in interface ClassDeclaration- Specified by:
getMethods in interface TypeDeclaration- Overrides:
getMethods in class TypeDeclarationImpl
- Returns:
- the methods that are directly declared,
or an empty collection if there are none
- See Also:
DeclarationFilter
accept
public void accept(DeclarationVisitor v)
- Applies a visitor to this declaration.
- Specified by:
accept in interface Declaration- Overrides:
accept in class TypeDeclarationImpl
- Parameters:
v - the visitor operating on this declaration