Top Description Inners Fields Constructors Methods
io.github.classgraph

public Class AnnotationInfoList

extends MappableInfoList<AnnotationInfo>
Class Inheritance
Imports
java.lang.annotation.Annotation, .Repeatable, java.util.ArrayList, .HashSet, .List, .Map, .Set, io.github.classgraph.ClassInfo.RelType, nonapi.io.github.classgraph.utils.Assert, .CollectionUtils, .LogNode

A list of AnnotationInfo objects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AnnotationInfoList.AnnotationInfoFilter

Filter an AnnotationInfoList using a predicate mapping an AnnotationInfo object to a boolean, producing another AnnotationInfoList for all items in the list for which the predicate is true.

Field Summary

Modifier and TypeField and Description
private AnnotationInfoList
directlyRelatedAnnotations

The set of annotations directly related to a class or method and not inherited through a meta-annotated annotation.

pack-priv static final AnnotationInfoList
EMPTY_LIST

An unmodifiable empty AnnotationInfoList.

private static final long

Constructor Summary

AccessConstructor and Description
public
AnnotationInfoList()

Construct a new modifiable empty list of AnnotationInfo objects.

public
AnnotationInfoList(final int
the size hint
sizeHint
)

Construct a new modifiable empty list of AnnotationInfo objects, given a size hint.

public
AnnotationInfoList(final AnnotationInfoList
the reachable annotations
reachableAnnotations
)

Construct a new modifiable empty AnnotationInfoList, given an initial list of AnnotationInfo objects.

pack-priv
AnnotationInfoList(final AnnotationInfoList
the reachable annotations
reachableAnnotations
,
final AnnotationInfoList
the directly related annotations
directlyRelatedAnnotations
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public AnnotationInfoList

Returns:

The list of directly-related annotations.
directOnly
()

returns the list of direct annotations, excluding meta-annotations.

public static AnnotationInfoList

Returns:

the unmodifiable empty AnnotationInfoList.
emptyList
()

Return an unmodifiable empty AnnotationInfoList.

public boolean
equals(final Object
the object to be compared for equality with this list
obj
)

Overrides io.github.classgraph.InfoList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.

public AnnotationInfoList

Returns:

The subset of the AnnotationInfo objects in this list for which the given filter predicate is true.
filter
(final AnnotationInfoList.AnnotationInfoFilter
The AnnotationInfoFilter to apply.
filter
)

Find the subset of the AnnotationInfo objects in this list for which the given filter predicate is true.

private static void
findMetaAnnotations(final AnnotationInfo
the annotationInfo object
ai
,
final AnnotationInfoList
annotations out
allAnnotationsOut
,
final Set<ClassInfo>
visited
visited
)

Find the transitive closure of meta-annotations.

protected void
findReferencedClassInfo(final Map<String, ClassInfo>
the map from class name to ClassInfo.
classNameToClassInfo
,
final Set<ClassInfo>
the referenced class info
refdClassInfo
,
final LogNode
the log
log
)

Get ClassInfo objects for any classes referenced in this list.

pack-priv static AnnotationInfoList

Returns:

the indirect annotations
getIndirectAnnotations
(final AnnotationInfoList
the direct annotations on the class, method, method parameter or field.
directAnnotationInfo
,
final ClassInfo
for class annotations, this is the annotated class, else null.
annotatedClass
)

Get the indirect annotations on a class (meta-annotations and/or inherited annotations).

public AnnotationInfoList

Returns:

The list of annotations with the given class, or the empty list if none found.
getRepeatable
(final Class<? extends Annotation>
The class to search for.
annotationClass
)

Get the Repeatable annotation with the given class, or the empty list if none found.

public AnnotationInfoList

Returns:

The list of annotations with the given name, or the empty list if none found.
getRepeatable
(final String
The name to search for.
name
)

Get the Repeatable annotation with the given name, or the empty list if none found.

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

Handle Repeatable annotations.

public int
hashCode()

Overrides io.github.classgraph.InfoList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this list.

Inherited from io.github.classgraph.MappableInfoList:
asMapcontainsNameget

Field Detail

directlyRelatedAnnotationsback to summary
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().

EMPTY_LISTback to summary
pack-priv static final AnnotationInfoList EMPTY_LIST

An unmodifiable empty AnnotationInfoList.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.github.classgraph.MappableInfoList.serialVersionUID.

serialVersionUID

Constructor Detail

AnnotationInfoListback to summary
public AnnotationInfoList()

Construct a new modifiable empty list of AnnotationInfo objects.

AnnotationInfoListback to summary
public AnnotationInfoList(final int sizeHint)

Construct a new modifiable empty list of AnnotationInfo objects, given a size hint.

Parameters
sizeHint:int

the size hint

AnnotationInfoListback to summary
public AnnotationInfoList(final AnnotationInfoList reachableAnnotations)

Construct a new modifiable empty AnnotationInfoList, given an initial list of AnnotationInfo objects.

Parameters
reachableAnnotations:AnnotationInfoList

the reachable annotations

AnnotationInfoListback to summary
pack-priv AnnotationInfoList(final AnnotationInfoList reachableAnnotations, final AnnotationInfoList directlyRelatedAnnotations)

Constructor.

Parameters
reachableAnnotations:AnnotationInfoList

the reachable annotations

directlyRelatedAnnotations:AnnotationInfoList

the directly related annotations

Method Detail

directOnlyback to summary
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:AnnotationInfoList

The list of directly-related annotations.

emptyListback to summary
public static AnnotationInfoList emptyList()

Return an unmodifiable empty AnnotationInfoList.

Returns:AnnotationInfoList

the unmodifiable empty AnnotationInfoList.

equalsback to summary
public boolean equals(final Object obj)

Overrides io.github.classgraph.InfoList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.ArrayList.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if Objects.equals(e1, e2).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters
obj:Object

Doc from java.util.List.equals.

the object to be compared for equality with this list

Returns:boolean

Doc from java.util.List.equals.

true if the specified object is equal to this list

Annotations
@Override
filterback to summary
public AnnotationInfoList filter(final AnnotationInfoList.AnnotationInfoFilter filter)

Find the subset of the AnnotationInfo objects in this list for which the given filter predicate is true.

Parameters
filter:AnnotationInfoList.AnnotationInfoFilter

The AnnotationInfoFilter to apply.

Returns:AnnotationInfoList

The subset of the AnnotationInfo objects in this list for which the given filter predicate is true.

findMetaAnnotationsback to summary
private static void findMetaAnnotations(final AnnotationInfo ai, final AnnotationInfoList allAnnotationsOut, final Set<ClassInfo> visited)

Find the transitive closure of meta-annotations.

Parameters
ai:AnnotationInfo

the annotationInfo object

allAnnotationsOut:AnnotationInfoList

annotations out

visited:Set<ClassInfo>

visited

findReferencedClassInfoback to summary
protected void findReferencedClassInfo(final Map<String, ClassInfo> classNameToClassInfo, final Set<ClassInfo> refdClassInfo, final LogNode log)

Get ClassInfo objects for any classes referenced in this list.

Parameters
classNameToClassInfo:Map<String, ClassInfo>

the map from class name to ClassInfo.

refdClassInfo:Set<ClassInfo>

the referenced class info

log:LogNode

the log

getIndirectAnnotationsback to summary
pack-priv static AnnotationInfoList getIndirectAnnotations(final AnnotationInfoList directAnnotationInfo, final ClassInfo annotatedClass)

Get the indirect annotations on a class (meta-annotations and/or inherited annotations).

Parameters
directAnnotationInfo:AnnotationInfoList

the direct annotations on the class, method, method parameter or field.

annotatedClass:ClassInfo

for class annotations, this is the annotated class, else null.

Returns:AnnotationInfoList

the indirect annotations

getRepeatableback to summary
public AnnotationInfoList getRepeatable(final Class<? extends Annotation> annotationClass)

Get the Repeatable annotation with the given class, or the empty list if none found.

Parameters
annotationClass:Class<? extends Annotation>

The class to search for.

Returns:AnnotationInfoList

The list of annotations with the given class, or the empty list if none found.

getRepeatableback to summary
public AnnotationInfoList getRepeatable(final String name)

Get the Repeatable annotation with the given name, or the empty list if none found.

Parameters
name:String

The name to search for.

Returns:AnnotationInfoList

The list of annotations with the given name, or the empty list if none found.

handleRepeatableAnnotationsback to summary
pack-priv void handleRepeatableAnnotations(final Set<String> allRepeatableAnnotationNames, final ClassInfo containingClassInfo, final ClassInfo.RelType forwardRelType, final ClassInfo.RelType reverseRelType0, final ClassInfo.RelType reverseRelType1)

Handle Repeatable annotations.

Parameters
allRepeatableAnnotationNames:Set<String>

the names of all repeatable annotations

containingClassInfo:ClassInfo

the containing class

forwardRelType:ClassInfo.RelType

the forward relationship type for linking (or null for none)

reverseRelType0:ClassInfo.RelType

the first reverse relationship type for linking (or null for none)

reverseRelType1:ClassInfo.RelType

the second reverse relationship type for linking (or null for none)

hashCodeback to summary
public int hashCode()

Overrides io.github.classgraph.InfoList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.ArrayList.hashCode.

Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:

int hashCode = 1;
    for (E e : list)
        hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object#hashCode.
Returns:int

Doc from java.util.List.hashCode.

the hash code value for this list

Annotations
@Override
io.github.classgraph back to summary

public Interface AnnotationInfoList.AnnotationInfoFilter

Annotations
@FunctionalInterface

Filter an AnnotationInfoList using a predicate mapping an AnnotationInfo object to a boolean, producing another AnnotationInfoList for all items in the list for which the predicate is true.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Whether or not to allow the item through the filter. If true, the item is copied to the output list; if false, it is excluded.
accept
(AnnotationInfo
The AnnotationInfo item to filter.
annotationInfo
)

Whether or not to allow an AnnotationInfo list item through the filter.

Method Detail

acceptback to summary
public boolean accept(AnnotationInfo annotationInfo)

Whether or not to allow an AnnotationInfo list item through the filter.

Parameters
annotationInfo:AnnotationInfo

The AnnotationInfo item to filter.

Returns:boolean

Whether or not to allow the item through the filter. If true, the item is copied to the output list; if false, it is excluded.