-
-
Notifications
You must be signed in to change notification settings - Fork 298
PackageInfo API
Luke Hutchison edited this page Aug 16, 2021
·
2 revisions
See also the ClassGraph API overview.
Holds information about a package encountered during scanning. Obtained by calling ScanResult#getPackageInfo(packageName)
or ScanResult#getPackageInfo()
.
-
Properties: (N.B. call
.enableClassInfo()
before.scan()
to enablePackageInfo
, and call.ignoreClassVisibility()
if you want to get packages for non-public classes.)-
.getName()
returns the name of the package as aString
(""
for the root package).
-
-
Classes:
-
.getClassInfo()
returns aClassInfoList
ofClassInfo
objects for all classes found in this package. -
.getClassInfoRecursive()
returns aClassInfoList
ofClassInfo
objects for all classes found in this package or its subpackages. -
.getClassInfo(String className)
returns theClassInfo
object for the named class in this package, or null if the class was not found in this package.
-
-
Annotations: (package annotations are annotations on the
package-info.java
package descriptor)-
.getAnnotationInfo()
returns the annotations on this package as anAnnotationInfoList
. -
.hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass)
returnstrue
if the package has the given annotation. -
.getAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass)
returns theAnnotationInfo
object for the given package annotation, or null if none.
-
-
Related packages:
-
.getParent()
returns thePackageInfo
object for the parent package, or null if this is the root package (""
). -
.getChildren()
returns aPackageInfoList
ofPackageInfo
objects for child packages (packages nested within this package), or the empty list if none.
-
Extends ArrayList<PackageInfo>
with the following convenience methods:
-
.asMap()
returns thePackageInfoList
as aMap<String, PackageInfo>
mapping the package name to the correspondingPackageInfo
object. -
.getNames()
returns a list of the names of the packages in this list as aList<String>
. -
.containsName(String packageName)
returnstrue
if a package of the given name is contained in this list. -
.get(String packageName)
returns thePackageInfo
object in this list with the requested name, if present, otherwise returns null. -
.filter(PackageInfoFilter filter)
returns aPackageInfoList
that is a subset of the original list, obtained by applying the given filter predicate to eachPackageInfo
object in the list.-
PackageInfoFilter
is aFunctionalInterface
with the single abstract methodboolean accept(PackageInfo packageInfo)
.
-