Class ParameterizedType
- All Implemented Interfaces:
Descriptor
name() denotes the generic class, and
arguments() is a list of type arguments applied to the generic class 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
Nested Classes -
Field Summary
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAYFields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION -
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 ParameterizedType.BuilderCreate a builder of a parameterized type for the given generic class.static ParameterizedType.BuilderCreate a builder of a parameterized type with the givenname.static ParameterizedTypeCreate an instance of a parameterized type with given genericclazzand given typearguments.static ParameterizedTypeCreate an instance of a parameterized type with given genericclazzand given typearguments.static ParameterizedTypeCreate an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.static ParameterizedTypeCreate an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.static ParameterizedTypeCreate an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.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.kind()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, create, createWithAnnotations, descriptor, hasAnnotation, name, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jboss.jandex.Descriptor
descriptor
-
Method Details
-
create
Create an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.The resulting parameterized type has no owner.
- Parameters:
name- the binary name of the generic classarguments- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with givenname, which denotes a generic class, and given typearguments.The resulting parameterized type has no owner.
- Parameters:
name- the binary name of the generic classarguments- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with given genericclazzand given typearguments.The resulting parameterized type has no owner.
- Parameters:
clazz- the generic classarguments- type arguments applied to the generic class to form the parameterized type- Returns:
- the parameterized type
- Since:
- 3.1.0
-
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 whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
name- the binary name of the generic classarguments- an array of type arguments applied to a generic class to form the parameterized typeowner- the enclosing type if annotated or parameterized, otherwisenull- Returns:
- the parameterized type
- Since:
- 2.1
-
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 whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
name- the binary name of the generic classarguments- an array of type arguments applied to a generic class to form the parameterized typeowner- the enclosing type if annotated or parameterized, otherwisenull- Returns:
- the parameterized type
- Since:
- 3.1.0
-
create
Create an instance of a parameterized type with given genericclazzand given typearguments.An
ownermay be supplied when the new instance is supposed to represent an inner type whose enclosing type is either parameterized or annotated with a type annotation.- Parameters:
clazz- the generic classarguments- an array of type arguments applied to a generic class to form the parameterized typeowner- the enclosing type if annotated or parameterized, otherwisenull- Returns:
- the parameterized type
- Since:
- 3.1.0
-
builder
Create a builder of a parameterized type with the givenname.- Parameters:
name- binary name of the generic class- Returns:
- the builder
- Since:
- 3.1.0
-
builder
Create a builder of a parameterized type for the given generic class.- Parameters:
clazz- the generic class- Returns:
- the builder
- Since:
- 3.1.0
-
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.
-