Class ParameterizedType
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 (X), whose owner (Y) is itself parameterized:
Y<String>.X
- Since:
- 2.0
-
Nested Class Summary
-
Field Summary
FieldsFields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
-
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 arguments passed to this Parameterized type.(package private) Type[]
Casts this type to aParameterizedType
and returns it if the kind isType.Kind.PARAMETERIZED_TYPE
Throws an exception otherwise.(package private) ParameterizedType
copyType
(AnnotationInstance[] newAnnotations) (package private) ParameterizedType
(package private) ParameterizedType
static ParameterizedType
Create a new mock instance.boolean
Compares this Type with another type, and returns true if they are equivalent.int
hashCode()
Computes a hash code representing this type.kind()
Returns the kind of Type this is.owner()
Returns the owner (enclosing) type of this parameterized type if the owner is parameterized, or contains type annotations.toString()
Returns a string representation for this type.Methods inherited from class org.jboss.jandex.Type
addAnnotation, annotation, annotationArray, annotations, appendAnnotations, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, hasAnnotation, name, toString
-
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 a new mock instance.- Parameters:
name
- the name of this typearguments
- an array of types representing arguments to this typeowner
- the enclosing type if annotated or parameterized, otherwise null- Returns:
- the mock instance
- Since:
- 2.1
-
arguments
Returns the list of arguments passed to 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 contains type annotations. The latter may be aClassType
. 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 (X).
Y<String>.X
This example will return a parameterized type for "Y" when X's
owner()
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
ClassType
-
toString
Description copied from class:Type
Returns a string representation for this type. It is similar, yet not equivalent to a Java source code representation. -
copyType
-
copyType
-
copyType
-
equals
Description copied from class:Type
Compares this Type with another type, and returns true if they are equivalent. A type is equivalent to another type if it is the same kind, and all of its 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.
-