Class AnnotationInfoList

All Implemented Interfaces:
Serializable, Cloneable, Iterable<AnnotationInfo>, Collection<AnnotationInfo>, List<AnnotationInfo>, RandomAccess, SequencedCollection<AnnotationInfo>

public class AnnotationInfoList extends MappableInfoList<AnnotationInfo>
A list of AnnotationInfo objects.
See Also:
  • Field Details

    • directlyRelatedAnnotations

      private AnnotationInfoList directlyRelatedAnnotations
      The set of annotations directly related to a class or method and not inherited through a meta-annotated annotation. This field is nullable, as the annotation info list is incrementally built. See directOnly().
    • serialVersionUID

      private static final long serialVersionUID
      serialVersionUID
      See Also:
    • EMPTY_LIST

      static final AnnotationInfoList EMPTY_LIST
      An unmodifiable empty AnnotationInfoList.
  • Constructor Details

    • AnnotationInfoList

      public AnnotationInfoList()
      Construct a new modifiable empty list of AnnotationInfo objects.
    • AnnotationInfoList

      public AnnotationInfoList(int sizeHint)
      Construct a new modifiable empty list of AnnotationInfo objects, given a size hint.
      Parameters:
      sizeHint - the size hint
    • AnnotationInfoList

      public AnnotationInfoList(AnnotationInfoList reachableAnnotations)
      Construct a new modifiable empty AnnotationInfoList, given an initial list of AnnotationInfo objects.
      Parameters:
      reachableAnnotations - the reachable annotations
    • AnnotationInfoList

      AnnotationInfoList(AnnotationInfoList reachableAnnotations, AnnotationInfoList directlyRelatedAnnotations)
      Constructor.
      Parameters:
      reachableAnnotations - the reachable annotations
      directlyRelatedAnnotations - the directly related annotations
  • Method Details

    • emptyList

      public static AnnotationInfoList emptyList()
      Return an unmodifiable empty AnnotationInfoList.
      Returns:
      the unmodifiable empty AnnotationInfoList.
    • filter

      Find the subset of the AnnotationInfo objects in this list for which the given filter predicate is true.
      Parameters:
      filter - The AnnotationInfoList.AnnotationInfoFilter to apply.
      Returns:
      The subset of the AnnotationInfo objects in this list for which the given filter predicate is true.
    • findReferencedClassInfo

      protected void findReferencedClassInfo(Map<String,ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log)
      Get ClassInfo objects for any classes referenced in this list.
      Parameters:
      classNameToClassInfo - the map from class name to ClassInfo.
      refdClassInfo - the referenced class info
      log - the log
    • handleRepeatableAnnotations

      void handleRepeatableAnnotations(Set<String> allRepeatableAnnotationNames, ClassInfo containingClassInfo, ClassInfo.RelType forwardRelType, ClassInfo.RelType reverseRelType0, ClassInfo.RelType reverseRelType1)
      Handle Repeatable annotations.
      Parameters:
      allRepeatableAnnotationNames - the names of all repeatable annotations
      containingClassInfo - the containing class
      forwardRelType - the forward relationship type for linking (or null for none)
      reverseRelType0 - the first reverse relationship type for linking (or null for none)
      reverseRelType1 - the second reverse relationship type for linking (or null for none)
    • findMetaAnnotations

      private static void findMetaAnnotations(AnnotationInfo ai, AnnotationInfoList allAnnotationsOut, Set<ClassInfo> visited)
      Find the transitive closure of meta-annotations.
      Parameters:
      ai - the annotationInfo object
      allAnnotationsOut - annotations out
      visited - visited
    • getIndirectAnnotations

      static AnnotationInfoList getIndirectAnnotations(AnnotationInfoList directAnnotationInfo, ClassInfo annotatedClass)
      Get the indirect annotations on a class (meta-annotations and/or inherited annotations).
      Parameters:
      directAnnotationInfo - the direct annotations on the class, method, method parameter or field.
      annotatedClass - for class annotations, this is the annotated class, else null.
      Returns:
      the indirect annotations
    • directOnly

      public AnnotationInfoList directOnly()
      returns the list of direct annotations, excluding meta-annotations. If this AnnotationInfoList consists of class annotations, i.e. if it was produced using `ClassInfo#getAnnotationInfo()`, then the returned list also excludes annotations inherited from a superclass or implemented interface that was meta-annotated with @Inherited.
      Returns:
      The list of directly-related annotations.
    • getRepeatable

      public AnnotationInfoList getRepeatable(Class<? extends Annotation> annotationClass)
      Get the Repeatable annotation with the given class, or the empty list if none found.
      Parameters:
      annotationClass - The class to search for.
      Returns:
      The list of annotations with the given class, or the empty list if none found.
    • getRepeatable

      public AnnotationInfoList getRepeatable(String name)
      Get the Repeatable annotation with the given name, or the empty list if none found.
      Parameters:
      name - The name to search for.
      Returns:
      The list of annotations with the given name, or the empty list if none found.
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<AnnotationInfo>
      Specified by:
      equals in interface List<AnnotationInfo>
      Overrides:
      equals in class InfoList<AnnotationInfo>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<AnnotationInfo>
      Specified by:
      hashCode in interface List<AnnotationInfo>
      Overrides:
      hashCode in class InfoList<AnnotationInfo>