Package io.github.classgraph
Class ScanResultObject
java.lang.Object
io.github.classgraph.ScanResultObject
- Direct Known Subclasses:
AnnotationClassRef
,AnnotationEnumValue
,AnnotationInfo
,AnnotationParameterValue
,ClassInfo
,ClassMemberInfo
,HierarchicalTypeSignature
,ObjectTypedValueWrapper
A superclass of objects accessible from a
ScanResult
that are associated with a ClassInfo
object.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ClassInfo
The associatedClassInfo
object.protected Class
<?> The class ref, once the class is loaded.protected ScanResult
The scan result. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
findReferencedClassInfo
(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced by this object.GetClassInfo
objects for any classes referenced by this object.(package private) ClassInfo
Get theClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e.private String
Get the class name by calling getClassInfo().getName(), or as a fallback, by calling getClassName().protected abstract String
The name of the class (used bygetClassInfo()
to fetch theClassInfo
object for the class).(package private) Class
<?> Load the class named returned bygetClassInfo()
, or if that returns null, the class named bygetClassName()
.(package private) Class
<?> loadClass
(boolean ignoreExceptions) Load the class named returned bygetClassInfo()
, or if that returns null, the class named bygetClassName()
.(package private) <T> Class
<T> Load the class named returned bygetClassInfo()
, or if that returns null, the class named bygetClassName()
.(package private) <T> Class
<T> Load the class named returned bygetClassInfo()
, or if that returns null, the class named bygetClassName()
.(package private) void
setScanResult
(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.toString()
Render to string.(package private) String
toString
(boolean useSimpleNames) Render to string, with simple names for classes if useSimpleNames is true.protected abstract void
toString
(boolean useSimpleNames, StringBuilder buf) Render to string.Render to string, using only simple names for classes.
-
Field Details
-
scanResult
The scan result. -
classInfo
The associatedClassInfo
object. -
classRef
The class ref, once the class is loaded.
-
-
Constructor Details
-
ScanResultObject
ScanResultObject()
-
-
Method Details
-
setScanResult
Set ScanResult backreferences in info objects after scan has completed.- Parameters:
scanResult
- the scan result
-
findReferencedClassInfo
GetClassInfo
objects for any classes referenced by this object.- Parameters:
log
- the log- Returns:
- the referenced class info.
-
findReferencedClassInfo
protected void findReferencedClassInfo(Map<String, ClassInfo> classNameToClassInfo, Set<ClassInfo> refdClassInfo, LogNode log) GetClassInfo
objects for any classes referenced by this object.- Parameters:
classNameToClassInfo
- the map from class name toClassInfo
.refdClassInfo
- the referenced class infolog
- the log
-
getClassName
The name of the class (used bygetClassInfo()
to fetch theClassInfo
object for the class).- Returns:
- The class name.
-
getClassInfo
ClassInfo getClassInfo()Get theClassInfo
object 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
ClassInfo
object for the referenced class.
-
getClassInfoNameOrClassName
Get the class name by calling getClassInfo().getName(), or as a fallback, by calling getClassName().- Returns:
- the class name
-
loadClass
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:
IllegalArgumentException
- if the class could not be loaded or cast, and ignoreExceptions was false.
-
loadClass
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:
IllegalArgumentException
- if the class could not be loaded or cast, and ignoreExceptions was false.
-
loadClass
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:
IllegalArgumentException
- if the class could not be loaded and ignoreExceptions was false.
-
loadClass
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:
IllegalArgumentException
- if the class could not be loaded.
-
toString
Render to string.- Parameters:
useSimpleNames
- if true, use just the simple name of each class.buf
- the buf
-
toString
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
Render to string, using only simple names for classes.- Returns:
- the string representation, using simple names for classes.
-
toString
Render to string.
-