Class TypeVariable

java.lang.Object
org.jboss.jandex.Type
org.jboss.jandex.TypeVariable

public final class TypeVariable extends Type
Represents a resolved type parameter or type argument. The name() of this type variable corresponds to the raw type name. For type variables, the raw type name is the first upper bound. The identifier() specifies the name of the type variable as specified in the source code.

For example, consider the type variable:

T extends Number
The identifier() is "T", while the name() is "java.lang.Number".
Since:
2.0
  • Field Details

    • HASH_MASK

      private static final int HASH_MASK
      See Also:
    • IMPLICIT_MASK

      private static final int IMPLICIT_MASK
      See Also:
    • name

      private final String name
    • bounds

      private final Type[] bounds
    • hash

      private int hash
  • Constructor Details

  • Method Details

    • identifier

      public String identifier()
      The identifier of this type variable as it appears in Java source code.

      The following class has a type parameter, with an identifier of "T":

           class Foo<T extends Number> {}
       
      Returns:
      the identifier of this type variable
    • bounds

      public List<Type> bounds()
    • boundArray

      Type[] boundArray()
    • hasImplicitObjectBound

      boolean hasImplicitObjectBound()
    • kind

      public Type.Kind kind()
      Description copied from class: Type
      Returns the kind of Type this is.
      Specified by:
      kind in class Type
      Returns:
      the kind
    • asTypeVariable

      public TypeVariable asTypeVariable()
      Description copied from class: Type
      Casts this type to a ParameterizedType and returns it if the kind is Type.Kind.TYPE_VARIABLE Throws an exception otherwise.
      Overrides:
      asTypeVariable in class Type
      Returns:
      a ClassType
    • toString

      String toString(boolean simple)
      Overrides:
      toString in class Type
    • equals

      public boolean equals(Object o)
      Description copied from class: Type
      Compares this Type with another type, and returns true if they are equivalent. A type is equivalent to another type if it is the same kind, and all of its fields are equal. This includes annotations, which must be equal as well.
      Overrides:
      equals in class Type
      Parameters:
      o - the type to compare to
      Returns:
      true if equal
      See Also:
    • copyType

      Type copyType(AnnotationInstance[] newAnnotations)
      Specified by:
      copyType in class Type
    • copyType

      TypeVariable copyType(int boundIndex, Type bound)
    • hashCode

      public int hashCode()
      Description copied from class: Type
      Computes a hash code representing this type.
      Overrides:
      hashCode in class Type
      Returns:
      the hash code