Package io.github.classgraph
Class ModuleInfo
- java.lang.Object
-
- io.github.classgraph.ModuleInfo
-
- All Implemented Interfaces:
HasName,java.lang.Comparable<ModuleInfo>
public class ModuleInfo extends java.lang.Object implements java.lang.Comparable<ModuleInfo>, HasName
Holds metadata about a package encountered during a scan.
-
-
Field Summary
Fields Modifier and Type Field Description private AnnotationInfoListannotationInfoAnnotationInfoobjects for any annotations on the module-info.class file, if present, else null.private java.util.Set<AnnotationInfo>annotationInfoSetUniqueAnnotationInfoobjects for any annotations on the module-info.class file, if present, else null.private java.util.Set<ClassInfo>classInfoSetSet of classes in the module.private ClasspathElementclasspathElementThe classpath element.private java.net.URIlocationURIThe location of the module as a URI.private ModuleRefmoduleRefTheModuleRef.private java.lang.StringnameThe name of the module.private java.util.Set<PackageInfo>packageInfoSetPackageInfoobjects for packages found within the class, if any, else null.
-
Constructor Summary
Constructors Constructor Description ModuleInfo()Deerialization constructor.ModuleInfo(ModuleRef moduleRef, ClasspathElement classpathElement)Construct a ModuleInfo object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddAnnotations(AnnotationInfoList moduleAnnotations)Add annotations found in a module descriptor classfile.(package private) voidaddClassInfo(ClassInfo classInfo)Add aClassInfoobject to thisModuleInfo.(package private) voidaddPackageInfo(PackageInfo packageInfo)Add aPackageInfoobject to thisModuleInfo.intcompareTo(ModuleInfo other)booleanequals(java.lang.Object obj)AnnotationInfoListgetAnnotationInfo()Get any annotations on thepackage-info.classfile.AnnotationInfogetAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Get a the annotation on this module, or null if the module does not have the annotation.AnnotationInfogetAnnotationInfo(java.lang.String annotationName)Get a the named annotation on this module, or null if the module does not have the named annotation.ClassInfoListgetClassInfo()Get the list ofClassInfoobjects for all classes that are members of this package.ClassInfogetClassInfo(java.lang.String className)Get theClassInfoobject for the named class in this module, or null if the class was not found in this module.java.net.URIgetLocation()The module location, or null for modules whose location is unknown.ModuleRefgetModuleRef()TheModuleReffor this module, or null if this module was obtained from a classpath element on the traditional classpath that contained amodule-info.classfile.java.lang.StringgetName()The module name, or""for the unnamed module.PackageInfoListgetPackageInfo()Get thePackageInfoobjects for all packages that are members of this module.PackageInfogetPackageInfo(java.lang.String packageName)Get thePackageInfoobject for the named package in this module, or null if the package was not found in this module.booleanhasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)Check if this module has the annotation.booleanhasAnnotation(java.lang.String annotationName)Check if this module has the named annotation.inthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
name
private java.lang.String name
The name of the module.
-
classpathElement
private transient ClasspathElement classpathElement
The classpath element.
-
locationURI
private transient java.net.URI locationURI
The location of the module as a URI.
-
annotationInfoSet
private java.util.Set<AnnotationInfo> annotationInfoSet
UniqueAnnotationInfoobjects for any annotations on the module-info.class file, if present, else null.
-
annotationInfo
private AnnotationInfoList annotationInfo
AnnotationInfoobjects for any annotations on the module-info.class file, if present, else null.
-
packageInfoSet
private java.util.Set<PackageInfo> packageInfoSet
PackageInfoobjects for packages found within the class, if any, else null.
-
classInfoSet
private java.util.Set<ClassInfo> classInfoSet
Set of classes in the module.
-
-
Constructor Detail
-
ModuleInfo
ModuleInfo()
Deerialization constructor.
-
ModuleInfo
ModuleInfo(ModuleRef moduleRef, ClasspathElement classpathElement)
Construct a ModuleInfo object.- Parameters:
moduleRef- the module refclasspathElement- the classpath element
-
-
Method Detail
-
getName
public java.lang.String getName()
The module name, or""for the unnamed module.
-
getLocation
public java.net.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()
TheModuleReffor this module, or null if this module was obtained from a classpath element on the traditional classpath that contained amodule-info.classfile.- Returns:
- the
ModuleRef, or null if this module was obtained from a classpath element on the traditional classpath that contained amodule-info.classfile.
-
addClassInfo
void addClassInfo(ClassInfo classInfo)
Add aClassInfoobject to thisModuleInfo.- Parameters:
classInfo- theClassInfoobject to add
-
getClassInfo
public ClassInfo getClassInfo(java.lang.String className)
Get theClassInfoobject 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
ClassInfoobject 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 ofClassInfoobjects for all classes that are members of this package.- Returns:
- the list of
ClassInfoobjects for all classes that are members of this package.
-
addPackageInfo
void addPackageInfo(PackageInfo packageInfo)
Add aPackageInfoobject to thisModuleInfo.- Parameters:
packageInfo- thePackageInfoobject
-
getPackageInfo
public PackageInfo getPackageInfo(java.lang.String packageName)
Get thePackageInfoobject 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
PackageInfoobject for the named package in this module, or null if the package was not found in this module.
-
getPackageInfo
public PackageInfoList getPackageInfo()
Get thePackageInfoobjects for all packages that are members of this module.- Returns:
- the list of
PackageInfoobjects 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(java.lang.Class<? extends java.lang.annotation.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
AnnotationInfoobject representing the annotation on this module, or null if the module does not have the annotation.
-
getAnnotationInfo
public AnnotationInfo getAnnotationInfo(java.lang.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
AnnotationInfoobject 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 thepackage-info.classfile.- Returns:
- the list of
AnnotationInfoobjects for annotations on thepackage-info.classfile.
-
hasAnnotation
public boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.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(java.lang.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:
compareToin interfacejava.lang.Comparable<ModuleInfo>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-