Class TypeVariableSignature


public final class TypeVariableSignature extends ClassRefOrTypeVariableSignature
A type variable signature.
  • Field Details

    • scanResult

      protected transient ScanResult scanResult
      The scan result.
    • classRef

      protected transient Class<?> classRef
      The class ref, once the class is loaded.
  • Method Details

    • getName

      public 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:
      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(List<io.github.classgraph.Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)
      Description copied from class: TypeSignature
      Add a type annotation to this type.
      Specified by:
      addTypeAnnotation in class TypeSignature
      Parameters:
      typePath - The type path.
      annotationInfo - The annotation to add.
    • getClassName

      protected String getClassName()
      Return definingClassName, so that getClassInfo() returns the ClassInfo object for the containing class.
      Returns:
      the defining class name.
    • findReferencedClassNames

      protected void findReferencedClassNames(Set<String> refdClassNames)
      Get the names of any classes referenced in the type signature.
      Overrides:
      findReferencedClassNames in class TypeSignature
      Parameters:
      refdClassNames - the referenced class names.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equalsIgnoringTypeParams

      public boolean equalsIgnoringTypeParams(TypeSignature other)
      Description copied from class: TypeSignature
      Compare base types, ignoring generic type parameters.
      Specified by:
      equalsIgnoringTypeParams in class TypeSignature
      Parameters:
      other - the other TypeSignature to compare to.
      Returns:
      True if the two TypeSignature objects are equal, ignoring type parameters.
    • toStringWithTypeBound

      public 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 calling resolve(). Returns just the type variable if there is no type bound, or if no type bound is known (i.e. if resolve() returns null).
      Returns:
      The string representation.
    • toStringInternal

      protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, StringBuilder buf)
      Description copied from class: HierarchicalTypeSignature
      Render type signature to string.
      Specified by:
      toStringInternal in class HierarchicalTypeSignature
      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 - the StringBuilder to write to.
    • toStringWithSimpleNames

      public String toStringWithSimpleNames()
      Render to string, using only simple names for classes.
      Returns:
      the string representation, using simple names for classes.
    • toString

      public String toString()
      Render to string.
      Overrides:
      toString in class Object
      Returns:
      the string representation.