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 ofAnnotationInfo
objects.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AnnotationInfoList.AnnotationInfoFilter
Filter anAnnotationInfoList
using a predicate mapping anAnnotationInfo
object to a boolean, producing anotherAnnotationInfoList
for all items in the list for which the predicate is true.
-
Field Summary
Fields Modifier and Type Field Description private AnnotationInfoList
directlyRelatedAnnotations
The set of annotations directly related to a class or method and not inherited through a meta-annotated annotation.(package private) static AnnotationInfoList
EMPTY_LIST
An unmodifiable emptyAnnotationInfoList
.private static long
serialVersionUID
serialVersionUID-
Fields inherited from class io.github.classgraph.PotentiallyUnmodifiableList
modifiable
-
-
Constructor Summary
Constructors Constructor Description AnnotationInfoList()
Construct a new modifiable empty list ofAnnotationInfo
objects.AnnotationInfoList(int sizeHint)
Construct a new modifiable empty list ofAnnotationInfo
objects, given a size hint.AnnotationInfoList(AnnotationInfoList reachableAnnotations)
Construct a new modifiable emptyAnnotationInfoList
, given an initial list ofAnnotationInfo
objects.AnnotationInfoList(AnnotationInfoList reachableAnnotations, AnnotationInfoList directlyRelatedAnnotations)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationInfoList
directOnly()
returns the list of direct annotations, excluding meta-annotations.static AnnotationInfoList
emptyList()
Return an unmodifiable emptyAnnotationInfoList
.boolean
equals(java.lang.Object obj)
AnnotationInfoList
filter(AnnotationInfoList.AnnotationInfoFilter filter)
Find the subset of theAnnotationInfo
objects in this list for which the given filter predicate is true.private static void
findMetaAnnotations(AnnotationInfo ai, AnnotationInfoList allAnnotationsOut, java.util.Set<ClassInfo> visited)
Find the transitive closure of meta-annotations.protected void
findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfo
objects for any classes referenced in this list.(package private) static AnnotationInfoList
getIndirectAnnotations(AnnotationInfoList directAnnotationInfo, ClassInfo annotatedClass)
Get the indirect annotations on a class (meta-annotations and/or inherited annotations).AnnotationInfoList
getRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Get theRepeatable
annotation with the given class, or the empty list if none found.AnnotationInfoList
getRepeatable(java.lang.String name)
Get theRepeatable
annotation with the given name, or the empty list if none found.(package private) void
handleRepeatableAnnotations(java.util.Set<java.lang.String> allRepeatableAnnotationNames, ClassInfo containingClassInfo, ClassInfo.RelType forwardRelType, ClassInfo.RelType reverseRelType0, ClassInfo.RelType reverseRelType1)
HandleRepeatable
annotations.int
hashCode()
-
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 ofAnnotationInfo
objects.
-
AnnotationInfoList
public AnnotationInfoList(int sizeHint)
Construct a new modifiable empty list ofAnnotationInfo
objects, given a size hint.- Parameters:
sizeHint
- the size hint
-
AnnotationInfoList
public AnnotationInfoList(AnnotationInfoList reachableAnnotations)
Construct a new modifiable emptyAnnotationInfoList
, given an initial list ofAnnotationInfo
objects.- 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 theAnnotationInfo
objects in this list for which the given filter predicate is true.- Parameters:
filter
- TheAnnotationInfoList.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(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfo
objects 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)
HandleRepeatable
annotations.- 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 thisAnnotationInfoList
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(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Get theRepeatable
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(java.lang.String name)
Get theRepeatable
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(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Collection<AnnotationInfo>
- Specified by:
equals
in interfacejava.util.List<AnnotationInfo>
- Overrides:
equals
in classInfoList<AnnotationInfo>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<AnnotationInfo>
- Specified by:
hashCode
in interfacejava.util.List<AnnotationInfo>
- Overrides:
hashCode
in classInfoList<AnnotationInfo>
-
-