Class ModuleInfo

java.lang.Object
io.github.classgraph.ModuleInfo
All Implemented Interfaces:
HasName, Comparable<ModuleInfo>

public class ModuleInfo extends Object implements Comparable<ModuleInfo>, HasName
Holds metadata about a package encountered during a scan.
  • Field Details

    • name

      private String name
      The name of the module.
    • classpathElement

      private transient ClasspathElement classpathElement
      The classpath element.
    • moduleRef

      private transient ModuleRef moduleRef
    • locationURI

      private transient URI locationURI
      The location of the module as a URI.
    • annotationInfoSet

      private Set<AnnotationInfo> annotationInfoSet
      Unique AnnotationInfo objects for any annotations on the module-info.class file, if present, else null.
    • annotationInfo

      private AnnotationInfoList annotationInfo
      AnnotationInfo objects for any annotations on the module-info.class file, if present, else null.
    • packageInfoSet

      private Set<PackageInfo> packageInfoSet
      PackageInfo objects for packages found within the class, if any, else null.
    • classInfoSet

      private Set<ClassInfo> classInfoSet
      Set of classes in the module.
  • Constructor Details

    • ModuleInfo

      ModuleInfo()
      Deerialization constructor.
    • ModuleInfo

      ModuleInfo(ModuleRef moduleRef, ClasspathElement classpathElement)
      Construct a ModuleInfo object.
      Parameters:
      moduleRef - the module ref
      classpathElement - the classpath element
  • Method Details

    • getName

      public String getName()
      The module name, or "" for the unnamed module.
      Specified by:
      getName in interface HasName
      Returns:
      the module name, or "" for the unnamed module.
    • getLocation

      public URI getLocation()
      The module location, or null for modules whose location is unknown.
      Returns:
      the module location, or null for modules whose location is unknown.
    • getModuleRef

      public ModuleRef getModuleRef()
      The ModuleRef for this module, or null if this module was obtained from a classpath element on the traditional classpath that contained a module-info.class file.
      Returns:
      the ModuleRef, or null if this module was obtained from a classpath element on the traditional classpath that contained a module-info.class file.
    • addClassInfo

      void addClassInfo(ClassInfo classInfo)
      Add a ClassInfo object to this ModuleInfo.
      Parameters:
      classInfo - the ClassInfo object to add
    • getClassInfo

      public ClassInfo getClassInfo(String className)
      Get the ClassInfo object for the named class in this module, or null if the class was not found in this module.
      Parameters:
      className - the class name
      Returns:
      the ClassInfo object for the named class in this module, or null if the class was not found in this module.
    • getClassInfo

      public ClassInfoList getClassInfo()
      Get the list of ClassInfo objects for all classes that are members of this package.
      Returns:
      the list of ClassInfo objects for all classes that are members of this package.
    • addPackageInfo

      void addPackageInfo(PackageInfo packageInfo)
      Add a PackageInfo object to this ModuleInfo.
      Parameters:
      packageInfo - the PackageInfo object
    • getPackageInfo

      public PackageInfo getPackageInfo(String packageName)
      Get the PackageInfo object for the named package in this module, or null if the package was not found in this module.
      Parameters:
      packageName - the package name
      Returns:
      the PackageInfo object for the named package in this module, or null if the package was not found in this module.
    • getPackageInfo

      public PackageInfoList getPackageInfo()
      Get the PackageInfo objects for all packages that are members of this module.
      Returns:
      the list of PackageInfo objects for all packages that are members of this module.
    • addAnnotations

      void addAnnotations(AnnotationInfoList moduleAnnotations)
      Add annotations found in a module descriptor classfile.
      Parameters:
      moduleAnnotations - the module annotations
    • getAnnotationInfo

      public AnnotationInfo getAnnotationInfo(Class<? extends Annotation> annotation)
      Get a the annotation on this module, or null if the module does not have the annotation.
      Parameters:
      annotation - The annotation.
      Returns:
      An AnnotationInfo object representing the annotation on this module, or null if the module does not have the annotation.
    • getAnnotationInfo

      public AnnotationInfo getAnnotationInfo(String annotationName)
      Get a the named annotation on this module, or null if the module does not have the named annotation.
      Parameters:
      annotationName - The annotation name.
      Returns:
      An AnnotationInfo object representing the named annotation on this module, or null if the module does not have the named annotation.
    • getAnnotationInfo

      public AnnotationInfoList getAnnotationInfo()
      Get any annotations on the package-info.class file.
      Returns:
      the list of AnnotationInfo objects for annotations on the package-info.class file.
    • hasAnnotation

      public boolean hasAnnotation(Class<? extends Annotation> annotation)
      Check if this module has the annotation.
      Parameters:
      annotation - The annotation.
      Returns:
      true if this module has the annotation.
    • hasAnnotation

      public boolean hasAnnotation(String annotationName)
      Check if this module has the named annotation.
      Parameters:
      annotationName - The name of an annotation.
      Returns:
      true if this module has the named annotation.
    • compareTo

      public int compareTo(ModuleInfo other)
      Specified by:
      compareTo in interface Comparable<ModuleInfo>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object