Class AbstractProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
- All Implemented Interfaces:
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 interfaces, 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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ProcessingEnvironmentProcessing environment providing by the tool framework. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) Returns an empty iterable of completions.Returns the names of the annotation interfaces supported by this processor.Returns the options recognized by this processor.Returns the latest source version supported by this annotation processor.voidinit(ProcessingEnvironment processingEnv) Initializes the processor with the processing environment.protected booleanabstract booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
processingEnv
Processing environment providing by the tool framework.
-
-
Constructor Details
-
AbstractProcessor
protected AbstractProcessor()Constructor for subclasses to call.
-
-
Method Details
-
getSupportedOptions
Returns the options recognized by this processor.- Specified by:
getSupportedOptionsin interfaceProcessor- Implementation Requirements:
- 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. - Returns:
- the options recognized by this processor, or an empty set if none
- See Also:
-
getSupportedAnnotationTypes
Returns the names of the annotation interfaces supported by this processor.- Specified by:
getSupportedAnnotationTypesin interfaceProcessor- Implementation Requirements:
- 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 toRELEASE_8, then any leading module prefixes are stripped from the names. - Returns:
- the names of the annotation interfaces supported by this processor or an empty set if none
- See Also:
-
getSupportedSourceVersion
Returns the latest source version supported by this annotation processor.- Specified by:
getSupportedSourceVersionin interfaceProcessor- Implementation Requirements:
- If the processor class is annotated with
SupportedSourceVersion, return the source version in the annotation. If the class is not so annotated,SourceVersion.RELEASE_6is returned. - Returns:
- the latest source version supported by this annotation processor
- See Also:
-
init
Initializes the processor with the processing environment.- Specified by:
initin interfaceProcessor- Implementation Requirements:
- Initializes the processor with the processing environment by
setting the
processingEnvfield to the value of theprocessingEnvargument. AnIllegalStateExceptionwill be thrown if this method is called more than once on the same object. - Parameters:
processingEnv- environment to access facilities the tool framework provides to the processor- Throws:
IllegalStateException- if this method is called more than once.
-
process
Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor. Iftrueis returned, the annotation interfaces are claimed and subsequent processors will not be asked to process them; iffalseis returned, the annotation interfaces are unclaimed and subsequent processors may be asked to process them. A processor may always return the same boolean value or may vary the result based on its own chosen criteria.The input set will be empty if the processor supports
"*"and the root elements have no annotations. AProcessormust gracefully handle an empty set of annotations. -
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:
- an empty iterable of completions
-
isInitialized
protected boolean isInitialized()- Returns:
trueif this object has been initialized,falseotherwise
-