Compatibility Note: Methods may be added to this interface in future releases of the platform.
javax.annotation.processing.ProcessingEnvironment#getElementUtils
| Modifier and Type | Class and Description |
|---|---|
| public static enum | Elements.
The kind of documentation comment. |
| public static enum | Elements.
The origin of an element or other language model item. |
| Modifier and Type | Method and Description |
|---|---|
| public List | Returns: all annotations of the elementthe element being examined e)Returns all annotations present on an element, whether directly present or present via inheritance. |
| public List | Returns: all members of the typethe type being examined type)Returns all members of a type element, whether inherited or declared directly. |
| public default Set | Returns: the known module elements, or an empty set if there are no modulesReturns all module elements in the current environment. |
| public default Set | Returns: the package elements, or an empty set if no package with the name can be foundthe canonical name name)Returns all package elements with the given canonical name. |
| public default Set | Returns: the type elements, or an empty set if no type with the name can be foundthe canonical name name)Returns all type elements with the given canonical name. |
| public Name | Returns: the binary name of a type elementthe type element being examined type)Returns the binary name of a type element. |
| public String | Returns: the text of a constant expressiona primitive value or string value)Returns the text of a constant expression representing a primitive value or a string. |
| public String | Returns: the documentation comment of the element, ornull
if there is nonethe element being examined e)Returns the text of the documentation ("JavaDoc") comment of an element. |
| public default Elements. | Returns: the kind of the documentation comment for the given element, ornull if there is no comment or the kind is not knownthe element being examined e)Returns the kind of the documentation comment for the given element,
or |
| public Map | Returns: the values of an annotation's elements, including defaultsannotation to examine a)Returns the values of an annotation's elements, including defaults. |
| public default TypeElement | Returns: the class body of anenum constant if the
argument is an enum constant declared with an optional
class body, null otherwisean enum constant enumConstant)Returns the class body of an |
| public default JavaFileObject | Returns: the file object for this element ornull if
there is no such file objectthe element to find a file object for e)Returns the file object for this element or |
| public default ModuleElement | Returns: the named module element, ornull if it cannot be foundthe name, or an empty string for an unnamed module name)Returns a module element given its fully qualified name. |
| public default ModuleElement | Returns: the module of an elementthe element being examined e)Returns the module of an element. |
| public Name | Returns: a name with the same sequence of characters as the argumentthe character sequence to return as a name cs)Returns a name with the same sequence of characters as the argument. |
| public default Elements. | |
| public default Elements. | Returns: the origin of the given annotation mirrorthe construct the annotation mirror modifies c, AnnotationMirror the annotation mirror being examined a)Returns the origin of the given annotation mirror. |
| public default Elements. | Returns: the origin of the given module directivethe module of the directive m, ModuleElement.the module directive being examined directiveReturns the origin of the given module directive. |
| public default TypeElement | Returns: the outermost type element an element is contained in if such a containing element exists; otherwise returnsnullthe element being examined e)Returns the outermost type element an element is contained in
if such a containing element exists; otherwise returns |
| public PackageElement | Returns: the specified package, ornull if no package can be uniquely determined.fully qualified package name,
or an empty string for an unnamed package name)Returns a package given its fully qualified name if the package is uniquely determinable in the environment. |
| public default PackageElement | Returns: the specified package, ornull if it cannot be foundmodule relative to which the lookup should happen module, CharSequence fully qualified package name, or an empty string for an unnamed package name)Returns a package given its fully qualified name, as seen from the given module. |
| public PackageElement | Returns: the package of an elementthe element being examined e)Returns the package of an element. |
| public TypeElement | Returns: the named type element, ornull if no type element can be uniquely determined.the canonical name name)Returns a type element given its canonical name if the type element is uniquely determinable in the environment. |
| public default TypeElement | Returns: the named type element, ornull if it cannot be foundmodule relative to which the lookup should happen module, CharSequence the canonical name name)Returns a type element given its canonical name, as seen from the given module. |
| public boolean | |
| public default boolean | Returns: true if the module element is an automatic
module, false otherwisethe module element being examined module)Returns |
| public default boolean | Returns: true if the executable element is a bridge
method, false otherwisethe executable being examined e)Returns |
| public default boolean | Returns: true if the executable element can be
determined to be a canonical constructor of a record, false otherwisethe executable being examined e)Returns |
| public default boolean | Returns: true if the executable element can be
determined to be a compact constructor of a record, false otherwisethe executable being examined e)Returns |
| public boolean | Returns: true if the element is deprecated, false otherwisethe element being examined e)Returns |
| public boolean | Returns: true if the type element is a functional
interface, false otherwisethe type element being examined type)Returns |
| public boolean | Returns: true if and only if the first method overrides
the secondthe first method, possible overrider overrider, ExecutableElement the second method, possibly being overridden overridden, TypeElement the class or interface of which the first method is a member type)Tests whether one method, as a member of a given class or interface, overrides another method. |
| public void | printElements(Writer
the writer to print the output to w, Element... the elements to print elements)Prints a representation of the elements to the given writer in the specified order. |
| public default RecordComponentElement | Returns: the record component, ornull if the given
method is not a record component accessorthe method for which the record component should be found. accessor)Returns the record component for the given accessor. |
| getAllAnnotationMirrors | back to summary |
|---|---|
| public List Returns all annotations present on an element, whether directly present or present via inheritance. Note that any annotations returned by this method are declaration annotations.
| |
| getAllMembers | back to summary |
|---|---|
| public List Returns all members of a type element, whether inherited or declared directly. For a class, the result also includes its constructors, but not local or anonymous classes. API Note Elements of certain kinds can be isolated using
methods in
| |
| getAllModuleElements | back to summary |
|---|---|
| public default Set Returns all module elements in the current environment. If no modules are present, an empty set is returned. One situation where no modules are present occurs when the environment does not include modules, such as an annotation processing environment configured for a source version without modules. Implementation Specification The default implementation of this method returns an empty set. API Note When an environment includes modules, both named modules and unnamed modules may be returned.
| |
| getAllPackageElements | back to summary |
|---|---|
| public default Set Returns all package elements with the given canonical name. There may be more than one package element with the same canonical name if the package elements are in different modules. Implementation Specification The default implementation of this method calls
| |
| getAllTypeElements | back to summary |
|---|---|
| public default Set Returns all type elements with the given canonical name. There may be more than one type element with the same canonical name if the type elements are in different modules. Implementation Specification The default implementation of this method calls
| |
| getBinaryName | back to summary |
|---|---|
| public Name getBinaryName(TypeElement type) Returns the binary name of a type element.
| |
| getConstantExpression | back to summary |
|---|---|
| public String getConstantExpression(Object value) Returns the text of a constant expression representing a primitive value or a string. The text returned is in a form suitable for representing the value in source code.
| |
| getDocComment | back to summary |
|---|---|
| public String getDocComment(Element e) Returns the text of the documentation ("JavaDoc") comment of an element. A documentation comment of an element is a particular kind of comment that immediately precedes the element, ignoring white space, annotations and any other comments that are not themselves documentation comments. There are two kinds of documentation comments, either based on traditional comments or based on a series of end-of-line comments. For both kinds, the text returned for the documentation comment is a processed form of the comment as it appears in source code, as described below. A traditional
documentation comment is a traditional comment that begins
with "
An end-of-line
documentation comment is a series of adjacent end-of-line
comments, each on a line by itself, ignoring any whitespace
characters at the beginning of the line, and each beginning
with "
API Note Documentation comments are processed by the standard doclet
used by the
| |
| getDocCommentKind | back to summary |
|---|---|
| public default Elements. Returns the kind of the documentation comment for the given element,
or Implementation Specification The default implementation of this method returns
| |
| getElementValuesWithDefaults | back to summary |
|---|---|
| public Map Returns the values of an annotation's elements, including defaults.
| |
| getEnumConstantBody | back to summary |
|---|---|
| public default TypeElement getEnumConstantBody(VariableElement enumConstant) Returns the class body of an Implementation Specification The default implementation of this method throws
| |
| getFileObjectOf | back to summary |
|---|---|
| public default JavaFileObject getFileObjectOf(Element e) Returns the file object for this element or The returned file object is for the reference
representation of the information used to construct the
element. For example, if during compilation or annotation
processing, a source file for class An implementation may choose to not support the
functionality of this method, in which case In the context of annotation processing, a non- If it has a file object, the file object for a package will
be a If it has a file object, the file object for a module will
be a If it has a file object, the file object for a top-level
For a nested class or interface, if it has a file object:
For other lexically enclosed elements, such as variables, methods, and constructors, if they have a file object, the file object will be the object associated with the enclosing element of the lexically enclosed element. Implementation Specification The default implementation unconditionally throws
| |
| getModuleElement | back to summary |
|---|---|
| public default ModuleElement getModuleElement(CharSequence name) Returns a module element given its fully qualified name.
If the requested module cannot be found, Implementation Specification The default implementation of this method returns
| |
| getModuleOf | back to summary |
|---|---|
| public default ModuleElement getModuleOf(Element e) Returns the module of an element. The module of a module is
itself.
If a package has a module as its enclosing element, that
module is the module of the package. If the enclosing element
of a package is Implementation Specification The default implementation of this method returns
| |
| getName | back to summary |
|---|---|
| public Name getName(CharSequence cs) Returns a name with the same sequence of characters as the argument.
| |
| getOrigin | back to summary |
|---|---|
| public default Elements. Returns the origin of the given element. Note that if this method returns Implementation Specification The default implementation of this method returns
| |
| getOrigin | back to summary |
|---|---|
| public default Elements. Returns the origin of the given annotation mirror. An annotation mirror is mandated if it is an implicitly declared container annotation used to hold repeated annotations of a repeatable annotation interface. Note that if this method returns Implementation Specification The default implementation of this method returns
| |
| getOrigin | back to summary |
|---|---|
| public default Elements. Returns the origin of the given module directive. Note that if this method returns Note that an implementation may not be able to reliably determine the origin status of the directive if the directive is created from a class file due to limitations of the fidelity of the class file format in preserving information from source code. Implementation Specification The default implementation of this method returns
| |
| getOutermostTypeElement | back to summary |
|---|---|
| public default TypeElement getOutermostTypeElement(Element e) Returns the outermost type element an element is contained in
if such a containing element exists; otherwise returns Implementation Specification The default implementation of this method first checks the kind
of the argument. For elements of kind
| |
| getPackageElement | back to summary |
|---|---|
| public PackageElement getPackageElement(CharSequence name) Returns a package given its fully qualified name if the package is uniquely determinable in the environment. If running with modules, packages of the given name are searched in a two-stage process:
null is returned.
| |
| getPackageElement | back to summary |
|---|---|
| public default PackageElement getPackageElement(ModuleElement module, CharSequence name) Returns a package given its fully qualified name, as seen from the given module. Implementation Specification The default implementation of this method returns
| |
| getPackageOf | back to summary |
|---|---|
| public PackageElement getPackageOf(Element e) Returns the package of an element. The package of a package is
itself.
The package of a module is
| |
| getTypeElement | back to summary |
|---|---|
| public TypeElement getTypeElement(CharSequence name) Returns a type element given its canonical name if the type element is uniquely determinable in the environment. If running with modules, type elements of the given name are searched in a two-stage process:
null is returned.
| |
| getTypeElement | back to summary |
|---|---|
| public default TypeElement getTypeElement(ModuleElement module, CharSequence name) Returns a type element given its canonical name, as seen from the given module. Implementation Specification The default implementation of this method returns
| |
| hides | back to summary |
|---|---|
| public boolean hides(Element hider, Element hidden) Tests whether one type, method, or field hides another.
| |
| isAutomaticModule | back to summary |
|---|---|
| public default boolean isAutomaticModule(ModuleElement module) Returns Implementation Specification The default implementation of this method returns
| |
| isBridge | back to summary |
|---|---|
| public default boolean isBridge(ExecutableElement e) Returns Implementation Specification The default implementation of this method returns
| |
| isCanonicalConstructor | back to summary |
|---|---|
| public default boolean isCanonicalConstructor(ExecutableElement e) Returns Implementation Specification The default implementation of this method unconditionally
returns
| |
| isCompactConstructor | back to summary |
|---|---|
| public default boolean isCompactConstructor(ExecutableElement e) Returns Implementation Specification The default implementation of this method unconditionally
returns
| |
| isDeprecated | back to summary |
|---|---|
| public boolean isDeprecated(Element e) Returns
| |
| isFunctionalInterface | back to summary |
|---|---|
| public boolean isFunctionalInterface(TypeElement type) Returns
| |
| overrides | back to summary |
|---|---|
| public boolean overrides(ExecutableElement overrider, ExecutableElement overridden, TypeElement type) Tests whether one method, as a member of a given class or interface, overrides another method. When a non-abstract method overrides an abstract one, the former is also said to implement the latter. As implied by JLS 8.4.8.1, a method does not override itself. The overrides relation is irreflexive. In the simplest and most typical usage, the value of the
A more interesting case can be illustrated by the following example
in which a method in class A does not override a
like-named method in interface B:
When viewed as a member of a third class C, however,
the method in A does override the one in B:
Consistent with the usage of the @Override
annotation, if an interface declares a method
override-equivalent to a public method of java., such a method of the interface is regarded
as overriding the corresponding Object method; for
example:
interface I { @Override String toString(); } ... assert elements.overrides(elementForItoString, elementForObjecttoString, elements.getTypeElement("I")); API Note This method examines the method's name, signature, subclass relationship, and accessibility in determining whether one method overrides another, as specified in JLS 8.4.8.1. In addition, an implementation may have stricter checks including method modifiers, return types and exception types as described in JLS 8.4.8.1 and 8.4.8.3. Note that such additional compile-time checks are not guaranteed and may vary between implementations.
| |
| printElements | back to summary |
|---|---|
| public void printElements(Writer w, Element... elements) Prints a representation of the elements to the given writer in the specified order. The main purpose of this method is for diagnostics. The exact format of the output is not specified and is subject to change. | |
| recordComponentFor | back to summary |
|---|---|
| public default RecordComponentElement recordComponentFor(ExecutableElement accessor) Returns the record component for the given accessor. Returns
Implementation Specification The default implementation of this method checks if the element
enclosing the accessor has kind
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Elements. | END_OF_LINE
The kind of comments whose lines are prefixed by |
| public static final Elements. | TRADITIONAL
The kind of comments that begin with |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Elements. | |
| public static Elements. |
| END_OF_LINE | back to summary |
|---|---|
| public static final Elements. The kind of comments whose lines are prefixed by API Note The standard doclet used by the | |
| TRADITIONAL | back to summary |
|---|---|
| public static final Elements. The kind of comments that begin with API Note The standard doclet used by the | |
| DocCommentKind | back to summary |
|---|---|
| private DocCommentKind() | |
| valueOf | back to summary |
|---|---|
| public static Elements. | |
| values | back to summary |
|---|---|
| public static Elements. | |
Note that it is possible additional kinds of origin values will be added in future versions of the platform.
| Modifier and Type | Field and Description |
|---|---|
| public static final Elements. | EXPLICIT
Describes a construct explicitly declared in source code. |
| public static final Elements. | MANDATED
A mandated construct is one that is not explicitly declared in the source code, but whose presence is mandated by the specification. |
| public static final Elements. | SYNTHETIC
A synthetic construct is one that is neither implicitly nor explicitly declared in the source code. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isDeclared()
Returns |
| public static Elements. | |
| public static Elements. |
| EXPLICIT | back to summary |
|---|---|
| public static final Elements. Describes a construct explicitly declared in source code. | |
| MANDATED | back to summary |
|---|---|
| public static final Elements. A mandated construct is one that is not explicitly declared in the source code, but whose presence is mandated by the specification. Such a construct is said to be implicitly declared. One example of a mandated element is a default constructor in a class that contains no explicit constructor declarations. Another example of a mandated construct is an implicitly declared container annotation used to hold multiple annotations of a repeatable annotation interface. | |
| SYNTHETIC | back to summary |
|---|---|
| public static final Elements. A synthetic construct is one that is neither implicitly nor explicitly declared in the source code. Such a construct is typically a translation artifact created by a compiler. | |
| Origin | back to summary |
|---|---|
| private Origin() | |
| isDeclared | back to summary |
|---|---|
| public boolean isDeclared() Returns | |
| valueOf | back to summary |
|---|---|
| public static Elements. | |
| values | back to summary |
|---|---|
| public static Elements. | |