APIdia Launch Partner
Top Description Fields Constructors Methods
javax.annotation.processing

public abstract Class AbstractProcessor

extends Object
implements Processor
Class Inheritance
All Implemented Interfaces
javax.annotation.processing.Processor
Imports
java.util.List, .Set, .HashSet, .Collections, .Objects, javax.lang.model.element.*, javax.lang.model.SourceVersion, javax.tools.Diagnostic

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

Modifier and TypeField and Description
private boolean
protected ProcessingEnvironment
processingEnv

Processing environment providing by the tool framework.

Constructor Summary

AccessConstructor and Description
protected
AbstractProcessor()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
private Set<String>
arrayToSet(String[] array, boolean stripModulePrefixes, String contentType, String annotationName)

public Iterable<? extends Completion>

Returns:

an empty iterable of completions
getCompletions
(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)

Implements javax.annotation.processing.Processor.getCompletions.

Returns an empty iterable of completions.

public Set<String>
getSupportedAnnotationTypes()

Implements javax.annotation.processing.Processor.getSupportedAnnotationTypes.

Returns the names of the annotation interfaces supported by this processor.

public Set<String>

Returns:

the options recognized by this processor, or an empty set if none
getSupportedOptions
()

Implements javax.annotation.processing.Processor.getSupportedOptions.

Returns the options recognized by this processor.

public SourceVersion
getSupportedSourceVersion()

Implements javax.annotation.processing.Processor.getSupportedSourceVersion.

Returns the latest source version supported by this annotation processor.

public synchronized void
init(ProcessingEnvironment
environment to access facilities the tool framework provides to the processor
processingEnv
)

Implements javax.annotation.processing.Processor.init.

Initializes the processor with the processing environment.

protected synchronized boolean

Returns:

true if this object has been initialized, false otherwise
isInitialized
()

Returns true if this object has been initialized, false otherwise.

public abstract boolean
process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)

Redeclares javax.annotation.processing.Processor.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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

initializedback to summary
private boolean initialized
processingEnvback to summary
protected ProcessingEnvironment processingEnv

Processing environment providing by the tool framework.

Constructor Detail

AbstractProcessorback to summary
protected AbstractProcessor()

Constructor for subclasses to call.

Method Detail

arrayToSetback to summary
private Set<String> arrayToSet(String[] array, boolean stripModulePrefixes, String contentType, String annotationName)
getCompletionsback to summary
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)

Implements javax.annotation.processing.Processor.getCompletions.

Returns an empty iterable of completions.

Returns:Iterable<? extends Completion>

an empty iterable of completions

Annotations
@Override
getSupportedAnnotationTypesback to summary
public Set<String> getSupportedAnnotationTypes()

Implements javax.annotation.processing.Processor.getSupportedAnnotationTypes.

Returns the names of the annotation interfaces supported by this processor.

Implementation Specification

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.

Annotations
@Override
getSupportedOptionsback to summary
public Set<String> getSupportedOptions()

Implements javax.annotation.processing.Processor.getSupportedOptions.

Returns the options recognized by this processor.

Implementation Specification

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:Set<String>

the options recognized by this processor, or an empty set if none

Annotations
@Override
getSupportedSourceVersionback to summary
public SourceVersion getSupportedSourceVersion()

Implements javax.annotation.processing.Processor.getSupportedSourceVersion.

Doc from javax.annotation.processing.Processor.getSupportedSourceVersion.

Returns the latest source version supported by this annotation processor.

Implementation Specification

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.

Annotations
@Override
initback to summary
public synchronized void init(ProcessingEnvironment processingEnv)

Implements javax.annotation.processing.Processor.init.

Doc from javax.annotation.processing.Processor.init.

Initializes the processor with the processing environment.

Implementation Specification

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.

Parameters
processingEnv:ProcessingEnvironment

environment to access facilities the tool framework provides to the processor

Exceptions
IllegalStateException:
if this method is called more than once.
isInitializedback to summary
protected synchronized boolean isInitialized()

Returns true if this object has been initialized, false otherwise.

Returns:boolean

true if this object has been initialized, false otherwise

processback to summary
public abstract boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)

Redeclares javax.annotation.processing.Processor.process.

Doc from javax.annotation.processing.Processor.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. If true is returned, the annotation interfaces are claimed and subsequent processors will not be asked to process them; if false is 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. A Processor must gracefully handle an empty set of annotations.

Annotations
@Override