Top Description Inners Fields Constructors Methods
io.github.classgraph

public Class ClassInfoList

extends MappableInfoList<ClassInfo>
Class Inheritance
Imports
java.io.File, .IOException, .PrintWriter, java.util.ArrayDeque, .ArrayList, .Collection, .Collections, .HashSet, .LinkedHashSet, .List, .Set, io.github.classgraph.ClassInfo.ReachableAndDirectlyRelatedClasses, nonapi.io.github.classgraph.scanspec.ScanSpec, nonapi.io.github.classgraph.utils.CollectionUtils

A uniquified (deduplicated) list of ClassInfo objects, which stores both reachable classes (obtained through a given class relationship, either by direct relationship or through an indirect path), and directly related classes (classes reachable through a direct relationship only). (By default, accessing a ClassInfoList as a List returns only reachable classes; by calling directOnly(), you can get the directly related classes.)

Most ClassInfoList objects returned by ClassGraph are sorted into lexicographical order by the value of ClassInfo#getName(). One exception to this is the classes returned by ClassInfo#getSuperclasses(), which are in ascending order of the class hierarchy.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ClassInfoList.ClassInfoFilter

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

Field Summary

Modifier and TypeField and Description
private final transient Set<ClassInfo>
directlyRelatedClasses

Directly related classes.

pack-priv static final ClassInfoList
EMPTY_LIST

An unmodifiable empty ClassInfoList.

private static final long
private final boolean
sortByName

Whether to sort by name.

Constructor Summary

AccessConstructor and Description
pack-priv
ClassInfoList(final Set<ClassInfo>
reachable classes
reachableClasses
,
final Set<ClassInfo>
directly related classes
directlyRelatedClasses
,
final boolean
whether to sort by name
sortByName
)

Construct a modifiable list of ClassInfo objects, consisting of reachable classes (obtained through the transitive closure) and directly related classes (one step away in the graph).

pack-priv
ClassInfoList(final ClassInfo.ReachableAndDirectlyRelatedClasses
reachable and directly related classes
reachableAndDirectlyRelatedClasses
,
final boolean
whether to sort by name
sortByName
)

Construct a modifiable list of ClassInfo objects.

pack-priv
ClassInfoList(final Set<ClassInfo>
reachable classes
reachableClasses
,
final boolean
whether to sort by name
sortByName
)

Construct a modifiable list of ClassInfo objects, where each class is directly related.

public
ClassInfoList()

Construct a new empty modifiable list of ClassInfo objects.

public
ClassInfoList(final int
the size hint.
sizeHint
)

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

public
ClassInfoList(final Collection<ClassInfo>
the initial collection of ClassInfo objects to add to the ClassInfoList.
classInfoCollection
)

Construct a new modifiable empty ClassInfoList, given an initial list of ClassInfo objects.

Method Summary

Modifier and TypeMethod and Description
public ClassInfoList

Returns:

The list of directly-related classes.
directOnly
()

Get the list of classes that were directly related, as opposed to reachable through multiple steps.

public static ClassInfoList

Returns:

the unmodifiable empty ClassInfoList.
emptyList
()

Return an unmodifiable empty ClassInfoList.

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 ClassInfoList

Returns:

The set difference of this ClassInfoList and other, i.e. (this \ other).
exclude
(final ClassInfoList
The other ClassInfoList to subtract from this one.
other
)

Find the set difference between this ClassInfoList and another ClassInfoList, i.e. (this \ other).

public ClassInfoList

Returns:

The subset of this ClassInfoList for which the given filter predicate is true.
filter
(final ClassInfoList.ClassInfoFilter
The ClassInfoFilter to apply.
filter
)

Find the subset of this ClassInfoList for which the given filter predicate is true.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFile
(final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
,
final boolean
If true, show fields within class nodes in the graph.
showFields
,
final boolean
If true, show edges between classes and the types of their fields.
showFieldTypeDependencyEdges
,
final boolean
If true, show methods within class nodes in the graph.
showMethods
,
final boolean
If true, show edges between classes and the return types and/or parameter types of their methods.
showMethodTypeDependencyEdges
,
final boolean
If true, show annotations in the graph.
showAnnotations
,
final boolean
whether to use simple names for classes in type signatures (if true, the package name is stripped from class names in method and field type signatures).
useSimpleNames
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFile
(final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
,
final boolean
If true, show fields within class nodes in the graph.
showFields
,
final boolean
If true, show edges between classes and the types of their fields.
showFieldTypeDependencyEdges
,
final boolean
If true, show methods within class nodes in the graph.
showMethods
,
final boolean
If true, show edges between classes and the return types and/or parameter types of their methods.
showMethodTypeDependencyEdges
,
final boolean
If true, show annotations in the graph.
showAnnotations
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFile
(final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFile
()

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public void
generateGraphVizDotFile(final File
the file to save the GraphViz .dot file to.
file
)

Generate a and save a .dot file, which can be fed into GraphViz for layout and visualization of the class graph.

public String
public String

Returns:

the GraphViz file contents.
generateGraphVizDotFileFromInterClassDependencies
(final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
,
final boolean
If true, and if ClassGraph#enableExternalClasses() was called before scanning, show "external classes" (non-accepted classes) within the dependency graph.
includeExternalClasses
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFileFromInterClassDependencies
(final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public String

Returns:

the GraphViz file contents.
generateGraphVizDotFileFromInterClassDependencies
()

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

public ClassInfoList

Returns:

The filtered list, containing only annotations.
getAnnotations
()

Filter this ClassInfoList to include only annotations.

public ClassInfoList

Returns:

The filtered list, containing only classes for which assignableToClassRef.isAssignableFrom(listItemClassRef) is true for the corresponding Class<?> references for assignableToClass and the list items. Returns the empty list if no classes were assignable to the requested class.
getAssignableTo
(final ClassInfo
the superclass or interface to filter for.
superclassOrInterface
)

Filter this ClassInfoList to include only classes that are assignable to the requested class, assignableToClass (i.e. where assignableToClass is a superclass or implemented interface of the list element).

public ClassInfoList

Returns:

The filtered list, containing only enums.
getEnums
()

Filter this ClassInfoList to include only Enum classes.

public ClassInfoList

Returns:

The filtered list, containing only implemented interfaces.
getImplementedInterfaces
()

Filter this ClassInfoList to include only implemented interfaces, i.e. non-annotation interfaces, or annotations that have been implemented by a class.

public ClassInfoList

Returns:

The filtered list, containing only interfaces.
getInterfaces
()

Filter this ClassInfoList to include only interfaces that are not annotations.

public ClassInfoList

Returns:

The filtered list, containing only interfaces.
getInterfacesAndAnnotations
()

Filter this ClassInfoList to include only interfaces and annotations (annotations are interfaces, and can be implemented).

public ClassInfoList

Returns:

The filtered list, containing only record classes.
getRecords
()

Filter this ClassInfoList to include only record classes.

public ClassInfoList

Returns:

The filtered list, containing only standard classes.
getStandardClasses
()

Filter this ClassInfoList to include only standard classes (classes that are not interfaces or 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.

public ClassInfoList

Returns:

The intersection of this ClassInfoList with the others.
intersect
(final ClassInfoList...
The other ClassInfoLists to intersect with this one.
others
)

Find the intersection of this ClassInfoList with one or more others.

public <
The superclass or interface.
T
>
List<Class<T>>

Returns:

The loaded Class<?> objects corresponding to each ClassInfo object in this list.
loadClasses
(final Class<T>
The superclass or interface class reference to cast each loaded class to.
superclassOrInterfaceType
,
final boolean
If true, ignore any exceptions or errors thrown during classloading, or when attempting to cast the resulting Class<?> reference to the requested type -- instead, skip the element (i.e. the returned list may contain fewer items than this input list). If false, IllegalArgumentException is thrown if the class could not be loaded or could not be cast to the requested type.
ignoreExceptions
)

Convert this list of ClassInfo objects to a list of Class<?

public <
The superclass or interface.
T
>
List<Class<T>>

Returns:

The loaded Class<?> objects corresponding to each ClassInfo object in this list.
loadClasses
(final Class<T>
The superclass or interface class reference to cast each loaded class to.
superclassOrInterfaceType
)

Convert this list of ClassInfo objects to a list of Class<?

public List<Class<?>>

Returns:

The loaded Class<?> objects corresponding to each ClassInfo object in this list.
loadClasses
(final boolean
If true, ignore any exceptions or errors thrown during classloading. If an exception or error is thrown during classloading, no Class<?> reference is added to the output class for the corresponding ClassInfo object, so the returned list may contain fewer items than this input list. If false, IllegalArgumentException is thrown if the class could not be loaded.
ignoreExceptions
)

Convert this list of ClassInfo objects to a list of Class<?

public List<Class<?>>

Returns:

The loaded Class<?> objects corresponding to each ClassInfo object in this list.
loadClasses
()

Convert this list of ClassInfo objects to a list of Class<?

public ClassInfoList

Returns:

The union of this ClassInfoList with the others.
union
(final ClassInfoList...
The other ClassInfoLists to union with this one.
others
)

Find the union of this ClassInfoList with one or more others.

Inherited from io.github.classgraph.MappableInfoList:
asMapcontainsNameget

Field Detail

directlyRelatedClassesback to summary
private final transient Set<ClassInfo> directlyRelatedClasses

Directly related classes.

EMPTY_LISTback to summary
pack-priv static final ClassInfoList EMPTY_LIST

An unmodifiable empty ClassInfoList.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.github.classgraph.MappableInfoList.serialVersionUID.

serialVersionUID

sortByNameback to summary
private final boolean sortByName

Whether to sort by name.

Constructor Detail

ClassInfoListback to summary
pack-priv ClassInfoList(final Set<ClassInfo> reachableClasses, final Set<ClassInfo> directlyRelatedClasses, final boolean sortByName)

Construct a modifiable list of ClassInfo objects, consisting of reachable classes (obtained through the transitive closure) and directly related classes (one step away in the graph).

Parameters
reachableClasses:Set<ClassInfo>

reachable classes

directlyRelatedClasses:Set<ClassInfo>

directly related classes

sortByName:boolean

whether to sort by name

ClassInfoListback to summary
pack-priv ClassInfoList(final ClassInfo.ReachableAndDirectlyRelatedClasses reachableAndDirectlyRelatedClasses, final boolean sortByName)

Construct a modifiable list of ClassInfo objects.

Parameters
reachableAndDirectlyRelatedClasses:ClassInfo.ReachableAndDirectlyRelatedClasses

reachable and directly related classes

sortByName:boolean

whether to sort by name

ClassInfoListback to summary
pack-priv ClassInfoList(final Set<ClassInfo> reachableClasses, final boolean sortByName)

Construct a modifiable list of ClassInfo objects, where each class is directly related.

Parameters
reachableClasses:Set<ClassInfo>

reachable classes

sortByName:boolean

whether to sort by name

ClassInfoListback to summary
public ClassInfoList()

Construct a new empty modifiable list of ClassInfo objects.

ClassInfoListback to summary
public ClassInfoList(final int sizeHint)

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

Parameters
sizeHint:int

the size hint.

ClassInfoListback to summary
public ClassInfoList(final Collection<ClassInfo> classInfoCollection)

Construct a new modifiable empty ClassInfoList, given an initial list of ClassInfo objects.

If the passed Collection is not a Set, then the ClassInfo objects will be uniquified (by adding them to a set) before they are added to the returned list. ClassInfo objects in the returned list will be sorted by name.

Parameters
classInfoCollection:Collection<ClassInfo>

the initial collection of ClassInfo objects to add to the ClassInfoList.

Method Detail

directOnlyback to summary
public ClassInfoList directOnly()

Get the list of classes that were directly related, as opposed to reachable through multiple steps. For example, if this ClassInfoList was produced by querying for all superclasses of a given class, then directOnly() will return only the direct superclass of this class.

Returns:ClassInfoList

The list of directly-related classes.

emptyListback to summary
public static ClassInfoList emptyList()

Return an unmodifiable empty ClassInfoList.

Returns:ClassInfoList

the unmodifiable empty ClassInfoList.

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
excludeback to summary
public ClassInfoList exclude(final ClassInfoList other)

Find the set difference between this ClassInfoList and another ClassInfoList, i.e. (this \ other).

Parameters
other:ClassInfoList

The other ClassInfoList to subtract from this one.

Returns:ClassInfoList

The set difference of this ClassInfoList and other, i.e. (this \ other).

filterback to summary
public ClassInfoList filter(final ClassInfoList.ClassInfoFilter filter)

Find the subset of this ClassInfoList for which the given filter predicate is true.

Parameters
filter:ClassInfoList.ClassInfoFilter

The ClassInfoFilter to apply.

Returns:ClassInfoList

The subset of this ClassInfoList for which the given filter predicate is true.

generateGraphVizDotFileback to summary
public String generateGraphVizDotFile(final float sizeX, final float sizeY, final boolean showFields, final boolean showFieldTypeDependencyEdges, final boolean showMethods, final boolean showMethodTypeDependencyEdges, final boolean showAnnotations, final boolean useSimpleNames)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file.

To show non-public classes, call ClassGraph#ignoreClassVisibility() before scanning.

To show fields, call ClassGraph#enableFieldInfo() before scanning. To show non-public fields, also call ClassGraph#ignoreFieldVisibility() before scanning.

To show methods, call ClassGraph#enableMethodInfo() before scanning. To show non-public methods, also call ClassGraph#ignoreMethodVisibility() before scanning.

To show annotations, call ClassGraph#enableAnnotationInfo() before scanning. To show non-public annotations, also call ClassGraph#ignoreFieldVisibility() before scanning (there is no separate visibility modifier for annotations).

Parameters
sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

showFields:boolean

If true, show fields within class nodes in the graph.

showFieldTypeDependencyEdges:boolean

If true, show edges between classes and the types of their fields.

showMethods:boolean

If true, show methods within class nodes in the graph.

showMethodTypeDependencyEdges:boolean

If true, show edges between classes and the return types and/or parameter types of their methods.

showAnnotations:boolean

If true, show annotations in the graph.

useSimpleNames:boolean

whether to use simple names for classes in type signatures (if true, the package name is stripped from class names in method and field type signatures).

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableClassInfo() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileback to summary
public String generateGraphVizDotFile(final float sizeX, final float sizeY, final boolean showFields, final boolean showFieldTypeDependencyEdges, final boolean showMethods, final boolean showMethodTypeDependencyEdges, final boolean showAnnotations)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file.

To show non-public classes, call ClassGraph#ignoreClassVisibility() before scanning.

To show fields, call ClassGraph#enableFieldInfo() before scanning. To show non-public fields, also call ClassGraph#ignoreFieldVisibility() before scanning.

To show methods, call ClassGraph#enableMethodInfo() before scanning. To show non-public methods, also call ClassGraph#ignoreMethodVisibility() before scanning.

To show annotations, call ClassGraph#enableAnnotationInfo() before scanning. To show non-public annotations, also call ClassGraph#ignoreFieldVisibility() before scanning (there is no separate visibility modifier for annotations).

This method uses simple names for class names in type signatures of fields and methods (package names are stripped).

Parameters
sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

showFields:boolean

If true, show fields within class nodes in the graph.

showFieldTypeDependencyEdges:boolean

If true, show edges between classes and the types of their fields.

showMethods:boolean

If true, show methods within class nodes in the graph.

showMethodTypeDependencyEdges:boolean

If true, show edges between classes and the return types and/or parameter types of their methods.

showAnnotations:boolean

If true, show annotations in the graph.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableClassInfo() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileback to summary
public String generateGraphVizDotFile(final float sizeX, final float sizeY)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

Methods, fields and annotations are shown if enabled, via ClassGraph#enableMethodInfo(), ClassGraph#enableFieldInfo() and ClassGraph#enableAnnotationInfo().

Only public classes, methods, and fields are shown, unless ClassGraph#ignoreClassVisibility(), ClassGraph#ignoreMethodVisibility(), and/or ClassGraph#ignoreFieldVisibility() has/have been called.

Parameters
sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableClassInfo() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileback to summary
public String generateGraphVizDotFile()

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

Methods, fields and annotations are shown if enabled, via ClassGraph#enableMethodInfo(), ClassGraph#enableFieldInfo() and ClassGraph#enableAnnotationInfo().

Only public classes, methods, and fields are shown, unless ClassGraph#ignoreClassVisibility(), ClassGraph#ignoreMethodVisibility(), and/or ClassGraph#ignoreFieldVisibility() has/have been called.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableClassInfo() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileback to summary
public void generateGraphVizDotFile(final File file) throws IOException

Generate a and save a .dot file, which can be fed into GraphViz for layout and visualization of the class graph.

Methods, fields and annotations are shown if enabled, via ClassGraph#enableMethodInfo(), ClassGraph#enableFieldInfo() and ClassGraph#enableAnnotationInfo().

Only public classes, methods, and fields are shown, unless ClassGraph#ignoreClassVisibility(), ClassGraph#ignoreMethodVisibility(), and/or ClassGraph#ignoreFieldVisibility() has/have been called.

Parameters
file:File

the file to save the GraphViz .dot file to.

Exceptions
IOException:
if the file could not be saved.
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableClassInfo() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileFromClassDependenciesback to summary
public String generateGraphVizDotFileFromClassDependencies()

Deprecated: use generateGraphVizDotFileFromInterClassDependencies() instead.

Returns:String

the GraphViz file contents.

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileFromInterClassDependenciesback to summary
public String generateGraphVizDotFileFromInterClassDependencies(final float sizeX, final float sizeY, final boolean includeExternalClasses)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The returned graph shows inter-class dependencies only. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file. You must have called ClassGraph#enableInterClassDependencies() before scanning to use this method.

Parameters
sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

includeExternalClasses:boolean

If true, and if ClassGraph#enableExternalClasses() was called before scanning, show "external classes" (non-accepted classes) within the dependency graph.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileFromInterClassDependenciesback to summary
public String generateGraphVizDotFileFromInterClassDependencies(final float sizeX, final float sizeY)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The returned graph shows inter-class dependencies only. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file. You must have called ClassGraph#enableInterClassDependencies() before scanning to use this method.

Equivalent to calling generateGraphVizDotFileFromInterClassDependencies(float, float, boolean) with parameters of (10.5f, 8f, scanSpec.enableExternalClasses), where scanSpec.enableExternalClasses is true if ClassGraph#enableExternalClasses() was called before scanning.

Parameters
sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).
generateGraphVizDotFileFromInterClassDependenciesback to summary
public String generateGraphVizDotFileFromInterClassDependencies()

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The returned graph shows inter-class dependencies only. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file. You must have called ClassGraph#enableInterClassDependencies() before scanning to use this method.

Equivalent to calling generateGraphVizDotFileFromInterClassDependencies(float, float, boolean) with parameters of (10.5f, 8f, scanSpec.enableExternalClasses), where scanSpec.enableExternalClasses is true if ClassGraph#enableExternalClasses() was called before scanning.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).
getAnnotationsback to summary
public ClassInfoList getAnnotations()

Filter this ClassInfoList to include only annotations.

Returns:ClassInfoList

The filtered list, containing only annotations.

getAssignableToback to summary
public ClassInfoList getAssignableTo(final ClassInfo superclassOrInterface)

Filter this ClassInfoList to include only classes that are assignable to the requested class, assignableToClass (i.e. where assignableToClass is a superclass or implemented interface of the list element).

Parameters
superclassOrInterface:ClassInfo

the superclass or interface to filter for.

Returns:ClassInfoList

The filtered list, containing only classes for which assignableToClassRef.isAssignableFrom(listItemClassRef) is true for the corresponding Class<?> references for assignableToClass and the list items. Returns the empty list if no classes were assignable to the requested class.

Exceptions
IllegalArgumentException:
if classInfo is null.
getEnumsback to summary
public ClassInfoList getEnums()

Filter this ClassInfoList to include only Enum classes.

Returns:ClassInfoList

The filtered list, containing only enums.

getImplementedInterfacesback to summary
public ClassInfoList getImplementedInterfaces()

Filter this ClassInfoList to include only implemented interfaces, i.e. non-annotation interfaces, or annotations that have been implemented by a class.

Returns:ClassInfoList

The filtered list, containing only implemented interfaces.

getInterfacesback to summary
public ClassInfoList getInterfaces()

Filter this ClassInfoList to include only interfaces that are not annotations. See also getInterfacesAndAnnotations().

Returns:ClassInfoList

The filtered list, containing only interfaces.

getInterfacesAndAnnotationsback to summary
public ClassInfoList getInterfacesAndAnnotations()

Filter this ClassInfoList to include only interfaces and annotations (annotations are interfaces, and can be implemented). See also getInterfaces().

Returns:ClassInfoList

The filtered list, containing only interfaces.

getRecordsback to summary
public ClassInfoList getRecords()

Filter this ClassInfoList to include only record classes.

Returns:ClassInfoList

The filtered list, containing only record classes.

getStandardClassesback to summary
public ClassInfoList getStandardClasses()

Filter this ClassInfoList to include only standard classes (classes that are not interfaces or annotations).

Returns:ClassInfoList

The filtered list, containing only standard classes.

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
intersectback to summary
public ClassInfoList intersect(final ClassInfoList... others)

Find the intersection of this ClassInfoList with one or more others.

Parameters
others:ClassInfoList[]

The other ClassInfoLists to intersect with this one.

Returns:ClassInfoList

The intersection of this ClassInfoList with the others.

loadClassesback to summary
public <T> List<Class<T>> loadClasses(final Class<T> superclassOrInterfaceType, final boolean ignoreExceptions)

Convert this list of ClassInfo objects to a list of Class<?> objects, casting each item in the list to the requested superclass or interface type. Causes the classloader to load the class named by each ClassInfo object, if it is not already loaded.

Important Note

since superclassOrInterfaceType is a class reference for an already-loaded class, it is critical that superclassOrInterfaceType is loaded by the same classloader as the class referred to by this ClassInfo object, otherwise the class cast will fail.

Parameters
<T>
The superclass or interface.
superclassOrInterfaceType:Class<T>

The superclass or interface class reference to cast each loaded class to.

ignoreExceptions:boolean

If true, ignore any exceptions or errors thrown during classloading, or when attempting to cast the resulting Class<?> reference to the requested type -- instead, skip the element (i.e. the returned list may contain fewer items than this input list). If false, IllegalArgumentException is thrown if the class could not be loaded or could not be cast to the requested type.

Returns:List<Class<T>>

The loaded Class<?> objects corresponding to each ClassInfo object in this list.

Exceptions
IllegalArgumentException:
if ignoreExceptions is false and an exception or error was thrown while trying to load or cast any of the classes.
loadClassesback to summary
public <T> List<Class<T>> loadClasses(final Class<T> superclassOrInterfaceType)

Convert this list of ClassInfo objects to a list of Class<?> objects, casting each item in the list to the requested superclass or interface type. Causes the classloader to load the class named by each ClassInfo object, if it is not already loaded.

Important Note

since superclassOrInterfaceType is a class reference for an already-loaded class, it is critical that superclassOrInterfaceType is loaded by the same classloader as the class referred to by this ClassInfo object, otherwise the class cast will fail.

Parameters
<T>
The superclass or interface.
superclassOrInterfaceType:Class<T>

The superclass or interface class reference to cast each loaded class to.

Returns:List<Class<T>>

The loaded Class<?> objects corresponding to each ClassInfo object in this list.

Exceptions
IllegalArgumentException:
if an exception or error was thrown while trying to load or cast any of the classes.
loadClassesback to summary
public List<Class<?>> loadClasses(final boolean ignoreExceptions)

Convert this list of ClassInfo objects to a list of Class<?> objects. Causes the classloader to load the class named by each ClassInfo object, if it is not already loaded.

Parameters
ignoreExceptions:boolean

If true, ignore any exceptions or errors thrown during classloading. If an exception or error is thrown during classloading, no Class<?> reference is added to the output class for the corresponding ClassInfo object, so the returned list may contain fewer items than this input list. If false, IllegalArgumentException is thrown if the class could not be loaded.

Returns:List<Class<?>>

The loaded Class<?> objects corresponding to each ClassInfo object in this list.

Exceptions
IllegalArgumentException:
if ignoreExceptions is false and an exception or error was thrown while trying to load any of the classes.
loadClassesback to summary
public List<Class<?>> loadClasses()

Convert this list of ClassInfo objects to a list of Class<?> objects. Causes the classloader to load the class named by each ClassInfo object, if it is not already loaded.

Returns:List<Class<?>>

The loaded Class<?> objects corresponding to each ClassInfo object in this list.

Exceptions
IllegalArgumentException:
if an exception or error was thrown while trying to load any of the classes.
unionback to summary
public ClassInfoList union(final ClassInfoList... others)

Find the union of this ClassInfoList with one or more others.

Parameters
others:ClassInfoList[]

The other ClassInfoLists to union with this one.

Returns:ClassInfoList

The union of this ClassInfoList with the others.

io.github.classgraph back to summary

public Interface ClassInfoList.ClassInfoFilter

Annotations
@FunctionalInterface

Filter a ClassInfoList using a predicate mapping a ClassInfo object to a boolean, producing another ClassInfoList 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
(ClassInfo
The ClassInfo item to filter.
classInfo
)

Whether or not to allow a ClassInfo list item through the filter.

Method Detail

acceptback to summary
public boolean accept(ClassInfo classInfo)

Whether or not to allow a ClassInfo list item through the filter.

Parameters
classInfo:ClassInfo

The ClassInfo 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.