public class ParameterizedType extends Type
name() corresponds to the raw type,
and the arguments list corresponds to a list of type arguments passed to the parameterized type.
Additionally, a parameterized type is used to represent an inner class whose enclosing class
is either parameterized or has type annotations. In this case, the owner() method
will specify the type for the enclosing class. It is also possible for such a type to be parameterized
itself.
For example, the follow declaration would have a name of "java.util.Map", and two
ClassType arguments, the first being "java.lang.String", the second "java.lang.Integer":
java.util.Map<String, Integer>
Another example shows the case where a parameterized type is used to represent a non-parameterized class (Y), whose owner (X) is itself parameterized:
Y<String>.X
| Modifier and Type | Field and Description |
|---|---|
private Type[] |
arguments |
private int |
hash |
private Type |
owner |
EMPTY_ARRAY| Constructor and Description |
|---|
ParameterizedType(DotName name,
Type[] arguments,
Type owner) |
ParameterizedType(DotName name,
Type[] arguments,
Type owner,
AnnotationInstance[] annotations) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<Type> |
arguments()
Returns the list of arguments passed to this Parameterized type.
|
(package private) Type[] |
argumentsArray() |
ParameterizedType |
asParameterizedType()
Casts this type to a
ParameterizedType and returns it if the kind is
Type.Kind.PARAMETERIZED_TYPE
Throws an exception otherwise. |
(package private) ParameterizedType |
copyType(AnnotationInstance[] newAnnotations) |
(package private) ParameterizedType |
copyType(Type owner) |
(package private) ParameterizedType |
copyType(Type[] parameters) |
boolean |
equals(java.lang.Object o)
Compares this Type with another type, and returns true if they are equivalent.
|
int |
hashCode()
Computes a hash code representing this type.
|
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 contains type annotations.
|
java.lang.String |
toString()
Returns a string representation for this type.
|
addAnnotation, annotationArray, annotations, appendAnnotations, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, name, toStringprivate final Type[] arguments
private final Type owner
private int hash
ParameterizedType(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations)
public java.util.List<Type> arguments()
Type[] argumentsArray()
public Type owner()
ClassType. Otherwise null is
returned.
Note that this means that inner classes whose enclosing types are not parameterized or annotated may return null when this method is called.
The example below shows the case where a parameterized type is used to represent a non-parameterized class (Y).
Y<String>.X
This 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 TypeClassTypepublic java.lang.String toString()
TypeParameterizedType copyType(AnnotationInstance[] newAnnotations)
ParameterizedType copyType(Type[] parameters)
ParameterizedType copyType(Type owner)
public boolean equals(java.lang.Object o)
Type