Package io.github.classgraph
Class BaseTypeSignature
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- io.github.classgraph.HierarchicalTypeSignature
-
- io.github.classgraph.TypeSignature
-
- io.github.classgraph.BaseTypeSignature
-
public class BaseTypeSignature extends TypeSignature
A type signature for a base type (byte, char, double, float, int, long, short, boolean, or void).
-
-
Field Summary
Fields Modifier and Type Field Description private chartypeSignatureCharThe type signature character used to represent the base 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 BaseTypeSignature(char typeSignatureChar)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)Add a type annotation to this type.booleanequals(java.lang.Object obj)booleanequalsIgnoringTypeParams(TypeSignature other)Compare base types, ignoring generic type parameters.protected voidfindReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)Get the names of any classes referenced in the type signature.protected ClassInfogetClassInfo()Get theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected java.lang.StringgetClassName()The name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).java.lang.Class<?>getType()Get the type.(package private) static java.lang.Class<?>getType(char typeChar)Get the type for a type character.(package private) static chargetTypeChar(java.lang.String typeStr)Get the name of the type as a string.chargetTypeSignatureChar()Get the type signature char used to represent the type, e.g.java.lang.StringgetTypeStr()Get the name of the type as a string.(package private) static java.lang.StringgetTypeStr(char typeChar)Get the name of the type as a string.inthashCode()(package private) java.lang.Class<?>loadClass()Load the class named returned byScanResultObject.getClassInfo(), or if that returns null, the class named byScanResultObject.getClassName().(package private) <T> java.lang.Class<T>loadClass(java.lang.Class<T> superclassOrInterfaceType)Load the class named returned byScanResultObject.getClassInfo(), or if that returns null, the class named byScanResultObject.getClassName().(package private) static BaseTypeSignatureparse(Parser parser)Parse a base type.(package private) voidsetScanResult(ScanResult scanResult)Set ScanResult backreferences in info objects after scan has completed.protected voidtoStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Render type signature to string.-
Methods inherited from class io.github.classgraph.TypeSignature
findReferencedClassInfo, getTypeAnnotationInfo, parse, 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
-
-
-
-
Method Detail
-
getTypeStr
static java.lang.String getTypeStr(char typeChar)
Get the name of the type as a string.- Parameters:
typeChar- the type character, e.g. 'I'.- Returns:
- The name of the type, e.g. "int", or null if there was no match.
-
getTypeChar
static char getTypeChar(java.lang.String typeStr)
Get the name of the type as a string.- Parameters:
typeStr- the type character, e.g. "int".- Returns:
- The type, character, e.g. 'I', or '\0' if there was no match.
-
getType
static java.lang.Class<?> getType(char typeChar)
Get the type for a type character.- Parameters:
typeChar- the type character, e.g. 'I'.- Returns:
- The type class, e.g. int.class, or null if there was no match.
-
getTypeSignatureChar
public char getTypeSignatureChar()
Get the type signature char used to represent the type, e.g. 'I' for int.- Returns:
- the type signature char, as a one-char String.
-
getTypeStr
public java.lang.String getTypeStr()
Get the name of the type as a string.- Returns:
- The name of the type, such as "int", "float", or "void".
-
getType
public java.lang.Class<?> getType()
Get the type.- Returns:
- The class of the base type, such as int.class, float.class, or void.class.
-
addTypeAnnotation
protected void addTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)
Description copied from class:TypeSignatureAdd a type annotation to this type.- Specified by:
addTypeAnnotationin classTypeSignature- Parameters:
typePath- The type path.annotationInfo- The annotation to add.
-
loadClass
java.lang.Class<?> loadClass()
Description copied from class:ScanResultObjectLoad the class named returned byScanResultObject.getClassInfo(), or if that returns null, the class named byScanResultObject.getClassName(). Returns aClass<?>reference for the class.- Overrides:
loadClassin classScanResultObject- Returns:
- The
Class<?>reference for the referenced class.
-
loadClass
<T> java.lang.Class<T> loadClass(java.lang.Class<T> superclassOrInterfaceType)
Description copied from class:ScanResultObjectLoad the class named returned byScanResultObject.getClassInfo(), or if that returns null, the class named byScanResultObject.getClassName(). Returns aClass<?>reference for the class, cast to the requested superclass or interface type.- Overrides:
loadClassin classScanResultObject- 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.
-
parse
static BaseTypeSignature parse(Parser parser)
Parse a base type.- Parameters:
parser- the parser- Returns:
- the base type signature
-
getClassName
protected java.lang.String getClassName()
Description copied from class:ScanResultObjectThe name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).- Specified by:
getClassNamein classScanResultObject- Returns:
- The class name.
-
getClassInfo
protected ClassInfo getClassInfo()
Description copied from class:ScanResultObjectGet 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,ScanResultObject.loadClass()may be able to load the referenced class by name.- Overrides:
getClassInfoin classScanResultObject- Returns:
- The
ClassInfoobject for the referenced class.
-
findReferencedClassNames
protected void findReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)
Get the names of any classes referenced in the type signature.- Overrides:
findReferencedClassNamesin classTypeSignature- Parameters:
refdClassNames- the referenced class names.
-
setScanResult
void setScanResult(ScanResult scanResult)
Description copied from class:ScanResultObjectSet ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResultin classHierarchicalTypeSignature- Parameters:
scanResult- the scan result
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
equalsIgnoringTypeParams
public boolean equalsIgnoringTypeParams(TypeSignature other)
Description copied from class:TypeSignatureCompare base types, ignoring generic type parameters.- Specified by:
equalsIgnoringTypeParamsin classTypeSignature- Parameters:
other- the otherTypeSignatureto compare to.- Returns:
- True if the two
TypeSignatureobjects are equal, ignoring type parameters.
-
toStringInternal
protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Description copied from class:HierarchicalTypeSignatureRender type signature to string.- Specified by:
toStringInternalin 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- theStringBuilderto write to.
-
-