Class ParameterizedType
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
- Author:
- Jason T. Greene
- Since:
- 2.0
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of type arguments used to instantiate this parameterized type.Casts this type to aParameterizedTypeand returns it if the kind isType.Kind.PARAMETERIZED_TYPE.static ParameterizedTypeCreate a new mock instance.booleanCompares thisTypewith another type.inthashCode()Computes a hash code representing this type.booleanintkind()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.Methods inherited from class org.jboss.jandex.Type
annotation, annotations, annotationsWithRepeatable, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, createWithAnnotations, hasAnnotation, name, toString
-
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 type arguments used to instantiate this parameterized type.- Returns:
- the list of type arguments, or empty if none
-
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. Returnsnullotherwise.Note that parameterized inner classes whose enclosing types are not parameterized or type-annotated have no owner and hence this method returns
nullin 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 forYwhenX'sowner()method is called.- Returns:
- the owner type if the owner is parameterized or annotated, otherwise null
-
kind
Description copied from class:TypeReturns the kind of Type this is. -
asParameterizedType
Description copied from class:TypeCasts this type to aParameterizedTypeand returns it if the kind isType.Kind.PARAMETERIZED_TYPE. Throws an exception otherwise.- Overrides:
asParameterizedTypein classType- Returns:
- a
ParameterizedType
-
equals
Description copied from class:TypeCompares thisTypewith 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:TypeComputes a hash code representing this type. -
internEquals
- Overrides:
internEqualsin classType
-
internHashCode
public int internHashCode()- Overrides:
internHashCodein classType
-