Top Description Fields Constructors Methods
org.jboss.jandex

public final Class TypeVariableReference

extends Type
Class Inheritance

Represents a reference to a type variable in the bound of a recursive type parameter. For example, if a class or method declares a type parameter T extends Comparable<T>, then the second occurence of T is represented as a type variable reference and not as a type variable, because it occurs in its own definition. A type variable which is fully defined before its occurence in a recursive type parameter is still represented as a type variable. For example, the recursive type parameter in the following class includes one type variable reference:
abstract class Builder<T, THIS extends Builder<T, THIS>> {
    abstract T build();

    final THIS self() {
        return (THIS) this;
    }
}
The identifier of the reference is THIS. The occurence of type variable T in the recursive type parameter is not represented as a reference, because it does not occur in its own definition. It is fully defined before.

The same holds for mutually recursive type parameters. If a type variable is fully defined before the type parameter in whose bound it occurs, it is represented as a type variable. It is represented as a type variable reference if it is defined after the type parameter in whose bound it occurs.

The type variable reference may be followed to obtain the original type variable.

Note that a type variable and a reference to that type variable may have different type annotations. Type annotations on the reference may be looked up from the reference, but when the reference is followed, the result is the original type variable with its own type annotations.

Field Summary

Modifier and TypeField and Description
private final String
private TypeVariable
Inherited from org.jboss.jandex.Type:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public TypeVariableReference
pack-priv Type
copyType(AnnotationInstance[] newAnnotations)

Implements abstract org.jboss.jandex.Type.copyType.

public boolean
equals(Object
the type to compare to
o
)

Overrides org.jboss.jandex.Type.equals.

Compares this Type with another type.
public TypeVariable
follow()

Returns the type variable referred to by this reference.

public int
hashCode()

Overrides org.jboss.jandex.Type.hashCode.

Computes a hash code representing this type.
public String

Returns:

the identifier of this type variable reference
identifier
()

Returns the identifier of this type variable reference as it appears in Java source code.

pack-priv boolean
pack-priv int
public Type.Kind
kind()

Implements abstract org.jboss.jandex.Type.kind.

Returns the kind of Type this is.
public DotName
name()

Overrides org.jboss.jandex.Type.name.

Returns the name of this type (or its erasure in case of generic types) as a DotName, using the Class#getName() format.
pack-priv void
pack-priv String
toString(boolean simple)

Overrides org.jboss.jandex.Type.toString.

Inherited from org.jboss.jandex.Type:
addAnnotationannotationannotationArrayannotationsannotationsWithRepeatableappendAnnotationsasArrayTypeasClassTypeasParameterizedTypeasPrimitiveTypeasTypeVariableasUnresolvedTypeVariableasVoidTypeasWildcardTypecreatecreateWithAnnotationsdescriptorhasAnnotationtoString

Field Detail

nameback to summary
private final String name

Hides org.jboss.jandex.Type.name.

targetback to summary
private TypeVariable target

Constructor Detail

TypeVariableReferenceback to summary
pack-priv TypeVariableReference(String name)
TypeVariableReferenceback to summary
pack-priv TypeVariableReference(String name, TypeVariable target, AnnotationInstance[] annotations)

Method Detail

asTypeVariableReferenceback to summary
public TypeVariableReference asTypeVariableReference()

Overrides org.jboss.jandex.Type.asTypeVariableReference.

Doc from org.jboss.jandex.Type.asTypeVariableReference.

Casts this type to a org.jboss.jandex.TypeVariableReference and returns it if the kind is Kind#TYPE_VARIABLE_REFERENCE. Throws an exception otherwise.

Returns:TypeVariableReference

a TypeVariableReference

Annotations
@Override
copyTypeback to summary
pack-priv Type copyType(AnnotationInstance[] newAnnotations)

Implements abstract org.jboss.jandex.Type.copyType.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides org.jboss.jandex.Type.equals.

Doc from org.jboss.jandex.Type.equals.

Compares this Type with another type. A type is equal to another type if it is of the same kind, and all of their fields are equal. This includes annotations, which must be equal as well.

Parameters
o:Object

the type to compare to

Returns:boolean

true if equal

Annotations
@Override
followback to summary
public TypeVariable follow()

Returns the type variable referred to by this reference.

hashCodeback to summary
public int hashCode()

Overrides org.jboss.jandex.Type.hashCode.

Doc from org.jboss.jandex.Type.hashCode.

Computes a hash code representing this type.

Returns:int

the hash code

Annotations
@Override
identifierback to summary
public String identifier()

Returns the identifier of this type variable reference as it appears in Java source code.

For example, the following class has a recursive type parameter E with one reference:

abstract class MyEnum<E extends MyEnum<E>> {
}
The identifier of the reference is E.
Returns:String

the identifier of this type variable reference

internEqualsback to summary
pack-priv boolean internEquals(Object o)

Overrides org.jboss.jandex.Type.internEquals.

Annotations
@Override
internHashCodeback to summary
pack-priv int internHashCode()

Overrides org.jboss.jandex.Type.internHashCode.

Annotations
@Override
kindback to summary
public Type.Kind kind()

Implements abstract org.jboss.jandex.Type.kind.

Doc from org.jboss.jandex.Type.kind.

Returns the kind of Type this is.

Returns:Type.Kind

the kind

Annotations
@Override
nameback to summary
public DotName name()

Overrides org.jboss.jandex.Type.name.

Doc from org.jboss.jandex.Type.name.

Returns the name of this type (or its erasure in case of generic types) as a DotName, using the Class#getName() format. Specifically:

  • for primitive types and the void pseudo-type, the corresponding Java keyword is returned (void, boolean, byte, short, int, long, float, double, char);
  • for class types, the binary name of the class is returned;
  • for array types, a string is returned that consists of one or more [ characters corresponding to the number of dimensions of the array type, followed by the element type as a single-character code for primitive types or Lbinary.name.of.TheClass; for class types (for example, [I for int[] or [[Ljava.lang.String; for String[][]);
  • for parameterized types, the binary name of the generic class is returned (for example, java.util.List for List<String>);
  • for type variables, the name of the first bound of the type variable is returned, or java.lang.Object for type variables that have no bound;
  • for wildcard types, the name of the upper bound is returned, or java.lang.Object if the wildcard type does not have an upper bound (for example, java.lang.Number for ? extends Number).
Returns:DotName

the name of this type (or its erasure in case of generic types)

Annotations
@Override
setTargetback to summary
pack-priv void setTarget(TypeVariable target)
toStringback to summary
pack-priv String toString(boolean simple)

Overrides org.jboss.jandex.Type.toString.

Annotations
@Override