Package org.jboss.jandex
Class TypeVariable
java.lang.Object
org.jboss.jandex.Type
org.jboss.jandex.TypeVariable
- All Implemented Interfaces:
Descriptor
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()
is the name of the type variable as present in the source code.
For example:
T extends NumberIn this case, the identifier is
T
, while the name is java.lang.Number
.- Since:
- 2.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Type[]
private int
private static final int
private final String
private static final int
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
Fields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION
-
Constructor Summary
ConstructorsConstructorDescriptionTypeVariable
(String name) TypeVariable
(String name, Type[] bounds) TypeVariable
(String name, Type[] bounds, AnnotationInstance[] annotations) TypeVariable
(String name, Type[] bounds, AnnotationInstance[] annotations, boolean implicitObjectBound) -
Method Summary
Modifier and TypeMethodDescriptionCasts this type to aTypeVariable
and returns it if the kind isType.Kind.TYPE_VARIABLE
.(package private) Type[]
bounds()
static TypeVariable.Builder
Create a builder of a type variable.(package private) TypeVariable
(package private) Type
copyType
(AnnotationInstance[] newAnnotations) static TypeVariable
Create an instance of a type variable with the givenidentifier
.boolean
Compares thisType
with another type.int
hashCode()
Computes a hash code representing this type.(package private) boolean
The identifier of this type variable as it appears in Java source code.(package private) boolean
(package private) int
kind()
Returns the kind of Type this is.name()
Returns the name of this type (or its erasure in case of generic types) as aDotName
, using theClass.getName()
format.(package private) String
toString
(boolean simple) (package private) Type
Returns this type with all type annotations removed.Methods inherited from class org.jboss.jandex.Type
addAnnotation, annotation, annotationArray, annotations, annotationsWithRepeatable, appendAnnotations, asArrayType, asClassType, asParameterizedType, asPrimitiveType, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, create, createWithAnnotations, descriptor, hasAnnotation, parse, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jboss.jandex.Descriptor
descriptor
-
Field Details
-
HASH_MASK
private static final int HASH_MASK- See Also:
-
IMPLICIT_MASK
private static final int IMPLICIT_MASK- See Also:
-
identifier
-
bounds
-
hash
private int hash
-
-
Constructor Details
-
TypeVariable
TypeVariable(String name) -
TypeVariable
-
TypeVariable
TypeVariable(String name, Type[] bounds, AnnotationInstance[] annotations) -
TypeVariable
TypeVariable(String name, Type[] bounds, AnnotationInstance[] annotations, boolean implicitObjectBound)
-
-
Method Details
-
create
Create an instance of a type variable with the givenidentifier
. The type variable has a single bound ofjava.lang.Object
.- Parameters:
identifier
- identifier of the type variable- Returns:
- the type variable
- Since:
- 3.1.0
- See Also:
-
builder
Create a builder of a type variable.- Returns:
- the builder
- Since:
- 3.1.0
-
name
Description copied from class:Type
Returns the name of this type (or its erasure in case of generic types) as aDotName
, using theClass.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 orLbinary.name.of.TheClass;
for class types (for example,[I
forint[]
or[[Ljava.lang.String;
forString[][]
); - for parameterized types, the binary name of the generic class is returned
(for example,
java.util.List
forList<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
).
- for primitive types and the void pseudo-type, the corresponding Java keyword
is returned (
-
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
-
boundArray
Type[] boundArray() -
hasImplicitObjectBound
boolean hasImplicitObjectBound() -
kind
Description copied from class:Type
Returns the kind of Type this is. -
asTypeVariable
Description copied from class:Type
Casts this type to aTypeVariable
and returns it if the kind isType.Kind.TYPE_VARIABLE
. Throws an exception otherwise.- Overrides:
asTypeVariable
in classType
- Returns:
- a
TypeVariable
-
copyType
-
withoutAnnotations
Type withoutAnnotations()Description copied from class:Type
Returns this type with all type annotations removed. The annotations are removed deeply, that is also on the constituent type in case of arrays, on type arguments in case of parameterized types, on the bound in case of wildcard types, etc.- Overrides:
withoutAnnotations
in classType
- Returns:
- this type without type annotations
-
copyType
-
toString
-
equals
Description copied from class:Type
Compares thisType
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. -
hashCode
public int hashCode()Description copied from class:Type
Computes a hash code representing this type. -
internEquals
- Overrides:
internEquals
in classType
-
internHashCode
int internHashCode()- Overrides:
internHashCode
in classType
-