Class AnnotatedElements

java.lang.Object
be.imgn.gaia.processing.AnnotatedElements

public final class AnnotatedElements extends Object
The elements a Step gets in a round, by annotation, and by meta-annotation for the step's meta-annotations; and the root elements of the round, if the step processes them.
for (Element mapper : elements.annotatedWith("com.example.Mapper")) {
    ...
}

An element found by a meta-annotation is also listed under the annotation it is annotated with, the one whose type has the meta-annotation: with @Qualifier @interface Primary, an element annotated with @Primary is in both withAnnotationsAnnotatedWith("javax.inject.Qualifier") and annotatedWith("com.example.Primary").

  • Method Details

    • annotatedWith

      public Set<Element> annotatedWith(String qualifiedName)
      Returns the elements annotated with an annotation.
      Parameters:
      qualifiedName - the fully qualified name of the annotation type
      Returns:
      the elements, in source order; empty if there is none
    • withAnnotationsAnnotatedWith

      public Set<Element> withAnnotationsAnnotatedWith(String metaAnnotation)
      Returns the elements annotated with an annotation whose type is annotated with a meta-annotation of the step: with javax.inject.Qualifier, the elements annotated with a qualifier, such as @Named("primary"). Only the meta-annotations of the annotation type itself count, as for ProcessingContext.annotationsAnnotatedWith(Element, String), which reads those annotations.
      Parameters:
      metaAnnotation - the fully qualified name of the meta-annotation type, one of Step.metaAnnotations()
      Returns:
      the elements, by annotation and then in source order; empty if there is none, or if the step does not declare that meta-annotation
    • rootElements

      public Set<Element> rootElements()
      Returns the root elements of the round, annotated or not, if the step processes them: its top-level types, and the packages and modules its package-info and module-info files declare.
      Returns:
      the root elements, in the order javac gives them; empty if the step does not process them
      Since:
      0.1.2
    • all

      public Set<Element> all()
      Returns every annotated element, whatever its annotation, each once. The root elements are not among them, unless they are annotated.
      Returns:
      the elements, by annotation and then in source order
    • annotations

      public Set<String> annotations()
      Returns the annotations at least one element has: those of the step, and those found by its meta-annotations.
      Returns:
      the fully qualified names of the annotation types
    • isEmpty

      public boolean isEmpty()
      Returns whether there is no element.
      Returns:
      true if no element is annotated, and there is no root element
    • toString

      public String toString()
      Overrides:
      toString in class Object