Class AbstractProcessor
- java.lang.Object
-
- javax.annotation.processing.AbstractProcessor
- All Implemented Interfaces:
Processor
public abstract class AbstractProcessor extends Object implements Processor
An abstract annotation processor designed to be a convenient superclass for most concrete annotation processors. This class examines annotation values to compute the options, annotation types, and source version supported by its subtypes.
The getter methods may issue warnings about noteworthy conditions using the facilities available after the processor has been initialized.
Subclasses are free to override the implementation and specification of any of the methods in this class as long as the general Processor
contract for that method is obeyed.
- Since:
- 1.6
Fields
Modifier and Type | Field | Description |
---|---|---|
protected ProcessingEnvironment | processingEnv | Processing environment providing by the tool framework. |
Constructors
Modifier | Constructor | Description |
---|---|---|
protected | AbstractProcessor() | Constructor for subclasses to call. |
Methods
Modifier and Type | Method | Description |
---|---|---|
Iterable<? extends Completion> | getCompletions(Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText) | Returns an empty iterable of completions. |
Set<String> | getSupportedAnnotationTypes() | If the processor class is annotated with |
Set<String> | getSupportedOptions() | If the processor class is annotated with |
SourceVersion | getSupportedSourceVersion() | If the processor class is annotated with |
void | init(ProcessingEnvironment processingEnv) | Initializes the processor with the processing environment by setting the |
protected boolean | isInitialized() | Returns |
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface javax.annotation.processing.Processor
process
Fields
processingEnv
protected ProcessingEnvironment processingEnv
Processing environment providing by the tool framework.
Constructors
AbstractProcessor
protected AbstractProcessor()
Constructor for subclasses to call.
Methods
getSupportedOptions
public Set<String> getSupportedOptions()
If the processor class is annotated with SupportedOptions
, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned.
- Specified by:
-
getSupportedOptions
in interfaceProcessor
- Returns:
- the options recognized by this processor, or an empty set if none
- See Also:
SupportedOptions
getSupportedAnnotationTypes
public Set<String> getSupportedAnnotationTypes()
If the processor class is annotated with SupportedAnnotationTypes
, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned. If the source
version
does not support modules, in other words if it is less than or equal to RELEASE_8
, then any leading module prefixes
are stripped from the names.
- Specified by:
-
getSupportedAnnotationTypes
in interfaceProcessor
- Returns:
- the names of the annotation types supported by this processor, or an empty set if none
- See Also:
SupportedAnnotationTypes
getSupportedSourceVersion
public SourceVersion getSupportedSourceVersion()
If the processor class is annotated with SupportedSourceVersion
, return the source version in the annotation. If the class is not so annotated, SourceVersion.RELEASE_6
is returned.
- Specified by:
-
getSupportedSourceVersion
in interfaceProcessor
- Returns:
- the latest source version supported by this processor
- See Also:
-
SupportedSourceVersion
,ProcessingEnvironment.getSourceVersion()
init
public void init(ProcessingEnvironment processingEnv)
Initializes the processor with the processing environment by setting the processingEnv
field to the value of the processingEnv
argument. An
IllegalStateException
will be thrown if this method is called more than once on the same object.
- Specified by:
-
init
in interfaceProcessor
- Parameters:
-
processingEnv
- environment to access facilities the tool framework provides to the processor - Throws:
-
IllegalStateException
- if this method is called more than once.
getCompletions
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
Returns an empty iterable of completions.
- Specified by:
-
getCompletions
in interfaceProcessor
- Parameters:
-
element
- the element being annotated -
annotation
- the (perhaps partial) annotation being applied to the element -
member
- the annotation member to return possible completions for -
userText
- source code text to be completed - Returns:
- suggested completions to the annotation
isInitialized
protected boolean isInitialized()
Returns true
if this object has been initialized, false
otherwise.
- Returns:
-
true
if this object has been initialized,false
otherwise.
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/annotation/processing/AbstractProcessor.html