Package io.github.classgraph
Class AnnotationInfoList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<AnnotationInfo>
,Collection<AnnotationInfo>
,List<AnnotationInfo>
,RandomAccess
,SequencedCollection<AnnotationInfo>
A list of
AnnotationInfo
objects.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
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
FieldsModifier and TypeFieldDescriptionprivate AnnotationInfoList
The set of annotations directly related to a class or method and not inherited through a meta-annotated annotation.(package private) static final AnnotationInfoList
An unmodifiable emptyAnnotationInfoList
.private static final long
serialVersionUIDFields inherited from class io.github.classgraph.PotentiallyUnmodifiableList
modifiable
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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
Modifier and TypeMethodDescriptionreturns the list of direct annotations, excluding meta-annotations.static AnnotationInfoList
Return an unmodifiable emptyAnnotationInfoList
.boolean
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, Set<ClassInfo> visited) Find the transitive closure of meta-annotations.protected void
findReferencedClassInfo
(Map<String, ClassInfo> classNameToClassInfo, 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).getRepeatable
(Class<? extends Annotation> annotationClass) Get theRepeatable
annotation with the given class, or the empty list if none found.getRepeatable
(String name) Get theRepeatable
annotation with the given name, or the empty list if none found.(package private) void
handleRepeatableAnnotations
(Set<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
addFirst, addLast, clone, contains, ensureCapacity, forEach, get, getFirst, getLast, indexOf, isEmpty, lastIndexOf, listIterator, removeFirst, removeIf, removeLast, removeRange, replaceAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
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 serialVersionUIDserialVersionUID- See Also:
-
EMPTY_LIST
An unmodifiable emptyAnnotationInfoList
.
-
-
Constructor Details
-
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
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 Details
-
emptyList
Return an unmodifiable emptyAnnotationInfoList
.- Returns:
- the unmodifiable empty
AnnotationInfoList
.
-
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(Map<String, ClassInfo> classNameToClassInfo, 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(Set<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, 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
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
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
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
- Specified by:
equals
in interfaceCollection<AnnotationInfo>
- Specified by:
equals
in interfaceList<AnnotationInfo>
- Overrides:
equals
in classInfoList<AnnotationInfo>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<AnnotationInfo>
- Specified by:
hashCode
in interfaceList<AnnotationInfo>
- Overrides:
hashCode
in classInfoList<AnnotationInfo>
-