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
EMPTY_ARRAY
Modifier and Type | Method and Description |
---|---|
List<Type> |
arguments()
Returns the list of arguments passed to this Parameterized type.
|
ParameterizedType |
asParameterizedType()
Casts this type to a
ParameterizedType and returns it if the kind is
Type.Kind.PARAMETERIZED_TYPE
Throws an exception otherwise. |
boolean |
equals(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.
|
String |
toString()
Returns a string representation for this type.
|
annotations, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, name
public List<Type> arguments()
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()
Type
ParameterizedType
and returns it if the kind is
Type.Kind.PARAMETERIZED_TYPE
Throws an exception otherwise.asParameterizedType
in class Type
ClassType
public String toString()
Type
public boolean equals(Object o)
Type
equals
in class Type
o
- the type to compare toObject.equals(Object)
Copyright © 2018 JBoss by Red Hat. All rights reserved.