Class ParameterizedType
- All Implemented Interfaces:
Descriptor
name()
denotes the generic class, and
arguments()
is a list of type arguments applied to the generic class in order
to instantiate this parameterized type.
For example, the parameterized type Map<String, Integer>
would have a name of
java.util.Map
and two ClassType
arguments: java.lang.String
and
java.lang.Integer
.
Additionally, a parameterized type is used to represent an inner type whose enclosing type
is either parameterized or has type annotations. In this case, the owner()
method
returns the type of the enclosing class. Such inner type may itself be parameterized.
For example, assume the following declarations:
class A<T> { class B { } } class C { class D { } }Then, the type
A<String>.B
is reprezented as a parameterized type, even though
B
is not parameterized, because the enclosing type is parameterized. The owner
of this type is the parameterized type A<String>
.
Similarly, the type @TypeAnn C.D
is reprezented as a parameterized type, even
though neither C
nor D
are parameterized, because the enclosing type
has a type annotation. The owner of this type is the class type @TypeAnn C
.
- Since:
- 2.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
Fields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION
-
Constructor Summary
ConstructorsConstructorDescriptionParameterizedType
(DotName name, Type[] arguments, Type owner) ParameterizedType
(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations) -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of type arguments used to instantiate this parameterized type.(package private) Type[]
Casts this type to aParameterizedType
and returns it if the kind isType.Kind.PARAMETERIZED_TYPE
.static ParameterizedType.Builder
Create a builder of a parameterized type for the given generic class.static ParameterizedType.Builder
Create a builder of a parameterized type with the givenname
.(package private) ParameterizedType
(package private) ParameterizedType
copyType
(AnnotationInstance[] newAnnotations) (package private) ParameterizedType
(package private) ParameterizedType
static ParameterizedType
Create an instance of a parameterized type with given genericclazz
and given typearguments
.static ParameterizedType
Create an instance of a parameterized type with given genericclazz
and given typearguments
.static ParameterizedType
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.static ParameterizedType
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.static ParameterizedType
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.static ParameterizedType
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.boolean
Compares thisType
with another type.int
hashCode()
Computes a hash code representing this type.(package private) boolean
(package private) int
kind()
Returns the kind of Type this is.owner()
Returns the owner (enclosing) type of this parameterized type, if the owner is parameterized or has type annotations.(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, asPrimitiveType, asTypeVariable, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, create, createWithAnnotations, descriptor, hasAnnotation, name, 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
-
arguments
-
owner
-
hash
private int hash
-
-
Constructor Details
-
ParameterizedType
-
ParameterizedType
ParameterizedType(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations)
-
-
Method Details
-
create
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.The resulting parameterized type has no owner.
- Parameters:
name
- the binary name of the generic classarguments
- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.The resulting parameterized type has no owner.
- Parameters:
name
- the binary name of the generic classarguments
- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with given genericclazz
and given typearguments
.The resulting parameterized type has no owner.
- Parameters:
clazz
- the generic classarguments
- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.An
owner
may be supplied when the new instance is supposed to represent an inner type whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
name
- the binary name of the generic classarguments
- an array of type arguments applied to a generic class to form the parameterized typeowner
- the enclosing type if annotated or parameterized, otherwisenull
- Returns:
- the parameterized type
- Since:
- 2.1
-
create
Create an instance of a parameterized type with givenname
, which denotes a generic class, and given typearguments
.An
owner
may be supplied when the new instance is supposed to represent an inner type whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
name
- the binary name of the generic classarguments
- an array of type arguments applied to a generic class to form the parameterized typeowner
- the enclosing type if annotated or parameterized, otherwisenull
- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with given genericclazz
and given typearguments
.An
owner
may be supplied when the new instance is supposed to represent an inner type whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
clazz
- the generic classarguments
- an array of type arguments applied to a generic class to form the parameterized typeowner
- the enclosing type if annotated or parameterized, otherwisenull
- Returns:
- the parameterized type
- Since:
- 3.1.0
-
builder
Create a builder of a parameterized type with the givenname
.- Parameters:
name
- binary name of the generic class- Returns:
- the builder
- Since:
- 3.1.0
-
builder
Create a builder of a parameterized type for the given generic class.- Parameters:
clazz
- the generic class- Returns:
- the builder
- Since:
- 3.1.0
-
arguments
Returns the list of type arguments used to instantiate this parameterized type.- Returns:
- the list of type arguments, or empty if none
-
argumentsArray
Type[] argumentsArray() -
owner
Returns the owner (enclosing) type of this parameterized type, if the owner is parameterized or has type annotations. In the latter case, the owner may be aClassType
. Returnsnull
otherwise.Note that parameterized inner classes whose enclosing types are not parameterized or type-annotated have no owner and hence this method returns
null
in such case.This example shows the case where a parameterized type is used to represent a non-parameterized class
X
:Y<String>.X
This example will return a parameterized type forY
whenX
'sowner()
method is called.- Returns:
- the owner type if the owner is parameterized or annotated, otherwise null
-
kind
Description copied from class:Type
Returns the kind of Type this is. -
asParameterizedType
Description copied from class:Type
Casts this type to aParameterizedType
and returns it if the kind isType.Kind.PARAMETERIZED_TYPE
. Throws an exception otherwise.- Overrides:
asParameterizedType
in classType
- Returns:
- a
ParameterizedType
-
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
-
copyType
-
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
-