Class AbstractAnnotationProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.github.tadukoo.annotation.processor.AbstractAnnotationProcessor
- All Implemented Interfaces:
javax.annotation.processing.Processor
- Direct Known Subclasses:
AnnotationProcessorProcessor
,ShouldBeFinalProcessor
public abstract class AbstractAnnotationProcessor
extends javax.annotation.processing.AbstractProcessor
An Abstract Annotation Process to be used in creating new annotation processors in a
simpler way than having them extend
Also includes
AbstractProcessor
themselves.
Also includes
AnnotationUtil
to make it easier to perform common operations
in processors.- Version:
- Pre-Alpha
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<? extends java.lang.annotation.Annotation>
annotation
The Annotation class this processor is used forprotected AnnotationUtil
annotationUtil
AnnotationUtil
to use for common annotation processing operationsFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv
-
Constructor Summary
Constructors Constructor Description AbstractAnnotationProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Calls the AbstractProcessor constructor and sets the Annotation class this processor is used for. -
Method Summary
Modifier and Type Method Description java.util.Set<java.lang.String>
getSupportedAnnotationTypes()
Returns the Annotation type this is for, by grabbing the name off the stored Annotation class.void
init(javax.annotation.processing.ProcessingEnvironment processingEnvironment)
Calls the AbstractProcessor init method and then uses the givenProcessingEnvironment
to initialize theAnnotationUtil
.boolean
process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)
Processes the annotation on the elements it's attached to.protected abstract void
processElements(java.util.Set<? extends javax.lang.model.element.Element> elements)
Actually handle processing the given elements for the annotation this handles.Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedOptions, getSupportedSourceVersion, isInitialized
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
annotationUtil
AnnotationUtil
to use for common annotation processing operations -
annotation
private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationThe Annotation class this processor is used for
-
-
Constructor Details
-
AbstractAnnotationProcessor
public AbstractAnnotationProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Calls the AbstractProcessor constructor and sets the Annotation class this processor is used for.- Parameters:
annotation
- The Annotation class this is for
-
-
Method Details
-
init
public final void init(javax.annotation.processing.ProcessingEnvironment processingEnvironment)Calls the AbstractProcessor init method and then uses the givenProcessingEnvironment
to initialize theAnnotationUtil
.- Specified by:
init
in interfacejavax.annotation.processing.Processor
- Overrides:
init
in classjavax.annotation.processing.AbstractProcessor
- Parameters:
processingEnvironment
- The ProcessingEnvironment this is happening in
-
getSupportedAnnotationTypes
public final java.util.Set<java.lang.String> getSupportedAnnotationTypes()Returns the Annotation type this is for, by grabbing the name off the stored Annotation class.- Specified by:
getSupportedAnnotationTypes
in interfacejavax.annotation.processing.Processor
- Overrides:
getSupportedAnnotationTypes
in classjavax.annotation.processing.AbstractProcessor
- Returns:
- The Annotation type this processor is for
-
process
public final boolean process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)Processes the annotation on the elements it's attached to. Ultimately callsprocessElements(java.util.Set<? extends javax.lang.model.element.Element>)
to do the actual processing. IfprocessElements(java.util.Set<? extends javax.lang.model.element.Element>)
throws anything, it throws a compile error on the relevant annotation with the stack trace.- Specified by:
process
in interfacejavax.annotation.processing.Processor
- Specified by:
process
in classjavax.annotation.processing.AbstractProcessor
- Parameters:
annotations
- The annotations to process (should just be the one this processor is for)roundEnv
- The RoundEnvironment used for grabbing the elements- Returns:
- True
-
processElements
protected abstract void processElements(java.util.Set<? extends javax.lang.model.element.Element> elements) throws java.lang.ThrowableActually handle processing the given elements for the annotation this handles.- Parameters:
elements
- The Set of elements to process for the annotation- Throws:
java.lang.Throwable
- If anything goes wrong, subclasses may throw something
-