public abstract class AbstractAnnotationProcessor<A extends java.lang.annotation.Annotation,E extends CtElement> extends AbstractProcessor<E> implements AnnotationProcessor<A,E>
Constructor and Description |
---|
AbstractAnnotationProcessor()
Empty constructor only for all processors (invoked by Spoon).
|
Modifier and Type | Method and Description |
---|---|
protected void |
addConsumedAnnotationType(java.lang.Class<? extends A> annotationType)
Adds a consumed annotation type (to be used in subclasses constructors).
|
protected void |
addProcessedAnnotationType(java.lang.Class<? extends A> annotationType)
Adds a processed annotation type (to be used in subclasses constructors).
|
protected void |
clearConsumedAnnotationTypes()
Clears the consumed annotation types.
|
protected void |
clearProcessedAnnotationTypes()
Clears the processed annotation types.
|
java.util.Set<java.lang.Class<? extends A>> |
getConsumedAnnotationTypes()
Gets the annotations types consumed by this processor.
|
java.util.Set<java.lang.Class<? extends A>> |
getProcessedAnnotationTypes()
Gets the annotations processed by this annotation processor, that is to
say the annotation types that trigger the
AnnotationProcessor.process(Annotation, CtElement) method when visiting a program
element. |
boolean |
inferConsumedAnnotationType()
Returns true (default) if the processor automatically infers the consumed
annotation type to the
A actual type. |
boolean |
isToBeProcessed(E element)
Returns true if the element is annotated with an annotation whose type is
processed.
|
void |
process(E element)
A callback method upcalled by the meta-model scanner to perform a
dedicated job on the currently scanned element.
|
protected void |
removeConsumedAnnotationType(java.lang.Class<? extends A> annotationType)
Removes a processed annotation type.
|
protected void |
removeProcessedAnnotationType(java.lang.Class<? extends A> annotationType)
Removes a processed annotation type.
|
boolean |
shoudBeConsumed(CtAnnotation<? extends java.lang.annotation.Annotation> annotation)
Returns true if this annotation should be removed from the processed code.
|
addProcessedElementType, clearProcessedElementType, getEnvironment, getFactory, getProcessedElementTypes, getTraversalStrategy, init, initProperties, interrupt, loadProperties, process, processingDone, removeProcessedElementType, setFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
process
getEnvironment, getProcessedElementTypes, getTraversalStrategy, init, initProperties, interrupt, process, processingDone
getFactory, setFactory
public AbstractAnnotationProcessor()
protected final void addConsumedAnnotationType(java.lang.Class<? extends A> annotationType)
protected final void addProcessedAnnotationType(java.lang.Class<? extends A> annotationType)
protected final void removeProcessedAnnotationType(java.lang.Class<? extends A> annotationType)
protected final void clearProcessedAnnotationTypes()
protected final void clearConsumedAnnotationTypes()
protected final void removeConsumedAnnotationType(java.lang.Class<? extends A> annotationType)
public final java.util.Set<java.lang.Class<? extends A>> getConsumedAnnotationTypes()
AnnotationProcessor
AnnotationProcessor.getProcessedAnnotationTypes()
that is automatically removed from
the program once the associated processor has finished its job.getConsumedAnnotationTypes
in interface AnnotationProcessor<A extends java.lang.annotation.Annotation,E extends CtElement>
public final java.util.Set<java.lang.Class<? extends A>> getProcessedAnnotationTypes()
AnnotationProcessor
AnnotationProcessor.process(Annotation, CtElement)
method when visiting a program
element. The processed annotation types includes all the consumed
annotation types.getProcessedAnnotationTypes
in interface AnnotationProcessor<A extends java.lang.annotation.Annotation,E extends CtElement>
public boolean inferConsumedAnnotationType()
AnnotationProcessor
A
actual type.inferConsumedAnnotationType
in interface AnnotationProcessor<A extends java.lang.annotation.Annotation,E extends CtElement>
public final boolean isToBeProcessed(E element)
isToBeProcessed
in interface Processor<E extends CtElement>
isToBeProcessed
in class AbstractProcessor<E extends CtElement>
element
- the candidateProcessor.process(CtElement)
public final void process(E element)
Processor
Processor.getProcessedElementTypes()
), the traversal strategy (
Processor.getTraversalStrategy()
), and the used processing manager (
Environment.getManager()
. Also, this method is upcalled only if
the method Processor.isToBeProcessed(CtElement)
returns true for a given
scanned element. In order to manually scan the meta-model, one can define
the Processor.process()
method instead.public boolean shoudBeConsumed(CtAnnotation<? extends java.lang.annotation.Annotation> annotation)
shoudBeConsumed
in interface AnnotationProcessor<A extends java.lang.annotation.Annotation,E extends CtElement>
Copyright © 2007–2021 Inria. All rights reserved.