Package io.github.classgraph
Class AnnotationInfoList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<T>
-
- io.github.classgraph.PotentiallyUnmodifiableList<T>
-
- io.github.classgraph.InfoList<T>
-
- io.github.classgraph.MappableInfoList<AnnotationInfo>
-
- io.github.classgraph.AnnotationInfoList
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<AnnotationInfo>,java.util.Collection<AnnotationInfo>,java.util.List<AnnotationInfo>,java.util.RandomAccess
public class AnnotationInfoList extends MappableInfoList<AnnotationInfo>
A list ofAnnotationInfoobjects.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAnnotationInfoList.AnnotationInfoFilterFilter anAnnotationInfoListusing a predicate mapping anAnnotationInfoobject to a boolean, producing anotherAnnotationInfoListfor all items in the list for which the predicate is true.
-
Field Summary
Fields Modifier and Type Field Description private AnnotationInfoListdirectlyRelatedAnnotationsThe set of annotations directly related to a class or method and not inherited through a meta-annotated annotation.(package private) static AnnotationInfoListEMPTY_LISTAn unmodifiable emptyAnnotationInfoList.private static longserialVersionUIDserialVersionUID-
Fields inherited from class io.github.classgraph.PotentiallyUnmodifiableList
modifiable
-
-
Constructor Summary
Constructors Constructor Description AnnotationInfoList()Construct a new modifiable empty list ofAnnotationInfoobjects.AnnotationInfoList(int sizeHint)Construct a new modifiable empty list ofAnnotationInfoobjects, given a size hint.AnnotationInfoList(AnnotationInfoList reachableAnnotations)Construct a new modifiable emptyAnnotationInfoList, given an initial list ofAnnotationInfoobjects.AnnotationInfoList(AnnotationInfoList reachableAnnotations, AnnotationInfoList directlyRelatedAnnotations)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationInfoListdirectOnly()returns the list of direct annotations, excluding meta-annotations.static AnnotationInfoListemptyList()Return an unmodifiable emptyAnnotationInfoList.booleanequals(java.lang.Object obj)AnnotationInfoListfilter(AnnotationInfoList.AnnotationInfoFilter filter)Find the subset of theAnnotationInfoobjects in this list for which the given filter predicate is true.private static voidfindMetaAnnotations(AnnotationInfo ai, AnnotationInfoList allAnnotationsOut, java.util.Set<ClassInfo> visited)Find the transitive closure of meta-annotations.protected voidfindReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)GetClassInfoobjects for any classes referenced in this list.(package private) static AnnotationInfoListgetIndirectAnnotations(AnnotationInfoList directAnnotationInfo, ClassInfo annotatedClass)Get the indirect annotations on a class (meta-annotations and/or inherited annotations).AnnotationInfoListgetRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)Get theRepeatableannotation with the given class, or the empty list if none found.AnnotationInfoListgetRepeatable(java.lang.String name)Get theRepeatableannotation with the given name, or the empty list if none found.(package private) voidhandleRepeatableAnnotations(java.util.Set<java.lang.String> allRepeatableAnnotationNames, ClassInfo containingClassInfo, ClassInfo.RelType forwardRelType, ClassInfo.RelType reverseRelType0, ClassInfo.RelType reverseRelType1)HandleRepeatableannotations.inthashCode()-
Methods inherited from class io.github.classgraph.MappableInfoList
asMap, containsName, get
-
Methods inherited from class io.github.classgraph.InfoList
getAsStrings, getAsStringsWithSimpleNames, getNames
-
Methods inherited from class io.github.classgraph.PotentiallyUnmodifiableList
add, add, addAll, addAll, clear, iterator, listIterator, makeUnmodifiable, remove, remove, removeAll, retainAll, set
-
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, lastIndexOf, listIterator, removeIf, removeRange, replaceAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Field Detail
-
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. SeedirectOnly().
-
serialVersionUID
private static final long serialVersionUID
serialVersionUID- See Also:
- Constant Field Values
-
EMPTY_LIST
static final AnnotationInfoList EMPTY_LIST
An unmodifiable emptyAnnotationInfoList.
-
-
Constructor Detail
-
AnnotationInfoList
public AnnotationInfoList()
Construct a new modifiable empty list ofAnnotationInfoobjects.
-
AnnotationInfoList
public AnnotationInfoList(int sizeHint)
Construct a new modifiable empty list ofAnnotationInfoobjects, given a size hint.- Parameters:
sizeHint- the size hint
-
AnnotationInfoList
public AnnotationInfoList(AnnotationInfoList reachableAnnotations)
Construct a new modifiable emptyAnnotationInfoList, given an initial list ofAnnotationInfoobjects.- Parameters:
reachableAnnotations- the reachable annotations
-
AnnotationInfoList
AnnotationInfoList(AnnotationInfoList reachableAnnotations, AnnotationInfoList directlyRelatedAnnotations)
Constructor.- Parameters:
reachableAnnotations- the reachable annotationsdirectlyRelatedAnnotations- the directly related annotations
-
-
Method Detail
-
emptyList
public static AnnotationInfoList emptyList()
Return an unmodifiable emptyAnnotationInfoList.- Returns:
- the unmodifiable empty
AnnotationInfoList.
-
filter
public AnnotationInfoList filter(AnnotationInfoList.AnnotationInfoFilter filter)
Find the subset of theAnnotationInfoobjects in this list for which the given filter predicate is true.- Parameters:
filter- TheAnnotationInfoList.AnnotationInfoFilterto apply.- Returns:
- The subset of the
AnnotationInfoobjects in this list for which the given filter predicate is true.
-
findReferencedClassInfo
protected void findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfoobjects for any classes referenced in this list.- Parameters:
classNameToClassInfo- the map from class name toClassInfo.refdClassInfo- the referenced class infolog- the log
-
handleRepeatableAnnotations
void handleRepeatableAnnotations(java.util.Set<java.lang.String> allRepeatableAnnotationNames, ClassInfo containingClassInfo, ClassInfo.RelType forwardRelType, ClassInfo.RelType reverseRelType0, ClassInfo.RelType reverseRelType1)HandleRepeatableannotations.- Parameters:
allRepeatableAnnotationNames- the names of all repeatable annotationscontainingClassInfo- the containing classforwardRelType- 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, java.util.Set<ClassInfo> visited)
Find the transitive closure of meta-annotations.- Parameters:
ai- the annotationInfo objectallAnnotationsOut- annotations outvisited- 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 thisAnnotationInfoListconsists 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(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Get theRepeatableannotation 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(java.lang.String name)
Get theRepeatableannotation 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(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Collection<AnnotationInfo>- Specified by:
equalsin interfacejava.util.List<AnnotationInfo>- Overrides:
equalsin classInfoList<AnnotationInfo>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<AnnotationInfo>- Specified by:
hashCodein interfacejava.util.List<AnnotationInfo>- Overrides:
hashCodein classInfoList<AnnotationInfo>
-
-