Class ClassRefTypeSignature


public final class ClassRefTypeSignature extends ClassRefOrTypeVariableSignature
A class reference type signature (called "ClassTypeSignature" in the classfile documentation).
  • 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

    • getBaseClassName

      public String getBaseClassName()
      Get the name of the class, without any suffixes.
      Returns:
      The name of the class.
      See Also:
    • getFullyQualifiedClassName

      public 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, Object.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 List<TypeArgument> getTypeArguments()
      Get any type arguments of the base class.
      Returns:
      The type arguments for the base class.
    • getSuffixes

      public List<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 List<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 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.
    • 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.
    • loadClass

      public Class<?> loadClass(boolean ignoreExceptions)
      Load the referenced class, if not already loaded, returning a Class<?> reference for the referenced class. (Called by AnnotationClassRef.loadClass().)
      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

      public Class<?> loadClass()
      Load the referenced class, if not already loaded, returning a Class<?> reference for the referenced class. (Called by AnnotationClassRef.loadClass().)
      Returns:
      The Class<?> reference for the referenced class.
      Throws:
      IllegalArgumentException - if the class could not be loaded.
    • getClassName

      protected String getClassName()
      The name of the class (used by ScanResultObject.getClassInfo() to fetch the ClassInfo object for the class).
      Returns:
      the fully-qualified class name, for classloading.
    • getClassInfo

      public ClassInfo getClassInfo()
      Get the ClassInfo object for the referenced class.
      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.
    • 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.
    • 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.