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 parameterized type Map<String, Integer> would have a name of
java.util.Map and two ClassType arguments: java.lang.String and
java.lang.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, assume the following declarations:
class A<T> {
class B {
}
}
class C {
class D {
}
}
Then, the type A<String>.B is reprezented as a parameterized type, even though
B is not parameterized, because the enclosing type is parameterized. The owner
of this type is the parameterized type A<String>.
Similarly, the type @TypeAnn C.D is reprezented as a parameterized type, even
though neither C nor D are parameterized, because the enclosing type
has a type annotation. The owner of this type is the class type @TypeAnn C.
- 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 an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.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 an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.An
ownermay be supplied when the new instance is supposed to represent an inner type, in case the enclosing type is either parameterized or annotated with a type annotation.- Parameters:
name- the name of this parameterized typearguments- an array of type arguments applied to a generic class to form this typeowner- the enclosing type if annotated or parameterized, otherwisenull- Returns:
- the parameterized type
- 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
-