Class ParameterizedType
- java.lang.Object
-
- org.jboss.jandex.Type
-
- org.jboss.jandex.ParameterizedType
-
public class ParameterizedType extends Type
Represents a generic parameterized type. Thename()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
ClassTypearguments, 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
-
-
Constructor Summary
Constructors Constructor Description ParameterizedType(DotName name, Type[] arguments, Type owner)ParameterizedType(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Type>arguments()Returns the list of arguments passed to this Parameterized type.(package private) Type[]argumentsArray()ParameterizedTypeasParameterizedType()Casts this type to aParameterizedTypeand returns it if the kind isType.Kind.PARAMETERIZED_TYPEThrows an exception otherwise.(package private) ParameterizedTypecopyType(AnnotationInstance[] newAnnotations)(package private) ParameterizedTypecopyType(Type owner)(package private) ParameterizedTypecopyType(Type[] parameters)static ParameterizedTypecreate(DotName name, Type[] arguments, Type owner)Create a new mock instance.booleanequals(java.lang.Object o)Compares this Type with another type, and returns true if they are equivalent.inthashCode()Computes a hash code representing this type.Type.Kindkind()Returns the kind of Type this is.Typeowner()Returns the owner (enclosing) type of this parameterized type if the owner is parameterized, or contains type annotations.java.lang.StringtoString()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
-
-
-
-
Method Detail
-
create
public static ParameterizedType create(DotName name, Type[] arguments, Type owner)
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
public java.util.List<Type> 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
public Type 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>.XThis 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
-
asParameterizedType
public ParameterizedType asParameterizedType()
Description copied from class:TypeCasts this type to aParameterizedTypeand returns it if the kind isType.Kind.PARAMETERIZED_TYPEThrows an exception otherwise.- Overrides:
asParameterizedTypein classType- Returns:
- a
ClassType
-
toString
public java.lang.String toString()
Description copied from class:TypeReturns a string representation for this type. It is similar, yet not equivalent to a Java source code representation.
-
copyType
ParameterizedType copyType(AnnotationInstance[] newAnnotations)
-
copyType
ParameterizedType copyType(Type[] parameters)
-
copyType
ParameterizedType copyType(Type owner)
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:TypeCompares 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.
-
-