Class ClassRefTypeSignature
A class reference type signature (called "ClassTypeSignature" in the classfile documentation).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final StringThe class name.Type suffixes.private List<AnnotationInfoList> The suffix type annotations.private final List<List<TypeArgument>> The suffix type arguments.private final List<TypeArgument> The class type arguments.Fields inherited from class HierarchicalTypeSignature
typeAnnotationInfoFields inherited from class ScanResultObject
classRef, scanResult -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateClassRefTypeSignature(String className, List<TypeArgument> typeArguments, List<String> suffixes, List<List<TypeArgument>> suffixTypeArguments) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddSuffixTypeAnnotation(int suffixIdx, AnnotationInfo annotationInfo) protected voidaddTypeAnnotation(List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo) Add a type annotation to this type.booleanbooleanCompare base types, ignoring generic type parameters.protected voidfindReferencedClassNames(Set<String> refdClassNames) Get the names of any classes referenced in the type signature.Get the name of the class, without any suffixes.Get theClassInfoobject for the referenced class.protected StringThe name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).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.Get all nested suffixes of the class (typically nested inner class names).Get a list of lists of type annotations for all nested suffixes of the class, one list per suffix.Get a list of type arguments for all nested suffixes of the class, one list per suffix.Get any type arguments of the base class.inthashCode()Class<?> Load the referenced class, if not already loaded, returning aClass<?>reference for the referenced class.Class<?> loadClass(boolean ignoreExceptions) Load the referenced class, if not already loaded, returning aClass<?>reference for the referenced class.(package private) static ClassRefTypeSignatureParse a class type signature.(package private) voidsetScanResult(ScanResult scanResult) Set ScanResult backreferences in info objects after scan has completed.private static booleanprotected voidtoStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, StringBuilder buf) Render type signature to string.Methods inherited from class ReferenceTypeSignature
parseClassBound, parseReferenceTypeSignatureMethods inherited from class TypeSignature
findReferencedClassInfo, getTypeAnnotationInfo, parseMethods inherited from class HierarchicalTypeSignature
addTypeAnnotation, toStringMethods inherited from class ScanResultObject
findReferencedClassInfo, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
Field Details
-
className
The class name. -
typeArguments
The class type arguments. -
suffixes
-
suffixTypeArguments
The suffix type arguments. -
suffixTypeAnnotations
The suffix type annotations.
-
-
Constructor Details
-
ClassRefTypeSignature
private ClassRefTypeSignature(String className, List<TypeArgument> typeArguments, List<String> suffixes, List<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 Details
-
getBaseClassName
Get the name of the class, without any suffixes.- Returns:
- The name of the class.
- See Also:
-
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
Get any type arguments of the base class.- Returns:
- The type arguments for the base class.
-
getSuffixes
-
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
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
-
addTypeAnnotation
protected void addTypeAnnotation(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
Load the referenced class, if not already loaded, returning aClass<?>reference for the referenced class. (Called byAnnotationClassRef.loadClass().)- Overrides:
loadClassin 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:
IllegalArgumentException- if the class could not be loaded and ignoreExceptions was false.
-
loadClass
Load the referenced class, if not already loaded, returning aClass<?>reference for the referenced class. (Called byAnnotationClassRef.loadClass().)- Overrides:
loadClassin classScanResultObject- Returns:
- The
Class<?>reference for the referenced class. - Throws:
IllegalArgumentException- if the class could not be loaded.
-
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 fully-qualified class name, for classloading.
-
getClassInfo
Get theClassInfoobject for the referenced class.- Overrides:
getClassInfoin classScanResultObject- Returns:
- The
ClassInfoobject 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
Description copied from class:ScanResultObjectSet ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResultin classHierarchicalTypeSignature- Parameters:
scanResult- the scan result
-
findReferencedClassNames
Get the names of any classes referenced in the type signature.- Overrides:
findReferencedClassNamesin classTypeSignature- Parameters:
refdClassNames- the referenced class names.
-
hashCode
-
suffixesMatch
-
equals
-
equalsIgnoringTypeParams
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, 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.
-
parse
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.
-