public class ParameterizedType extends Type
name() corresponds to the raw type, and the
arguments() list corresponds to the type arguments passed to the generic type
in order to instantiate this parameterized type.
For example, the following declaration would have a name of java.util.Map and two
ClassType arguments: java.lang.String and java.lang.Integer:
Map<String, 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, the following declaration shows the case where a parameterized type is used
to represent a non-parameterized class X whose owner Y is parameterized:
Y<String>.X
EMPTY_ARRAY| Modifier and Type | Method and Description |
|---|---|
List<Type> |
arguments()
Returns the list of type arguments used to instantiate this parameterized type.
|
static boolean |
arrayEquals(org.jboss.jandex.Interned[] a,
org.jboss.jandex.Interned[] b) |
static int |
arrayHashCode(org.jboss.jandex.Interned[] array) |
ParameterizedType |
asParameterizedType()
Casts this type to a
ParameterizedType and returns it if the kind is
Type.Kind.PARAMETERIZED_TYPE. |
static ParameterizedType |
create(DotName name,
Type[] arguments,
Type owner)
Create a new mock instance.
|
boolean |
equals(Object o)
Compares this
Type with another type. |
int |
hashCode()
Computes a hash code representing this type.
|
boolean |
internEquals(Object o) |
int |
internHashCode() |
Type.Kind |
kind()
Returns the kind of Type this is.
|
Type |
owner()
Returns the owner (enclosing) type of this parameterized type, if the owner is parameterized
or has type annotations.
|
annotation, annotations, annotationsWithRepeatable, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, createWithAnnotations, hasAnnotation, name, toStringpublic static ParameterizedType create(DotName name, Type[] arguments, Type owner)
name - the name of this typearguments - an array of types representing arguments to this typeowner - the enclosing type if annotated or parameterized, otherwise nullpublic List<Type> arguments()
public Type owner()
ClassType. Returns
null 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>.XThis example will return a parameterized type for
Y when X's owner() method
is called.public ParameterizedType asParameterizedType()
TypeParameterizedType and returns it if the kind is
Type.Kind.PARAMETERIZED_TYPE. Throws an exception otherwise.asParameterizedType in class TypeParameterizedTypepublic 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.