Package io.github.classgraph
Class ClassRefTypeSignature
- java.lang.Object
-
public final class ClassRefTypeSignature extends ClassRefOrTypeVariableSignature
A class reference type signature (called "ClassTypeSignature" in the classfile documentation).
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
className
The class name.private java.util.List<java.lang.String>
suffixes
Type suffixes.private java.util.List<AnnotationInfoList>
suffixTypeAnnotations
The suffix type annotations.private java.util.List<java.util.List<TypeArgument>>
suffixTypeArguments
The suffix type arguments.private java.util.List<TypeArgument>
typeArguments
The class type arguments.-
Fields inherited from class io.github.classgraph.HierarchicalTypeSignature
typeAnnotationInfo
-
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ClassRefTypeSignature(java.lang.String className, java.util.List<TypeArgument> typeArguments, java.util.List<java.lang.String> suffixes, java.util.List<java.util.List<TypeArgument>> suffixTypeArguments)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addSuffixTypeAnnotation(int suffixIdx, AnnotationInfo annotationInfo)
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.java.lang.String
getBaseClassName()
Get the name of the class, without any suffixes.ClassInfo
getClassInfo()
Get theClassInfo
object for the referenced class.protected java.lang.String
getClassName()
The name of the class (used byScanResultObject.getClassInfo()
to fetch theClassInfo
object for the class).java.lang.String
getFullyQualifiedClassName()
Get the name of the class, formed from the base name and any suffixes (suffixes are for inner class nesting, and are separated by '$'), but without any type arguments.java.util.List<java.lang.String>
getSuffixes()
Get all nested suffixes of the class (typically nested inner class names).java.util.List<AnnotationInfoList>
getSuffixTypeAnnotationInfo()
Get a list of lists of type annotations for all nested suffixes of the class, one list per suffix.java.util.List<java.util.List<TypeArgument>>
getSuffixTypeArguments()
Get a list of type arguments for all nested suffixes of the class, one list per suffix.java.util.List<TypeArgument>
getTypeArguments()
Get any type arguments of the base class.int
hashCode()
java.lang.Class<?>
loadClass()
Load the referenced class, if not already loaded, returning aClass<?>
reference for the referenced class.java.lang.Class<?>
loadClass(boolean ignoreExceptions)
Load the referenced class, if not already loaded, returning aClass<?>
reference for the referenced class.(package private) static ClassRefTypeSignature
parse(Parser parser, java.lang.String definingClassName)
Parse a class type signature.(package private) void
setScanResult(ScanResult scanResult)
Set ScanResult backreferences in info objects after scan has completed.private static boolean
suffixesMatch(ClassRefTypeSignature a, ClassRefTypeSignature b)
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, getTypeAnnotationInfo, 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
-
className
final java.lang.String className
The class name.
-
typeArguments
private final java.util.List<TypeArgument> typeArguments
The class type arguments.
-
suffixes
private final java.util.List<java.lang.String> suffixes
Type suffixes.
-
suffixTypeArguments
private final java.util.List<java.util.List<TypeArgument>> suffixTypeArguments
The suffix type arguments.
-
suffixTypeAnnotations
private java.util.List<AnnotationInfoList> suffixTypeAnnotations
The suffix type annotations.
-
-
Constructor Detail
-
ClassRefTypeSignature
private ClassRefTypeSignature(java.lang.String className, java.util.List<TypeArgument> typeArguments, java.util.List<java.lang.String> suffixes, java.util.List<java.util.List<TypeArgument>> suffixTypeArguments)
Constructor.- Parameters:
className
- The class name.typeArguments
- The class type arguments.suffixes
- The class suffixes (for inner classes)suffixTypeArguments
- The suffix type arguments.
-
-
Method Detail
-
getBaseClassName
public java.lang.String getBaseClassName()
Get the name of the class, without any suffixes.- Returns:
- The name of the class.
- See Also:
getFullyQualifiedClassName()
-
getFullyQualifiedClassName
public java.lang.String getFullyQualifiedClassName()
Get the name of the class, formed from the base name and any suffixes (suffixes are for inner class nesting, and are separated by '$'), but without any type arguments. For example,"xyz.Cls<String>.InnerCls<Integer>"
is returned as"xyz.Cls$InnerCls"
. The intent of this method is that if you replace '.' with '/', and then add the suffix ".class", you end up with the path of the classfile relative to the package root.For comparison,
ScanResultObject.toString()
uses '.' to separate suffixes, and includes type parameters, whereas this method uses '$' to separate suffixes, and does not include type parameters.- Returns:
- The fully-qualified name of the class, including suffixes but without type arguments.
-
getTypeArguments
public java.util.List<TypeArgument> getTypeArguments()
Get any type arguments of the base class.- Returns:
- The type arguments for the base class.
-
getSuffixes
public java.util.List<java.lang.String> getSuffixes()
Get all nested suffixes of the class (typically nested inner class names).- Returns:
- The class suffixes (for inner classes), or the empty list if none.
-
getSuffixTypeArguments
public java.util.List<java.util.List<TypeArgument>> getSuffixTypeArguments()
Get a list of type arguments for all nested suffixes of the class, one list per suffix.- Returns:
- The list of type arguments for the suffixes (nested inner classes), one list per suffix, or the empty list if none.
-
getSuffixTypeAnnotationInfo
public java.util.List<AnnotationInfoList> getSuffixTypeAnnotationInfo()
Get a list of lists of type annotations for all nested suffixes of the class, one list per suffix.- Returns:
- The list of lists of type annotations for the suffixes (nested inner classes), one list per suffix, or null if none.
-
addSuffixTypeAnnotation
private void addSuffixTypeAnnotation(int suffixIdx, AnnotationInfo annotationInfo)
-
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.
-
loadClass
public java.lang.Class<?> loadClass(boolean ignoreExceptions)
Load the referenced class, if not already loaded, returning aClass<?>
reference for the referenced class. (Called byAnnotationClassRef.loadClass()
.)- Overrides:
loadClass
in classScanResultObject
- Parameters:
ignoreExceptions
- if true, ignore exceptions and instead return null if the class could not be loaded.- Returns:
- The
Class<?>
reference for the referenced class. - Throws:
java.lang.IllegalArgumentException
- if the class could not be loaded and ignoreExceptions was false.
-
loadClass
public java.lang.Class<?> loadClass()
Load the referenced class, if not already loaded, returning aClass<?>
reference for the referenced class. (Called byAnnotationClassRef.loadClass()
.)- Overrides:
loadClass
in classScanResultObject
- Returns:
- The
Class<?>
reference for the referenced class. - Throws:
java.lang.IllegalArgumentException
- if the class could not be loaded.
-
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 fully-qualified class name, for classloading.
-
getClassInfo
public ClassInfo getClassInfo()
Get theClassInfo
object for the referenced class.- Overrides:
getClassInfo
in classScanResultObject
- Returns:
- The
ClassInfo
object for the referenced class, or null if the referenced class was not encountered during scanning (i.e. if 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.
-
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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
suffixesMatch
private static boolean suffixesMatch(ClassRefTypeSignature a, ClassRefTypeSignature b)
-
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 ClassRefTypeSignature parse(Parser parser, java.lang.String definingClassName) throws ParseException
Parse a class type signature.- Parameters:
parser
- The parser.definingClassName
- The name of the defining class (for resolving type variables).- Returns:
- The class type signature.
- Throws:
ParseException
- If the type signature could not be parsed.
-
-