-
-
Notifications
You must be signed in to change notification settings - Fork 300
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 aClassInfoListofClassInfoobjects for all classes found in this package. -
.getClassInfoRecursive()returns aClassInfoListofClassInfoobjects for all classes found in this package or its subpackages. -
.getClassInfo(String className)returns theClassInfoobject 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.javapackage descriptor)-
.getAnnotationInfo()returns the annotations on this package as anAnnotationInfoList. -
.hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass)returnstrueif the package has the given annotation. -
.getAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass)returns theAnnotationInfoobject for the given package annotation, or null if none.
-
-
Related packages:
-
.getParent()returns thePackageInfoobject for the parent package, or null if this is the root package (""). -
.getChildren()returns aPackageInfoListofPackageInfoobjects for child packages (packages nested within this package), or the empty list if none.
-
Extends ArrayList<PackageInfo> with the following convenience methods:
-
.asMap()returns thePackageInfoListas aMap<String, PackageInfo>mapping the package name to the correspondingPackageInfoobject. -
.getNames()returns a list of the names of the packages in this list as aList<String>. -
.containsName(String packageName)returnstrueif a package of the given name is contained in this list. -
.get(String packageName)returns thePackageInfoobject in this list with the requested name, if present, otherwise returns null. -
.filter(PackageInfoFilter filter)returns aPackageInfoListthat is a subset of the original list, obtained by applying the given filter predicate to eachPackageInfoobject in the list.-
PackageInfoFilteris aFunctionalInterfacewith the single abstract methodboolean accept(PackageInfo packageInfo).
-