public abstract class AbstractServiceProcessor
extends javax.annotation.processing.AbstractProcessor
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowGenerics |
protected java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationClass |
protected javax.lang.model.util.Elements |
elements |
protected java.lang.String |
interfaceName |
protected javax.lang.model.util.Types |
types |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractServiceProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
java.lang.Class<?> interfaceClass,
boolean allowGenerics)
Constructor
|
protected |
AbstractServiceProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
java.lang.String interfaceName,
boolean allowGenerics)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
error(javax.lang.model.element.Element ele,
java.lang.String fmt,
java.lang.Object... args)
Prints an error message using the
Messager object that is
associated with the given element's location. |
protected void |
error(java.lang.String fmt,
java.lang.Object... args)
Prints an error message using the
Messager object. |
java.util.Set<java.lang.String> |
getSupportedAnnotationTypes() |
javax.lang.model.SourceVersion |
getSupportedSourceVersion() |
void |
init(javax.annotation.processing.ProcessingEnvironment procEnv) |
boolean |
process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
javax.annotation.processing.RoundEnvironment roundEnv) |
protected abstract void |
produceOutput()
Function that is called after all annotation processing is finished.
|
protected abstract void |
visitClass(javax.lang.model.element.TypeElement classEle,
java.lang.String className)
Function that is called on every annotated class that is visited.
|
protected void |
writeResourceList(java.lang.String resourceName,
java.util.Collection<java.lang.String> entries)
Function that writes a resource list into the class output directory.
|
protected final java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass
protected final java.lang.String interfaceName
protected final boolean allowGenerics
protected javax.lang.model.util.Elements elements
protected javax.lang.model.util.Types types
protected AbstractServiceProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
java.lang.Class<?> interfaceClass,
boolean allowGenerics)
annotationClass - Class object which describes the annotationinterfaceClass - Class object which describes the interface which the annotated classes must implementallowGenerics - Are generic implementations of the interface allowed? Else, they are an errorprotected AbstractServiceProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
java.lang.String interfaceName,
boolean allowGenerics)
annotationClass - Class object which describes the annotationinterfaceName - Full Name of the interface which describes the interface which the annotated classes
must implementallowGenerics - Are generic implementations of the interface allowed? Else, they are an errorprotected abstract void visitClass(javax.lang.model.element.TypeElement classEle,
java.lang.String className)
process, every class that is
annotated with our annotation has some sanity-checks applied (e.g. does it implement the required interface)
and then this function is called on it.classEle - The TypeElement that represents the class that is being compiled.className - The name of the class represented by classEle.protected abstract void produceOutput()
writeResourceListpublic void init(javax.annotation.processing.ProcessingEnvironment procEnv)
init in interface javax.annotation.processing.Processorinit in class javax.annotation.processing.AbstractProcessorpublic java.util.Set<java.lang.String> getSupportedAnnotationTypes()
getSupportedAnnotationTypes in interface javax.annotation.processing.ProcessorgetSupportedAnnotationTypes in class javax.annotation.processing.AbstractProcessorpublic javax.lang.model.SourceVersion getSupportedSourceVersion()
getSupportedSourceVersion in interface javax.annotation.processing.ProcessorgetSupportedSourceVersion in class javax.annotation.processing.AbstractProcessorpublic boolean process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
javax.annotation.processing.RoundEnvironment roundEnv)
process in interface javax.annotation.processing.Processorprocess in class javax.annotation.processing.AbstractProcessorprotected void writeResourceList(java.lang.String resourceName,
java.util.Collection<java.lang.String> entries)
throws java.io.IOException
resourceName - Name of the file in which the resource list should be saved.entries - Entries that should be added to the list.java.io.IOException - In case I/O errors occur.protected void error(java.lang.String fmt,
java.lang.Object... args)
Messager object.fmt - format string for
String.format(String, Object...)args - arguments used in the format stringprotected void error(javax.lang.model.element.Element ele,
java.lang.String fmt,
java.lang.Object... args)
Messager object that is
associated with the given element's location.ele - element that the error message is associated withfmt - format string for
String.format(String, Object...)args - arguments used in the format string