Elements should be compared using the equals(Object)
method. There is no guarantee that any particular element will
always be represented by the same object.
To implement operations based on the class of an Element object, either use a visitor or
use the result of the getKind method. Using instanceof is not necessarily a reliable idiom for
determining the effective class of an object in this modeling
hierarchy since an implementation may choose to have a single object
implement multiple Element subinterfaces.
Elements, TypeMirror
| Modifier and Type | Method and Description |
|---|---|
| public < the return type of the visitor's methods R, the type of the additional parameter to the visitor's methods P> R | Returns: a visitor-specified resultthe visitor operating on this element v, P additional parameter to the visitor p)Applies a visitor to this element. |
| public TypeMirror | |
| public boolean | |
| public <A extends Annotation> A | getAnnotation(Class<A> annotationType)
Redeclares javax. Returns this construct's annotation of the specified type if
such an annotation is present, else |
| public List | getAnnotationMirrors()
Redeclares javax. Returns the annotations that are directly present on this construct. |
| public <A extends Annotation> A[] | getAnnotationsByType(Class<A> annotationType)
Redeclares javax. Returns annotations of the specified type that are associated with this construct. |
| public List | Returns: the enclosed elements, or an empty list if noneReturns the elements that are, loosely speaking, directly enclosed by this element. |
| public Element | Returns: the enclosing element, ornull if there is noneReturns the innermost element within which this element is, loosely speaking, enclosed. |
| public ElementKind | |
| public Set | Returns: the modifiers of this element, or an empty set if there are noneReturns the modifiers of this element, excluding annotations. |
| public Name | Returns: the simple (unqualified) name of this elementReturns the simple (unqualified) name of this element. |
| public int |
| accept | back to summary |
|---|---|
| public <R, P> R accept(ElementVisitor<R, P> v, P p) Applies a visitor to this element.
| |
| asType | back to summary |
|---|---|
| public TypeMirror asType() Returns the type defined by this element.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Returns API Note The identity of an element involves implicit state
not directly accessible from the element's methods, including
state about the presence of unrelated types. Element objects
created by different implementations of these interfaces should
not be expected to be equal even if "the same"
element is being modeled; this is analogous to the inequality
of | |
| getAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getAnnotation(Class<A> annotationType) Redeclares javax. Doc from javax. Returns this construct's annotation of the specified type if
such an annotation is present, else The annotation returned by this method could contain an element
whose value is of type Note This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation interfaces currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation interfaces. Note that any annotation returned by this method is a declaration annotation.
| |
| getAnnotationMirrors | back to summary |
|---|---|
| public List Redeclares javax. Doc from javax. Returns the annotations that are directly present on this construct. To get inherited annotations as well, use Note that any annotations returned by this method are declaration annotations.
| |
| getAnnotationsByType | back to summary |
|---|---|
| public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) Redeclares javax. Doc from javax. Returns annotations of the specified type that are associated
with this construct.
If there are no annotations of the specified type associated with this
construct, the return value is an array of length 0.
The order of annotations which are directly or indirectly
present on a construct C is computed as if indirectly present
annotations on C are directly present on C in place of their
container annotation, in the order in which they appear in the
value element of the container annotation.
The difference between this method and The annotations returned by this method could contain an element
whose value is of type Note This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation interfaces currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation interfaces. Note that any annotations returned by this method are declaration annotations.
| |
| getEnclosedElements | back to summary |
|---|---|
| public List Returns the elements that are, loosely speaking, directly enclosed by this element. A class or interface is considered to enclose the fields, methods, constructors, record components, and member classes and interfaces that it directly declares. A package encloses the top-level classes and interfaces within it, but is not considered to enclose subpackages. A module encloses packages within it. Enclosed elements may include implicitly declared mandated elements. Other kinds of elements are not currently considered to enclose any elements; however, that may change as this API or the programming language evolves. API Note Elements of certain kinds can be isolated using
methods in
| |
| getEnclosingElement | back to summary |
|---|---|
| public Element getEnclosingElement() Returns the innermost element within which this element is, loosely speaking, enclosed.
| |
| getKind | back to summary |
|---|---|
| public ElementKind getKind() Returns the
| |
| getModifiers | back to summary |
|---|---|
| public Set Returns the modifiers of this element, excluding annotations.
Implicit modifiers, such as the | |
| getSimpleName | back to summary |
|---|---|
| public Name getSimpleName() Returns the simple (unqualified) name of this element. The
name of a generic class or interface does not include any
reference to its formal type parameters.
For example, the simple name of the type element representing
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Obeys the general contract of | |