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 declared 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.
Type variables may have bounds. There are three possibilities:
- no bounds
- one bound, which is a type variable
- multiple bounds, where the first may be a class type, and the rest must be interface types
hasImplicitObjectBound() method may be used to discover
whether the first class bound was declared or not.- Since:
- 2.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Type[]private intprivate static final intprivate final Stringprivate static final intFields inherited from class org.jboss.jandex.Type
EMPTY_ARRAYFields 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 aTypeVariableand returns it if the kind isType.Kind.TYPE_VARIABLE.(package private) Type[]bounds()static TypeVariable.BuilderCreate a builder of a type variable.(package private) TypeVariable(package private) TypecopyType(AnnotationInstance[] newAnnotations) static TypeVariableCreate an instance of a type variable with the givenidentifier.booleanCompares thisTypewith another type.inthashCode()Computes a hash code representing this type.booleanReturns whether this type variable has an implicit (undeclared) bound of typeObject.The identifier of this type variable as it appears in Java source code.(package private) boolean(package private) intkind()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) StringtoString(boolean simple) (package private) TypeReturns 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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:TypeReturns 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,[Iforint[]or[[Ljava.lang.String;forString[][]); - for parameterized types, the binary name of the generic class is returned
(for example,
java.util.ListforList<String>); - for type variables, the name of the first bound of the type variable is returned,
or
java.lang.Objectfor type variables that have no bound; - for wildcard types, the name of the upper bound is returned,
or
java.lang.Objectif the wildcard type does not have an upper bound (for example,java.lang.Numberfor? 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
public boolean hasImplicitObjectBound()Returns whether this type variable has an implicit (undeclared) bound of typeObject. If so, allbounds()are interface types.- Returns:
- whether this type variable has an implicit (undeclared) bound of type
Object
-
kind
Description copied from class:TypeReturns the kind of Type this is. -
asTypeVariable
Description copied from class:TypeCasts this type to aTypeVariableand returns it if the kind isType.Kind.TYPE_VARIABLE. Throws an exception otherwise.- Overrides:
asTypeVariablein classType- Returns:
- a
TypeVariable
-
copyType
-
withoutAnnotations
Type withoutAnnotations()Description copied from class:TypeReturns 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:
withoutAnnotationsin classType- Returns:
- this type without type annotations
-
copyType
-
toString
-
equals
Description copied from class:TypeCompares thisTypewith 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:TypeComputes a hash code representing this type. -
internEquals
- Overrides:
internEqualsin classType
-
internHashCode
int internHashCode()- Overrides:
internHashCodein classType
-