Top Description Methods
jakarta.enterprise.inject.build.compatible.spi

public Interface Types

Imports
jakarta.enterprise.lang.model.declarations.ClassInfo, jakarta.enterprise.lang.model.types.ArrayType, .ClassType, .ParameterizedType, .PrimitiveType, .Type, .VoidType, .WildcardType

Factory for types. Allows creating representations of the void pseudo-type, primitive types, class types, array types, parameterized types and wildcard types.
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public Type

Returns:

Type object representing the given class literal
of
(Class<?>
the class literal, must not be null
clazz
)

Returns a type from given class literal.

public ArrayType

Returns:

the ArrayType, never null
ofArray
(Type
the element Type, must not be null
elementType
,
int
the number of dimensions
dimensions
)

Returns an ArrayType for the given element type and number of dimensions.

public ClassType

Returns:

the ClassType or null if the class is not present in any bean archive
ofClass
(String
the binary name of the class, must not be null
name
)

Returns a ClassType for the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned by Class#getName().

public ClassType

Returns:

the ClassType, never null
ofClass
(ClassInfo
the ClassInfo, must not be null
clazz
)

Returns a ClassType for the given class declaration.

public PrimitiveType

Returns:

the PrimitiveType, never null
ofPrimitive
(PrimitiveType.PrimitiveKind
the primitive type kind, must not be null
kind
)

Returns a PrimitiveType for the given kind of primitive type.

public VoidType

Returns:

the VoidType, never null
ofVoid
()

Returns a VoidType, representing the void pseudo-type.

public ParameterizedType

Returns:

the parameterized type, never null
parameterized
(Class<?>
the type to parameterize, must not be null
genericType
,
Class<?>...
one or more type arguments
typeArguments
)

Returns a ParameterizedType for the given generic type and type arguments.

public ParameterizedType

Returns:

the parameterized type, never null
parameterized
(Class<?>
the type to parameterize, must not be null
genericType
,
Type...
one or more type arguments
typeArguments
)

Returns a ParameterizedType for the given generic type and type arguments.

public ParameterizedType

Returns:

the parameterized type, never null
parameterized
(ClassType
the type to parameterize, must not be null
genericType
,
Type...
one or more type arguments
typeArguments
)

Returns a ParameterizedType for the given generic type and type arguments.

public WildcardType

Returns:

a WildcardType object representing an unbounded wildcard type
wildcardUnbounded
()

Returns a WildcardType that represents an equivalent of ?

public WildcardType

Returns:

a WildcardType object representing a wildcard type with given upper bound
wildcardWithLowerBound
(Type
lower bound type, must not be null
lowerBound
)

Returns a WildcardType that represents an equivalent of ?

public WildcardType

Returns:

a WildcardType object representing a wildcard type with given upper bound
wildcardWithUpperBound
(Type
upper bound type, must not be null
upperBound
)

Returns a WildcardType that represents an equivalent of ?

Method Detail

ofback to summary
public Type of(Class<?> clazz)

Returns a type from given class literal. For example:

  • of(void.class): same as ofVoid()
  • of(int.class): same as ofPrimitive(PrimitiveKind.INT)
  • of(String.class): same as ofClass(... ClassInfo for String ...)
  • of(int[].class): same as ofArray(ofPrimitive(PrimitiveKind.INT), 1)
  • of(String[][].class): same as ofArray(ofClass(... ClassInfo for String ...), 2)
Parameters
clazz:Class<?>

the class literal, must not be null

Returns:Type

Type object representing the given class literal

ofArrayback to summary
public ArrayType ofArray(Type elementType, int dimensions)

Returns an ArrayType for the given element type and number of dimensions.

Note that this method accepts the element type of an array, even though ArrayType uses a component type representation. For example, the component type of String[][] is String[], while the element type is String.

Parameters
elementType:Type

the element Type, must not be null

dimensions:int

the number of dimensions

Returns:ArrayType

the ArrayType, never null

Exceptions
IllegalArgumentException:
if the element type is an array type, a wildcard type, or the void pseudo-type
ofClassback to summary
public ClassType ofClass(String name)

Returns a ClassType for the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned by Class#getName().

Note that this method returns ClassType, so name may only be a name of a class. For primitives, use ofPrimitive(PrimitiveType.PrimitiveKind). For arrays, use ofArray(Type, int).

Parameters
name:String

the binary name of the class, must not be null

Returns:ClassType

the ClassType or null if the class is not present in any bean archive

ofClassback to summary
public ClassType ofClass(ClassInfo clazz)

Returns a ClassType for the given class declaration.

Parameters
clazz:ClassInfo

the ClassInfo, must not be null

Returns:ClassType

the ClassType, never null

ofPrimitiveback to summary
public PrimitiveType ofPrimitive(PrimitiveType.PrimitiveKind kind)

Returns a PrimitiveType for the given kind of primitive type.

Parameters
kind:PrimitiveType.PrimitiveKind

the primitive type kind, must not be null

Returns:PrimitiveType

the PrimitiveType, never null

ofVoidback to summary
public VoidType ofVoid()

Returns a VoidType, representing the void pseudo-type.

Returns:VoidType

the VoidType, never null

parameterizedback to summary
public ParameterizedType parameterized(Class<?> genericType, Class<?>... typeArguments)

Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.

Parameters
genericType:Class<?>

the type to parameterize, must not be null

typeArguments:Class<?>[]

one or more type arguments

Returns:ParameterizedType

the parameterized type, never null

Exceptions
IllegalArgumentException:
if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
parameterizedback to summary
public ParameterizedType parameterized(Class<?> genericType, Type... typeArguments)

Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.

Parameters
genericType:Class<?>

the type to parameterize, must not be null

typeArguments:Type[]

one or more type arguments

Returns:ParameterizedType

the parameterized type, never null

Exceptions
IllegalArgumentException:
if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
parameterizedback to summary
public ParameterizedType parameterized(ClassType genericType, Type... typeArguments)

Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.

Parameters
genericType:ClassType

the type to parameterize, must not be null

typeArguments:Type[]

one or more type arguments

Returns:ParameterizedType

the parameterized type, never null

Exceptions
IllegalArgumentException:
if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
wildcardUnboundedback to summary
public WildcardType wildcardUnbounded()

Returns a WildcardType that represents an equivalent of ?.

Returns:WildcardType

a WildcardType object representing an unbounded wildcard type

wildcardWithLowerBoundback to summary
public WildcardType wildcardWithLowerBound(Type lowerBound)

Returns a WildcardType that represents an equivalent of ? super lowerBound.

Parameters
lowerBound:Type

lower bound type, must not be null

Returns:WildcardType

a WildcardType object representing a wildcard type with given upper bound

wildcardWithUpperBoundback to summary
public WildcardType wildcardWithUpperBound(Type upperBound)

Returns a WildcardType that represents an equivalent of ? extends upperBound. Note that if upperBound represents the java.lang.Object type, then the result is equivalent to wildcardUnbounded().

Parameters
upperBound:Type

upper bound type, must not be null

Returns:WildcardType

a WildcardType object representing a wildcard type with given upper bound