|
Mirror API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Declaration
Represents the declaration of a program element such as a package, class, or method. Each declaration represents a static, language-level construct (and not, for example, a runtime construct of the virtual machine), and typically corresponds one-to-one with a particular fragment of source code.
Declarations should be compared using the equals(Object)
method. There is no guarantee that any particular declaration will
always be represented by the same object.
Declarations
,
TypeMirror
Method Summary | ||
---|---|---|
void |
accept(DeclarationVisitor v)
Applies a visitor to this declaration. |
|
boolean |
equals(Object obj)
Tests whether an object represents the same declaration as this. |
|
|
getAnnotation(Class<A> annotationType)
Returns the annotation of this declaration having the specified type. |
|
Collection<AnnotationMirror> |
getAnnotationMirrors()
Returns the annotations that are directly present on this declaration. |
|
String |
getDocComment()
Returns the text of the documentation ("javadoc") comment of this declaration. |
|
Collection<Modifier> |
getModifiers()
Returns the modifiers of this declaration, excluding annotations. |
|
SourcePosition |
getPosition()
Returns the source position of the beginning of this declaration. |
|
String |
getSimpleName()
Returns the simple (unqualified) name of this declaration. |
Method Detail |
---|
boolean equals(Object obj)
equals
in class Object
obj
- the object to be compared with this declaration
String getDocComment()
Collection<AnnotationMirror> getAnnotationMirrors()
<A extends Annotation> A getAnnotation(Class<A> annotationType)
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.
A
- the annotation typeannotationType
- the Class object corresponding to
the annotation type
getAnnotationMirrors()
Collection<Modifier> getModifiers()
String getSimpleName()
java.util.Set<E>
is "Set".
If this declaration represents the empty package, an empty
string is returned.
If it represents a constructor, the simple name of its
declaring class is returned.
SourcePosition getPosition()
This source position is intended for use in providing diagnostics, and indicates only approximately where a declaration begins.
void accept(DeclarationVisitor v)
v
- the visitor operating on this declaration
|
Mirror API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |