Package io.github.classgraph
Class ScanResultObject
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- Direct Known Subclasses:
AnnotationClassRef,AnnotationEnumValue,AnnotationInfo,AnnotationParameterValue,ClassInfo,ClassMemberInfo,HierarchicalTypeSignature,ObjectTypedValueWrapper
abstract class ScanResultObject extends java.lang.ObjectA superclass of objects accessible from aScanResultthat are associated with aClassInfoobject.
-
-
Field Summary
Fields Modifier and Type Field Description private ClassInfoclassInfoThe associatedClassInfoobject.protected java.lang.Class<?>classRefThe class ref, once the class is loaded.protected ScanResultscanResultThe scan result.
-
Constructor Summary
Constructors Constructor Description ScanResultObject()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidfindReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)GetClassInfoobjects for any classes referenced by this object.(package private) java.util.Set<ClassInfo>findReferencedClassInfo(LogNode log)GetClassInfoobjects for any classes referenced by this object.(package private) ClassInfogetClassInfo()Get theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e.private java.lang.StringgetClassInfoNameOrClassName()Get the class name by calling getClassInfo().getName(), or as a fallback, by calling getClassName().protected abstract java.lang.StringgetClassName()The name of the class (used bygetClassInfo()to fetch theClassInfoobject for the class).(package private) java.lang.Class<?>loadClass()Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName().(package private) java.lang.Class<?>loadClass(boolean ignoreExceptions)Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName().(package private) <T> java.lang.Class<T>loadClass(java.lang.Class<T> superclassOrInterfaceType)Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName().(package private) <T> java.lang.Class<T>loadClass(java.lang.Class<T> superclassOrInterfaceType, boolean ignoreExceptions)Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName().(package private) voidsetScanResult(ScanResult scanResult)Set ScanResult backreferences in info objects after scan has completed.java.lang.StringtoString()Render to string.(package private) java.lang.StringtoString(boolean useSimpleNames)Render to string, with simple names for classes if useSimpleNames is true.protected abstract voidtoString(boolean useSimpleNames, java.lang.StringBuilder buf)Render to string.java.lang.StringtoStringWithSimpleNames()Render to string, using only simple names for classes.
-
-
-
Field Detail
-
scanResult
protected transient ScanResult scanResult
The scan result.
-
classRef
protected transient java.lang.Class<?> classRef
The class ref, once the class is loaded.
-
-
Method Detail
-
setScanResult
void setScanResult(ScanResult scanResult)
Set ScanResult backreferences in info objects after scan has completed.- Parameters:
scanResult- the scan result
-
findReferencedClassInfo
final java.util.Set<ClassInfo> findReferencedClassInfo(LogNode log)
GetClassInfoobjects for any classes referenced by this object.- Parameters:
log- the log- Returns:
- the referenced class info.
-
findReferencedClassInfo
protected void findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
GetClassInfoobjects for any classes referenced by this object.- Parameters:
classNameToClassInfo- the map from class name toClassInfo.refdClassInfo- the referenced class infolog- the log
-
getClassName
protected abstract java.lang.String getClassName()
The name of the class (used bygetClassInfo()to fetch theClassInfoobject for the class).- Returns:
- The class name.
-
getClassInfo
ClassInfo getClassInfo()
Get theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e. no ClassInfo object was created for the class during scanning). N.B. even if this method returns null,loadClass()may be able to load the referenced class by name.- Returns:
- The
ClassInfoobject for the referenced class.
-
getClassInfoNameOrClassName
private java.lang.String getClassInfoNameOrClassName()
Get the class name by calling getClassInfo().getName(), or as a fallback, by calling getClassName().- Returns:
- the class name
-
loadClass
<T> java.lang.Class<T> loadClass(java.lang.Class<T> superclassOrInterfaceType, boolean ignoreExceptions)Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName(). Returns aClass<?>reference for the class, cast to the requested superclass or interface type.- Type Parameters:
T- the superclass or interface type- Parameters:
superclassOrInterfaceType- The type to cast the resulting class reference to.ignoreExceptions- If true, ignore classloading exceptions and return null on failure.- Returns:
- The
Class<?>reference for the referenced class, or null if the class could not be loaded (or casting failed) and ignoreExceptions is true. - Throws:
java.lang.IllegalArgumentException- if the class could not be loaded or cast, and ignoreExceptions was false.
-
loadClass
<T> java.lang.Class<T> loadClass(java.lang.Class<T> superclassOrInterfaceType)
Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName(). Returns aClass<?>reference for the class, cast to the requested superclass or interface type.- Type Parameters:
T- the superclass or interface type- Parameters:
superclassOrInterfaceType- The type to cast the resulting class reference to.- Returns:
- The
Class<?>reference for the referenced class, or null if the class could not be loaded (or casting failed) and ignoreExceptions is true. - Throws:
java.lang.IllegalArgumentException- if the class could not be loaded or cast, and ignoreExceptions was false.
-
loadClass
java.lang.Class<?> loadClass(boolean ignoreExceptions)
Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName(). Returns aClass<?>reference for the class.- Parameters:
ignoreExceptions- If true, ignore classloading exceptions and return null on failure.- Returns:
- The
Class<?>reference for the referenced class, or null if the class could not be loaded and ignoreExceptions is true. - Throws:
java.lang.IllegalArgumentException- if the class could not be loaded and ignoreExceptions was false.
-
loadClass
java.lang.Class<?> loadClass()
Load the class named returned bygetClassInfo(), or if that returns null, the class named bygetClassName(). Returns aClass<?>reference for the class.- Returns:
- The
Class<?>reference for the referenced class. - Throws:
java.lang.IllegalArgumentException- if the class could not be loaded.
-
toString
protected abstract void toString(boolean useSimpleNames, java.lang.StringBuilder buf)Render to string.- Parameters:
useSimpleNames- if true, use just the simple name of each class.buf- the buf
-
toString
java.lang.String toString(boolean useSimpleNames)
Render to string, with simple names for classes if useSimpleNames is true.- Parameters:
useSimpleNames- if true, use just the simple name of each class.- Returns:
- the string representation.
-
toStringWithSimpleNames
public java.lang.String toStringWithSimpleNames()
Render to string, using only simple names for classes.- Returns:
- the string representation, using simple names for classes.
-
toString
public java.lang.String toString()
Render to string.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation.
-
-