# 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 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

Fields
Modifier and Type
Field
Description
`protected ProcessingEnvironment`
`processingEnv`
Processing environment providing by the tool framework.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractProcessor()`
Constructor for subclasses to call.

## Method Summary

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()`
Returns the names of the annotation interfaces supported by this processor.
`Set<String>`
`getSupportedOptions()`
Returns the options recognized by this processor.
`SourceVersion`
`getSupportedSourceVersion()`
Returns the latest source version supported by this annotation processor.
`void`
`init(ProcessingEnvironment processingEnv)`
Initializes the processor with the processing environment.
`protected boolean`
`isInitialized()`
Returns `true` if this object has been initialized, `false` otherwise.
`abstract boolean`
`process(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, wait`
Modifier and Type
Method
Description
`protected Object`
`clone()`
Creates and returns a copy of this object.
`boolean`
`equals(Object obj)`
Indicates whether some other object is "equal to" this one.
`protected void`
`finalize()`
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
`final Class<?>`
`getClass()`
Returns the runtime class of this `Object`.
`int`
`hashCode()`
Returns a hash code value for this object.
`final void`
`notify()`
Wakes up a single thread that is waiting on this object's monitor.
`final void`
`notifyAll()`
Wakes up all threads that are waiting on this object's monitor.
`String`
`toString()`
Returns a string representation of the object.
`final void`
`wait()`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
`final void`
`wait(long timeoutMillis)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
`final void`
`wait(long timeoutMillis, int nanos)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

## Field Details

### processingEnv

protected ProcessingEnvironment processingEnv
Processing environment providing by the tool framework.

## Constructor Details

### AbstractProcessor

protected AbstractProcessor()
Constructor for subclasses to call.

## Method Details

### getSupportedOptions

public Set<String> getSupportedOptions()
Returns the options recognized by this processor.

Specified by:
  `getSupportedOptions` in interface `Processor`
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:
  - `SupportedOptions`

### getSupportedAnnotationTypes

public Set<String> getSupportedAnnotationTypes()
Returns the names of the annotation interfaces supported by this processor.

Specified by:
  `getSupportedAnnotationTypes` in interface `Processor`
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 to `RELEASE_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:
  - `SupportedAnnotationTypes`

### getSupportedSourceVersion

public SourceVersion getSupportedSourceVersion()
Returns the latest source version supported by this annotation processor.

Specified by:
  `getSupportedSourceVersion` in interface `Processor`
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_6` is returned.
Returns:
  the latest source version supported by this annotation processor
See Also:
  - `SupportedSourceVersion`
  - `ProcessingEnvironment.getSourceVersion()`

### init

public void init(ProcessingEnvironment processingEnv)
Initializes the processor with the processing environment.

Specified by:
  `init` in interface `Processor`
Implementation Requirements:
  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` - environment to access facilities the tool framework provides to the processor
Throws:
  `IllegalStateException` - if this method is called more than once.

### process

public abstract boolean process(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. 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.

Specified by:
  `process` in interface `Processor`
Parameters:
  `annotations` - the annotation interfaces requested to be processed
  `roundEnv` - environment for information about the current and prior round
Returns:
  whether or not the set of annotation interfaces are claimed by this processor

### getCompletions

public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
Returns an empty iterable of completions.

Specified by:
  `getCompletions` in interface `Processor`
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:
  an empty iterable of completions

### isInitialized

protected boolean isInitialized()
Returns `true` if this object has been initialized, `false` otherwise.

Returns:
  `true` if this object has been initialized, `false` otherwise