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 Details

    • process

      void process(A annotation, E element)
      Do the annotation processing job for a given annotation.
      Parameters:
      annotation - the annotation to process
      element - the element that holds the processed annotations
    • getProcessedAnnotationTypes

      Set<Class<? extends A>> getProcessedAnnotationTypes()
      Gets the annotations processed by this annotation processor, that is to say the annotation types that trigger the process(Annotation, CtElement) method when visiting a program element. The processed annotation types includes all the consumed annotation types.
      Returns:
      the annotation classes
    • getConsumedAnnotationTypes

      Set<Class<? extends A>> getConsumedAnnotationTypes()
      Gets the annotations types consumed by this processor. A consumed annotation is a special kind of processed annotation (see getProcessedAnnotationTypes() 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 the A actual type.
    • shoudBeConsumed

      boolean shoudBeConsumed(CtAnnotation<? extends Annotation> annotation)
      Returns true if this annotation should be removed from the processed code.