Top Description Inners Fields Constructors Methods
org.jboss.jandex

public Class ParameterizedType

extends Type
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .List, .Objects

Represents a parameterized type. The 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 and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final Type[]
private int
private final Type
Inherited from org.jboss.jandex.Type:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
pack-priv
ParameterizedType(DotName name, Type[] arguments, Type owner)

pack-priv
ParameterizedType(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations)

Method Summary

Modifier and TypeMethod and Description
public List<Type>

Returns:

the list of type arguments, or empty if none
arguments
()

Returns the list of type arguments used to instantiate this parameterized type.

pack-priv Type[]
public ParameterizedType
public static ParameterizedType.Builder

Returns:

the builder
builder
(DotName
binary name of the generic class
name
)

Create a builder of a parameterized type with the given name.

public static ParameterizedType.Builder

Returns:

the builder
builder
(Class<?>
the generic class
clazz
)

Create a builder of a parameterized type for the given generic class.

pack-priv ParameterizedType
copyType(AnnotationInstance[] newAnnotations)

Implements abstract org.jboss.jandex.Type.copyType.

pack-priv ParameterizedType
copyType(Type[] arguments)

pack-priv ParameterizedType
copyType(int argumentIndex, Type argument)

pack-priv ParameterizedType
copyType(Type owner)

public static ParameterizedType

Returns:

the parameterized type
create
(DotName
the binary name of the generic class
name
,
Type...
type arguments applied to the generic class to form the parameterized type
arguments
)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

public static ParameterizedType

Returns:

the parameterized type
create
(String
the binary name of the generic class
name
,
Type...
type arguments applied to the generic class to form the parameterized type
arguments
)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

public static ParameterizedType

Returns:

the parameterized type
create
(Class<?>
the generic class
clazz
,
Type...
type arguments applied to the generic class to form the parameterized type
arguments
)

Create an instance of a parameterized type with given generic clazz and given type arguments.

public static ParameterizedType

Returns:

the parameterized type
create
(DotName
the binary name of the generic class
name
,
Type[]
an array of type arguments applied to a generic class to form the parameterized type
arguments
,
Type
the enclosing type if annotated or parameterized, otherwise null
owner
)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

public static ParameterizedType

Returns:

the parameterized type
create
(String
the binary name of the generic class
name
,
Type[]
an array of type arguments applied to a generic class to form the parameterized type
arguments
,
Type
the enclosing type if annotated or parameterized, otherwise null
owner
)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

public static ParameterizedType

Returns:

the parameterized type
create
(Class<?>
the generic class
clazz
,
Type[]
an array of type arguments applied to a generic class to form the parameterized type
arguments
,
Type
the enclosing type if annotated or parameterized, otherwise null
owner
)

Create an instance of a parameterized type with given generic clazz and given type arguments.

public boolean
equals(Object
the type to compare to
o
)

Overrides org.jboss.jandex.Type.equals.

Compares this Type with another type.
public int
hashCode()

Overrides org.jboss.jandex.Type.hashCode.

Computes a hash code representing this type.
pack-priv boolean
pack-priv int
public Type.Kind
kind()

Implements abstract org.jboss.jandex.Type.kind.

Returns the kind of Type this is.
public Type

Returns:

the owner type if the owner is parameterized or annotated, otherwise null
owner
()

Returns the owner (enclosing) type of this parameterized type, if the owner is parameterized or has type annotations.

pack-priv String
toString(boolean simple)

Overrides org.jboss.jandex.Type.toString.

Inherited from org.jboss.jandex.Type:
addAnnotationannotationannotationArrayannotationsannotationsWithRepeatableappendAnnotationsasArrayTypeasClassTypeasPrimitiveTypeasTypeVariableasTypeVariableReferenceasUnresolvedTypeVariableasVoidTypeasWildcardTypecreatecreateWithAnnotationsdescriptorhasAnnotationnametoString

Field Detail

argumentsback to summary
private final Type[] arguments
hashback to summary
private int hash
ownerback to summary
private final Type owner

Constructor Detail

ParameterizedTypeback to summary
pack-priv ParameterizedType(DotName name, Type[] arguments, Type owner)
ParameterizedTypeback to summary
pack-priv ParameterizedType(DotName name, Type[] arguments, Type owner, AnnotationInstance[] annotations)

Method Detail

argumentsback to summary
public List<Type> arguments()

Returns the list of type arguments used to instantiate this parameterized type.

Returns:List<Type>

the list of type arguments, or empty if none

argumentsArrayback to summary
pack-priv Type[] argumentsArray()
asParameterizedTypeback to summary
public ParameterizedType asParameterizedType()

Overrides org.jboss.jandex.Type.asParameterizedType.

Doc from org.jboss.jandex.Type.asParameterizedType.

Casts this type to a org.jboss.jandex.ParameterizedType and returns it if the kind is Kind#PARAMETERIZED_TYPE. Throws an exception otherwise.

Returns:ParameterizedType

a ParameterizedType

Annotations
@Override
builderback to summary
public static ParameterizedType.Builder builder(DotName name)

Create a builder of a parameterized type with the given name.

Parameters
name:DotName

binary name of the generic class

Returns:ParameterizedType.Builder

the builder

Since
3.1.0
builderback to summary
public static ParameterizedType.Builder builder(Class<?> clazz)

Create a builder of a parameterized type for the given generic class.

Parameters
clazz:Class<?>

the generic class

Returns:ParameterizedType.Builder

the builder

Since
3.1.0
copyTypeback to summary
pack-priv ParameterizedType copyType(AnnotationInstance[] newAnnotations)

Implements abstract org.jboss.jandex.Type.copyType.

Annotations
@Override
copyTypeback to summary
pack-priv ParameterizedType copyType(Type[] arguments)
copyTypeback to summary
pack-priv ParameterizedType copyType(int argumentIndex, Type argument)
copyTypeback to summary
pack-priv ParameterizedType copyType(Type owner)
createback to summary
public static ParameterizedType create(DotName name, Type... arguments)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

The resulting parameterized type has no owner.

Parameters
name:DotName

the binary name of the generic class

arguments:Type[]

type arguments applied to the generic class to form the parameterized type

Returns:ParameterizedType

the parameterized type

Since
3.1.0
createback to summary
public static ParameterizedType create(String name, Type... arguments)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

The resulting parameterized type has no owner.

Parameters
name:String

the binary name of the generic class

arguments:Type[]

type arguments applied to the generic class to form the parameterized type

Returns:ParameterizedType

the parameterized type

Since
3.1.0
createback to summary
public static ParameterizedType create(Class<?> clazz, Type... arguments)

Create an instance of a parameterized type with given generic clazz and given type arguments.

The resulting parameterized type has no owner.

Parameters
clazz:Class<?>

the generic class

arguments:Type[]

type arguments applied to the generic class to form the parameterized type

Returns:ParameterizedType

the parameterized type

Since
3.1.0
createback to summary
public static ParameterizedType create(DotName name, Type[] arguments, Type owner)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

An owner may 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:DotName

the binary name of the generic class

arguments:Type[]

an array of type arguments applied to a generic class to form the parameterized type

owner:Type

the enclosing type if annotated or parameterized, otherwise null

Returns:ParameterizedType

the parameterized type

Since
2.1
createback to summary
public static ParameterizedType create(String name, Type[] arguments, Type owner)

Create an instance of a parameterized type with given name, which denotes a generic class, and given type arguments.

An owner may 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:String

the binary name of the generic class

arguments:Type[]

an array of type arguments applied to a generic class to form the parameterized type

owner:Type

the enclosing type if annotated or parameterized, otherwise null

Returns:ParameterizedType

the parameterized type

Since
3.1.0
createback to summary
public static ParameterizedType create(Class<?> clazz, Type[] arguments, Type owner)

Create an instance of a parameterized type with given generic clazz and given type arguments.

An owner may 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:Class<?>

the generic class

arguments:Type[]

an array of type arguments applied to a generic class to form the parameterized type

owner:Type

the enclosing type if annotated or parameterized, otherwise null

Returns:ParameterizedType

the parameterized type

Since
3.1.0
equalsback to summary
public boolean equals(Object o)

Overrides org.jboss.jandex.Type.equals.

Doc from org.jboss.jandex.Type.equals.

Compares this Type with 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.

Parameters
o:Object

the type to compare to

Returns:boolean

true if equal

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.jboss.jandex.Type.hashCode.

Doc from org.jboss.jandex.Type.hashCode.

Computes a hash code representing this type.

Returns:int

the hash code

Annotations
@Override
internEqualsback to summary
pack-priv boolean internEquals(Object o)

Overrides org.jboss.jandex.Type.internEquals.

Annotations
@Override
internHashCodeback to summary
pack-priv int internHashCode()

Overrides org.jboss.jandex.Type.internHashCode.

Annotations
@Override
kindback to summary
public Type.Kind kind()

Implements abstract org.jboss.jandex.Type.kind.

Doc from org.jboss.jandex.Type.kind.

Returns the kind of Type this is.

Returns:Type.Kind

the kind

Annotations
@Override
ownerback to summary
public Type 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 a ClassType. Returns null otherwise.

Note that parameterized inner classes whose enclosing types are not parameterized or type-annotated have no owner and hence this method returns null in 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 for Y when X's owner() method is called.
Returns:Type

the owner type if the owner is parameterized or annotated, otherwise null

toStringback to summary
pack-priv String toString(boolean simple)

Overrides org.jboss.jandex.Type.toString.

Annotations
@Override
org.jboss.jandex back to summary

public final Class ParameterizedType.Builder

extends Type.Builder<ParameterizedType.Builder>
Class Inheritance

Convenient builder for ParameterizedType.
Since
3.1.0

Field Summary

Modifier and TypeField and Description
private List<Type>
private Type
Inherited from org.jboss.jandex.Type.Builder:
annotationsname

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ParameterizedType.Builder

Returns:

this builder
addArgument
(Type
the type argument, must not be null
argument
)

Adds a type argument.

public ParameterizedType.Builder

Returns:

this builder
addArgument
(Class<?>
the class whose type is added as a type argument, must not be null
clazz
)

Adds a ClassType argument for the given class.

public ParameterizedType

Returns:

the built parameterized type
build
()

Returns the built parameterized type.

public ParameterizedType.Builder

Returns:

this builder
setOwner
(Type
the owner of the parameterized type being built, must not be null
owner
)

Sets the owner.

Inherited from org.jboss.jandex.Type.Builder:
addAnnotationannotationsArrayself

Field Detail

argumentsback to summary
private List<Type> arguments
ownerback to summary
private Type owner

Constructor Detail

Builderback to summary
pack-priv Builder(DotName name)

Method Detail

addArgumentback to summary
public ParameterizedType.Builder addArgument(Type argument)

Adds a type argument.

Parameters
argument:Type

the type argument, must not be null

Returns:ParameterizedType.Builder

this builder

addArgumentback to summary
public ParameterizedType.Builder addArgument(Class<?> clazz)

Adds a ClassType argument for the given class.

Parameters
clazz:Class<?>

the class whose type is added as a type argument, must not be null

Returns:ParameterizedType.Builder

this builder

buildback to summary
public ParameterizedType build()

Returns the built parameterized type.

Returns:ParameterizedType

the built parameterized type

setOwnerback to summary
public ParameterizedType.Builder setOwner(Type owner)

Sets the owner.

Parameters
owner:Type

the owner of the parameterized type being built, must not be null

Returns:ParameterizedType.Builder

this builder

See Also
ParameterizedType#owner()