Package io.github.classgraph
Class TypeVariableSignature
- java.lang.Object
-
public final class TypeVariableSignature extends ClassRefOrTypeVariableSignature
A type variable signature.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) MethodTypeSignaturecontainingMethodSignatureThe method signature that this type variable is part of.private java.lang.StringdefiningClassNameThe name of the class that this type variable is defined in.private java.lang.StringnameThe type variable name.private TypeParametertypeParameterCachedThe resolved type parameter, if any.-
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 privateTypeVariableSignature(java.lang.String typeVariableName, java.lang.String definingClassName)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 java.lang.StringgetClassName()Return definingClassName, so that getClassInfo() returns theClassInfoobject for the containing class.java.lang.StringgetName()Get the name of the type variable.inthashCode()(package private) static TypeVariableSignatureparse(Parser parser, java.lang.String definingClassName)Parse a TypeVariableSignature.TypeParameterresolve()Look up a type variable (e.g.(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.java.lang.StringtoStringWithTypeBound()Returns the type variable along with its type bound, if available (e.g.-
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, getClassInfo, loadClass, loadClass, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
-
-
-
Field Detail
-
name
private final java.lang.String name
The type variable name.
-
definingClassName
private final java.lang.String definingClassName
The name of the class that this type variable is defined in.
-
containingMethodSignature
MethodTypeSignature containingMethodSignature
The method signature that this type variable is part of.
-
typeParameterCached
private TypeParameter typeParameterCached
The resolved type parameter, if any.
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of the type variable.- Returns:
- The type variable name.
-
resolve
public TypeParameter resolve()
Look up a type variable (e.g. "T") in the defining method and/or enclosing class' type parameters, and return the type parameter with the same name (e.g. "T extends com.xyz.Cls").- Returns:
- the type parameter (e.g. "T extends com.xyz.Cls", or simply "T" if the type parameter does not have any bounds).
- Throws:
java.lang.IllegalArgumentException- if a type parameter with the same name as the type variable could not be found in the defining method or the enclosing 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.
-
parse
static TypeVariableSignature parse(Parser parser, java.lang.String definingClassName) throws ParseException
Parse a TypeVariableSignature.- Parameters:
parser- the parserdefiningClassName- the defining class name- Returns:
- the type variable signature
- Throws:
ParseException- if parsing fails
-
getClassName
protected java.lang.String getClassName()
Return definingClassName, so that getClassInfo() returns theClassInfoobject for the containing class.- Specified by:
getClassNamein classScanResultObject- Returns:
- the defining class name.
-
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.
-
toStringWithTypeBound
public java.lang.String toStringWithTypeBound()
Returns the type variable along with its type bound, if available (e.g. "X extends xyz.Cls"). You can get this in structured form by callingresolve(). Returns just the type variable if there is no type bound, or if no type bound is known (i.e. ifresolve()returns null).- Returns:
- The string representation.
-
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.
-
-