Package spoon.processing
Interface AnnotationProcessor<A extends Annotation,E extends CtElement>
- All Superinterfaces:
FactoryAccessor
,Processor<E>
- All Known Implementing Classes:
AbstractAnnotationProcessor
public interface AnnotationProcessor<A extends Annotation,E extends CtElement>
extends Processor<E>
This interface defines an annotation processor. An annotation processor is
triggered by Spoon when a visited element is annotated with one of the
processed or consumed annotations. To define a new annotation processor, the
user should subclass
AbstractAnnotationProcessor
,
the abstract default implementation of this interface.-
Method Summary
Modifier and TypeMethodDescriptionGets the annotations types consumed by this processor.Gets the annotations processed by this annotation processor, that is to say the annotation types that trigger theprocess(Annotation, CtElement)
method when visiting a program element.boolean
Returns true (default) if the processor automatically infers the consumed annotation type to theA
actual type.void
Do the annotation processing job for a given annotation.boolean
shoudBeConsumed(CtAnnotation<? extends Annotation> annotation)
Returns true if this annotation should be removed from the processed code.Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
Methods inherited from interface spoon.processing.Processor
getEnvironment, getProcessedElementTypes, getTraversalStrategy, init, initProperties, interrupt, isToBeProcessed, process, process, processingDone
-
Method Details
-
process
Do the annotation processing job for a given annotation.- Parameters:
annotation
- the annotation to processelement
- the element that holds the processed annotations
-
getProcessedAnnotationTypes
Gets the annotations processed by this annotation processor, that is to say the annotation types that trigger theprocess(Annotation, CtElement)
method when visiting a program element. The processed annotation types includes all the consumed annotation types.- Returns:
- the annotation classes
-
getConsumedAnnotationTypes
Gets the annotations types consumed by this processor. A consumed annotation is a special kind of processed annotation (seegetProcessedAnnotationTypes()
that is automatically removed from the program once the associated processor has finished its job.- Returns:
- the annotation classes
-
inferConsumedAnnotationType
boolean inferConsumedAnnotationType()Returns true (default) if the processor automatically infers the consumed annotation type to theA
actual type. -
shoudBeConsumed
Returns true if this annotation should be removed from the processed code.
-