Package io.github.classgraph
Class ArrayTypeSignature
java.lang.Object
io.github.classgraph.ScanResultObject
io.github.classgraph.HierarchicalTypeSignature
io.github.classgraph.TypeSignature
io.github.classgraph.ReferenceTypeSignature
io.github.classgraph.ArrayTypeSignature
An array type signature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArrayClassInfo
Array class info.private String
Human-readable class name, e.g.private Class
<?> The element class.private final TypeSignature
The nested type (anotherArrayTypeSignature
, or the base element type).private final String
The raw type signature string for the array type.Fields inherited from class io.github.classgraph.HierarchicalTypeSignature
typeAnnotationInfo
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
Constructor Summary
ConstructorsConstructorDescriptionArrayTypeSignature
(TypeSignature elementTypeSignature, int numDims, String typeSignatureStr) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addTypeAnnotation
(List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo) Add a type annotation to this type.boolean
boolean
Compare base types, ignoring generic type parameters.protected void
findReferencedClassNames
(Set<String> refdClassNames) Get the names of any classes referenced in the type signature.Return anArrayClassInfo
instance for the array class, cast to its superclass.protected ClassInfo
Get theClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected String
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).Get the type signature of the innermost element type of the array.Get the nested type, which is anotherArrayTypeSignature
with one dimension fewer, if this array has 2 or more dimensions, otherwise this returns the element type.int
Get the number of dimensions of the array.Get a list ofAnnotationInfo
objects for the type annotations on this array type, or null if none.Get the raw array type signature string, e.g.int
hashCode()
Class
<?> Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object.Class
<?> loadClass
(boolean ignoreExceptions) Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object.Class
<?> Get aClass<?>
reference for the array element type.Class
<?> loadElementClass
(boolean ignoreExceptions) Get aClass<?>
reference for the innermost array element type.(package private) static ArrayTypeSignature
Parses the array type signature.(package private) void
setScanResult
(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.protected void
toStringInternal
(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, StringBuilder buf) Render type signature to string.Methods inherited from class io.github.classgraph.ReferenceTypeSignature
parseClassBound, parseReferenceTypeSignature
Methods inherited from class io.github.classgraph.TypeSignature
findReferencedClassInfo, parse
Methods inherited from class io.github.classgraph.HierarchicalTypeSignature
addTypeAnnotation, toString
Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
Field Details
-
typeSignatureStr
The raw type signature string for the array type. -
className
Human-readable class name, e.g. "java.lang.String[]". -
arrayClassInfo
Array class info. -
elementClassRef
The element class. -
nestedType
The nested type (anotherArrayTypeSignature
, or the base element type).
-
-
Constructor Details
-
ArrayTypeSignature
ArrayTypeSignature(TypeSignature elementTypeSignature, int numDims, String typeSignatureStr) Constructor.- Parameters:
elementTypeSignature
- The type signature of the array elements.numDims
- The number of array dimensions.typeSignatureStr
- Raw array type signature string (e.g. "[[I")
-
-
Method Details
-
getTypeSignatureStr
Get the raw array type signature string, e.g. "[[I".- Returns:
- the raw array type signature string.
-
getElementTypeSignature
Get the type signature of the innermost element type of the array.- Returns:
- The type signature of the innermost element type.
-
getNumDimensions
public int getNumDimensions()Get the number of dimensions of the array.- Returns:
- The number of dimensions of the array.
-
getNestedType
Get the nested type, which is anotherArrayTypeSignature
with one dimension fewer, if this array has 2 or more dimensions, otherwise this returns the element type.- Returns:
- The nested type.
-
addTypeAnnotation
protected void addTypeAnnotation(List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo) Description copied from class:TypeSignature
Add a type annotation to this type.- Specified by:
addTypeAnnotation
in classTypeSignature
- Parameters:
typePath
- The type path.annotationInfo
- The annotation to add.
-
getTypeAnnotationInfo
Get a list ofAnnotationInfo
objects for the type annotations on this array type, or null if none.- Overrides:
getTypeAnnotationInfo
in classTypeSignature
- Returns:
- a list of
AnnotationInfo
objects for the type annotations of on this array type, or null if none. - See Also:
-
getClassName
Description copied from class:ScanResultObject
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).- Specified by:
getClassName
in classScanResultObject
- Returns:
- The class name.
-
getClassInfo
Description copied from class:ScanResultObject
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,ScanResultObject.loadClass()
may be able to load the referenced class by name.- Overrides:
getClassInfo
in classScanResultObject
- Returns:
- The
ClassInfo
object for the referenced class.
-
getArrayClassInfo
Return anArrayClassInfo
instance for the array class, cast to its superclass.- Returns:
- the
ArrayClassInfo
instance.
-
setScanResult
Description copied from class:ScanResultObject
Set ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResult
in classHierarchicalTypeSignature
- Parameters:
scanResult
- the scan result
-
findReferencedClassNames
Get the names of any classes referenced in the type signature.- Overrides:
findReferencedClassNames
in classTypeSignature
- Parameters:
refdClassNames
- the referenced class names.
-
loadElementClass
Get aClass<?>
reference for the innermost array element type. Causes the ClassLoader to load the class, if it is not already loaded.- Parameters:
ignoreExceptions
- Whether or not to ignore exceptions.- Returns:
- a
Class<?>
reference for the innermost array element type. Also works for arrays of primitive element type.
-
loadElementClass
Get aClass<?>
reference for the array element type. Causes the ClassLoader to load the element class, if it is not already loaded.- Returns:
- a
Class<?>
reference for the array element type. Also works for arrays of primitive element type.
-
loadClass
Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object. Causes the ClassLoader to load the element class, if it is not already loaded.- Overrides:
loadClass
in classScanResultObject
- Parameters:
ignoreExceptions
- Whether or not to ignore exceptions.- Returns:
- The class reference, or null, if ignoreExceptions is true and there was an exception or error loading the class.
- Throws:
IllegalArgumentException
- if ignoreExceptions is false and there were problems loading the class.
-
loadClass
Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object. Causes the ClassLoader to load the element class, if it is not already loaded.- Overrides:
loadClass
in classScanResultObject
- Returns:
- The class reference.
- Throws:
IllegalArgumentException
- if there were problems loading the class.
-
hashCode
public int hashCode() -
equals
-
equalsIgnoringTypeParams
Description copied from class:TypeSignature
Compare base types, ignoring generic type parameters.- Specified by:
equalsIgnoringTypeParams
in classTypeSignature
- Parameters:
other
- the otherTypeSignature
to compare to.- Returns:
- True if the two
TypeSignature
objects are equal, ignoring type parameters.
-
toStringInternal
protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, StringBuilder buf) Description copied from class:HierarchicalTypeSignature
Render type signature to string.- Specified by:
toStringInternal
in classHierarchicalTypeSignature
- Parameters:
useSimpleNames
- whether to use simple names for classes.annotationsToExclude
- toplevel annotations to exclude, to eliminate duplication (toplevel annotations are both class/field/method annotations and type annotations).buf
- theStringBuilder
to write to.
-
parse
Parses the array type signature.- Parameters:
parser
- the parserdefiningClassName
- the defining class name- Returns:
- the array type signature
- Throws:
ParseException
- if parsing fails
-