Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Luke Hutchison edited this page Aug 16, 2021 · 2 revisions

See also the ClassGraph API overview.

Contents

PackageInfo

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 enable PackageInfo, and call .ignoreClassVisibility() if you want to get packages for non-public classes.)
    • .getName() returns the name of the package as a String ("" for the root package).
  • Classes:
    • .getClassInfo() returns a ClassInfoList of ClassInfo objects for all classes found in this package.
    • .getClassInfoRecursive() returns a ClassInfoList of ClassInfo objects for all classes found in this package or its subpackages.
    • .getClassInfo(String className) returns the ClassInfo 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 an AnnotationInfoList.
    • .hasAnnotation(String annotationName | Class<? extends Annotation> annotationClass) returns true if the package has the given annotation.
    • .getAnnotationInfo(String annotationName | Class<? extends Annotation> annotationClass) returns the AnnotationInfo object for the given package annotation, or null if none.
  • Related packages:
    • .getParent() returns the PackageInfo object for the parent package, or null if this is the root package ("").
    • .getChildren() returns a PackageInfoList of PackageInfo objects for child packages (packages nested within this package), or the empty list if none.

PackageInfoList

Extends ArrayList<PackageInfo> with the following convenience methods:

  • .asMap() returns the PackageInfoList as a Map<String, PackageInfo> mapping the package name to the corresponding PackageInfo object.
  • .getNames() returns a list of the names of the packages in this list as a List<String>.
  • .containsName(String packageName) returns true if a package of the given name is contained in this list.
  • .get(String packageName) returns the PackageInfo object in this list with the requested name, if present, otherwise returns null.
  • .filter(PackageInfoFilter filter) returns a PackageInfoList that is a subset of the original list, obtained by applying the given filter predicate to each PackageInfo object in the list.
    • PackageInfoFilter is a FunctionalInterface with the single abstract method boolean accept(PackageInfo packageInfo).
Clone this wiki locally
Morty Proxy This is a proxified and sanitized view of the page, visit original site.