javax.annotation.processing
abstract public class: AbstractProcessor [javadoc |
source]
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 {@linkplain
#getSupportedOptions options}, {@linkplain
#getSupportedAnnotationTypes annotations}, and {@linkplain
#getSupportedSourceVersion source version} supported by its
subtypes.
The getter methods may {@linkplain Messager#printMessage issue
warnings} about noteworthy conditions using the facilities available
after the processor has been {@linkplain #isInitialized
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.
- author:
Joseph
- D. Darcy
- author:
Scott
- Seligman
- author:
Peter
- von der Ahé
- since:
1.6
-
Field Summary |
---|
protected ProcessingEnvironment | processingEnv | Processing environment providing by the tool framework. |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.annotation.processing.AbstractProcessor Detail: |
public Iterable<Completion> getCompletions(Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText) {
return Collections.emptyList();
}
Returns an empty iterable of completions. |
public Set<String> getSupportedAnnotationTypes() {
SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
if (sat == null) {
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedAnnotationTypes annotation " +
"found on " + this.getClass().getName() +
", returning an empty set.");
return Collections.emptySet();
}
else
return arrayToSet(sat.value());
}
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. |
public Set<String> getSupportedOptions() {
SupportedOptions so = this.getClass().getAnnotation(SupportedOptions.class);
if (so == null)
return Collections.emptySet();
else
return arrayToSet(so.value());
}
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. |
public SourceVersion getSupportedSourceVersion() {
SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
SourceVersion sv = null;
if (ssv == null) {
sv = SourceVersion.RELEASE_6;
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedSourceVersion annotation " +
"found on " + this.getClass().getName() +
", returning " + sv + ".");
} else
sv = ssv.value();
return sv;
}
|
public synchronized void init(ProcessingEnvironment processingEnv) {
if (initialized)
throw new IllegalStateException("Cannot call init more than once.");
if (processingEnv == null)
throw new NullPointerException("Tool provided null ProcessingEnvironment");
this.processingEnv = processingEnv;
initialized = true;
}
Initializes the processor with the processing environment by
setting the {@code processingEnv} field to the value of the
{@code processingEnv} argument. An {@code
IllegalStateException} will be thrown if this method is called
more than once on the same object. |
protected synchronized boolean isInitialized() {
return initialized;
}
Returns {@code true} if this object has been {@linkplain #init
initialized}, {@code false} otherwise. |
abstract public boolean process(Set<TypeElement> annotations,
RoundEnvironment roundEnv)
|