- 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
Processorcontract for that method is obeyed.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description protected ProcessingEnvironmentprocessingEnvProcessing environment providing by the tool framework.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractProcessor()Constructor for subclasses to call.
-
Method Summary
All Methods Instance Methods Concrete 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 withSupportedAnnotationTypes, return an unmodifiable set with the same set of strings as the annotation.Set<String>getSupportedOptions()If the processor class is annotated withSupportedOptions, return an unmodifiable set with the same set of strings as the annotation.SourceVersiongetSupportedSourceVersion()If the processor class is annotated withSupportedSourceVersion, return the source version in the annotation.voidinit(ProcessingEnvironment processingEnv)Initializes the processor with the processing environment by setting theprocessingEnvfield to the value of theprocessingEnvargument.protected booleanisInitialized()
-
-
-
Field Detail
-
processingEnv
protected ProcessingEnvironment processingEnv
Processing environment providing by the tool framework.
-
-
Method Detail
-
getSupportedOptions
public Set<String> getSupportedOptions()
If the processor class is annotated withSupportedOptions, 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:
getSupportedOptionsin 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 withSupportedAnnotationTypes, 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 thesource versiondoes not support modules, in other words if it is less than or equal toRELEASE_8, then any leadingmodule prefixesare stripped from the names.- Specified by:
getSupportedAnnotationTypesin 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 withSupportedSourceVersion, return the source version in the annotation. If the class is not so annotated,SourceVersion.RELEASE_6is returned.- Specified by:
getSupportedSourceVersionin 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 theprocessingEnvfield to the value of theprocessingEnvargument. AnIllegalStateExceptionwill be thrown if this method is called more than once on the same object.- Specified by:
initin 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:
getCompletionsin interfaceProcessor- Parameters:
element- the element being annotatedannotation- the (perhaps partial) annotation being applied to the elementmember- the annotation member to return possible completions foruserText- source code text to be completed- Returns:
- suggested completions to the annotation
-
isInitialized
protected boolean isInitialized()
- Returns:
trueif this object has been initialized,falseotherwise.
-
-