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
- Author:
- Jason T. Greene
-
-
Field Summary
-
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Type>arguments()Returns the list of arguments passed to this Parameterized type.ParameterizedTypeasParameterizedType()Casts this type to aParameterizedTypeand returns it if the kind isType.Kind.PARAMETERIZED_TYPEThrows an exception otherwise.static ParameterizedTypecreate(DotName name, Type[] arguments, Type owner)Create a new mock instance.booleanequals(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.StringtoString()Returns a string representation for this type.-
Methods inherited from class org.jboss.jandex.Type
annotation, annotations, asArrayType, asClassType, asPrimitiveType, asTypeVariable, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, hasAnnotation, name
-
-
-
-
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 List<Type> arguments()
Returns the list of arguments passed to this Parameterized type.- Returns:
- the list of type arguments, or empty if none
-
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 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.
-
equals
public boolean equals(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.- Overrides:
equalsin classType- Parameters:
o- the type to compare to- Returns:
- true if equal
- See Also:
Object.equals(Object)
-
-