public final class TypeVariableReference extends Type
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.
EMPTY_ARRAY| Modifier and Type | Method and Description |
|---|---|
static boolean |
arrayEquals(org.jboss.jandex.Interned[] a,
org.jboss.jandex.Interned[] b) |
static int |
arrayHashCode(org.jboss.jandex.Interned[] array) |
TypeVariableReference |
asTypeVariableReference()
Casts this type to a
TypeVariableReference and returns it if the kind is
Type.Kind.TYPE_VARIABLE_REFERENCE. |
boolean |
equals(Object o)
Compares this
Type with another type. |
TypeVariable |
follow()
Returns the type variable referred to by this reference.
|
int |
hashCode()
Computes a hash code representing this type.
|
String |
identifier()
Returns the identifier of this type variable reference as it appears in Java source code.
|
boolean |
internEquals(Object o) |
int |
internHashCode() |
Type.Kind |
kind()
Returns the kind of Type this is.
|
DotName |
name()
Returns the raw name of this type.
|
annotation, annotations, annotationsWithRepeatable, asArrayType, asClassType, asParameterizedType, asPrimitiveType, asTypeVariable, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, createWithAnnotations, hasAnnotation, toStringpublic DotName name()
Type[[[Ljava.lang.String;) Classes are returned as a normal DotName.
Generic values are returned as the underlying raw value. For example,
a wildcard such as ? extends Number has a raw type of
Number.
public String identifier()
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.public TypeVariable follow()
public TypeVariableReference asTypeVariableReference()
TypeTypeVariableReference and returns it if the kind is
Type.Kind.TYPE_VARIABLE_REFERENCE. Throws an exception otherwise.asTypeVariableReference in class TypeTypeVariableReferencepublic boolean equals(Object o)
TypeType 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.equals in class Typeo - the type to compare toObject.equals(Object)public int hashCode()
Typepublic boolean internEquals(Object o)
internEquals in class Typepublic int internHashCode()
internHashCode in class Typepublic static boolean arrayEquals(org.jboss.jandex.Interned[] a,
org.jboss.jandex.Interned[] b)
public static int arrayHashCode(org.jboss.jandex.Interned[] array)
Copyright © 2018–2022. All rights reserved.