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.
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private TypeVariable |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public TypeVariableReference | asTypeVariableReference()
Overrides org. org. and returns it if the kind is
Kind#TYPE_VARIABLE_REFERENCE.
|
| pack-priv Type | |
| public boolean | equals(Object
the type to compare to o)Overrides org. Type with another type.
|
| public TypeVariable | |
| public int | |
| public String | Returns: the identifier of this type variable referenceReturns the identifier of this type variable reference as it appears in Java source code. |
| pack-priv boolean | |
| pack-priv int | |
| public Type. | |
| public DotName | name()
Overrides org. DotName,
using the Class#getName() format.
|
| pack-priv void | |
| pack-priv String |
| name | back to summary |
|---|---|
| private final String name Hides org. | |
| target | back to summary |
|---|---|
| private TypeVariable target | |
| TypeVariableReference | back to summary |
|---|---|
| pack-priv TypeVariableReference(String name) | |
| TypeVariableReference | back to summary |
|---|---|
| pack-priv TypeVariableReference(String name, TypeVariable target, AnnotationInstance[] annotations) | |
| asTypeVariableReference | back to summary |
|---|---|
| public TypeVariableReference asTypeVariableReference() Overrides org. Doc from org. Casts this type to a
| |
| copyType | back to summary |
|---|---|
| pack-priv Type copyType(AnnotationInstance[] newAnnotations) Implements abstract org.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides org. Doc from org. Compares this | |
| follow | back to summary |
|---|---|
| public TypeVariable follow() Returns the type variable referred to by this reference. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Doc from org. Computes a hash code representing this type.
| |
| identifier | back 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
abstract class MyEnum<E extends MyEnum<E>> {
}
The identifier of the reference is E.
| |
| internEquals | back to summary |
|---|---|
| pack-priv boolean internEquals(Object o) Overrides org.
| |
| internHashCode | back to summary |
|---|---|
| pack-priv int internHashCode() Overrides org.
| |
| kind | back to summary |
|---|---|
| public Type. Implements abstract org. Doc from org. Returns the kind of Type this is. | |
| name | back to summary |
|---|---|
| public DotName name() Overrides org. Doc from org. Returns the name of this type (or its erasure in case of generic types) as a
| |
| setTarget | back to summary |
|---|---|
| pack-priv void setTarget(TypeVariable target) | |
| toString | back to summary |
|---|---|
| pack-priv String toString(boolean simple) Overrides org.
| |