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
-
public class ArrayTypeSignature extends ReferenceTypeSignature
An array type signature.
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayClassInfo
arrayClassInfo
Array class info.private java.lang.String
className
Human-readable class name, e.g.private java.lang.Class<?>
elementClassRef
The element class.private TypeSignature
nestedType
The nested type (anotherArrayTypeSignature
, or the base element type).private java.lang.String
typeSignatureStr
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
Constructors Constructor Description ArrayTypeSignature(TypeSignature elementTypeSignature, int numDims, java.lang.String typeSignatureStr)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)
Add a type annotation to this type.boolean
equals(java.lang.Object obj)
boolean
equalsIgnoringTypeParams(TypeSignature other)
Compare base types, ignoring generic type parameters.protected void
findReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)
Get the names of any classes referenced in the type signature.ArrayClassInfo
getArrayClassInfo()
Return anArrayClassInfo
instance for the array class, cast to its superclass.protected ClassInfo
getClassInfo()
Get theClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected java.lang.String
getClassName()
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).TypeSignature
getElementTypeSignature()
Get the type signature of the innermost element type of the array.TypeSignature
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.int
getNumDimensions()
Get the number of dimensions of the array.AnnotationInfoList
getTypeAnnotationInfo()
Get a list ofAnnotationInfo
objects for the type annotations on this array type, or null if none.java.lang.String
getTypeSignatureStr()
Get the raw array type signature string, e.g.int
hashCode()
java.lang.Class<?>
loadClass()
Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object.java.lang.Class<?>
loadClass(boolean ignoreExceptions)
Obtain aClass<?>
reference for the array class named by thisArrayClassInfo
object.java.lang.Class<?>
loadElementClass()
Get aClass<?>
reference for the array element type.java.lang.Class<?>
loadElementClass(boolean ignoreExceptions)
Get aClass<?>
reference for the innermost array element type.(package private) static ArrayTypeSignature
parse(Parser parser, java.lang.String definingClassName)
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, java.lang.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 Detail
-
typeSignatureStr
private final java.lang.String typeSignatureStr
The raw type signature string for the array type.
-
className
private java.lang.String className
Human-readable class name, e.g. "java.lang.String[]".
-
arrayClassInfo
private ArrayClassInfo arrayClassInfo
Array class info.
-
elementClassRef
private java.lang.Class<?> elementClassRef
The element class.
-
nestedType
private final TypeSignature nestedType
The nested type (anotherArrayTypeSignature
, or the base element type).
-
-
Constructor Detail
-
ArrayTypeSignature
ArrayTypeSignature(TypeSignature elementTypeSignature, int numDims, java.lang.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 Detail
-
getTypeSignatureStr
public java.lang.String getTypeSignatureStr()
Get the raw array type signature string, e.g. "[[I".- Returns:
- the raw array type signature string.
-
getElementTypeSignature
public TypeSignature 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
public TypeSignature 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(java.util.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
public AnnotationInfoList 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:
if you want to read for type annotations on inner (nested) dimensions of the array type.
-
getClassName
protected java.lang.String 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
protected ClassInfo 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
public ArrayClassInfo getArrayClassInfo()
Return anArrayClassInfo
instance for the array class, cast to its superclass.- Returns:
- the
ArrayClassInfo
instance.
-
setScanResult
void setScanResult(ScanResult scanResult)
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
protected void findReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)
Get the names of any classes referenced in the type signature.- Overrides:
findReferencedClassNames
in classTypeSignature
- Parameters:
refdClassNames
- the referenced class names.
-
loadElementClass
public java.lang.Class<?> loadElementClass(boolean ignoreExceptions)
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
public java.lang.Class<?> 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
public java.lang.Class<?> loadClass(boolean ignoreExceptions)
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:
java.lang.IllegalArgumentException
- if ignoreExceptions is false and there were problems loading the class.
-
loadClass
public java.lang.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:
java.lang.IllegalArgumentException
- if there were problems loading the class.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equalsIgnoringTypeParams
public boolean equalsIgnoringTypeParams(TypeSignature other)
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, java.lang.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
static ArrayTypeSignature parse(Parser parser, java.lang.String definingClassName) throws ParseException
Parses the array type signature.- Parameters:
parser
- the parserdefiningClassName
- the defining class name- Returns:
- the array type signature
- Throws:
ParseException
- if parsing fails
-
-