Interface Types
public interface Types
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 TypeMethodDescriptionjakarta.enterprise.lang.model.types.TypeReturns a type from given class literal.jakarta.enterprise.lang.model.types.ArrayTypeofArray(jakarta.enterprise.lang.model.types.Type elementType, int dimensions) Returns anArrayTypefor the given element type and number of dimensions.jakarta.enterprise.lang.model.types.ClassTypeofClass(jakarta.enterprise.lang.model.declarations.ClassInfo clazz) Returns aClassTypefor the given class declaration.jakarta.enterprise.lang.model.types.ClassTypeReturns aClassTypefor the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getName().jakarta.enterprise.lang.model.types.PrimitiveTypeofPrimitive(jakarta.enterprise.lang.model.types.PrimitiveType.PrimitiveKind kind) Returns aPrimitiveTypefor the given kind of primitive type.jakarta.enterprise.lang.model.types.VoidTypeofVoid()Returns aVoidType, representing thevoidpseudo-type.jakarta.enterprise.lang.model.types.ParameterizedTypeparameterized(jakarta.enterprise.lang.model.types.ClassType genericType, jakarta.enterprise.lang.model.types.Type... typeArguments) Returns aParameterizedTypefor the given generic type and type arguments.jakarta.enterprise.lang.model.types.ParameterizedTypeparameterized(Class<?> genericType, jakarta.enterprise.lang.model.types.Type... typeArguments) Returns aParameterizedTypefor the given generic type and type arguments.jakarta.enterprise.lang.model.types.ParameterizedTypeparameterized(Class<?> genericType, Class<?>... typeArguments) Returns aParameterizedTypefor the given generic type and type arguments.jakarta.enterprise.lang.model.types.WildcardTypeReturns aWildcardTypethat represents an equivalent of?.jakarta.enterprise.lang.model.types.WildcardTypewildcardWithLowerBound(jakarta.enterprise.lang.model.types.Type lowerBound) Returns aWildcardTypethat represents an equivalent of? super lowerBound.jakarta.enterprise.lang.model.types.WildcardTypewildcardWithUpperBound(jakarta.enterprise.lang.model.types.Type upperBound) Returns aWildcardTypethat represents an equivalent of? extends upperBound.
-
Method Details
-
of
Returns a type from given class literal. For example:of(void.class): same asofVoid()of(int.class): same asofPrimitive(PrimitiveKind.INT)of(String.class): same asofClass(... ClassInfo for String ...)of(int[].class): same asofArray(ofPrimitive(PrimitiveKind.INT), 1)of(String[][].class): same asofArray(ofClass(... ClassInfo for String ...), 2)
- Parameters:
clazz- the class literal, must not benull- Returns:
Typeobject representing the given class literal
-
ofVoid
jakarta.enterprise.lang.model.types.VoidType ofVoid()Returns aVoidType, representing thevoidpseudo-type.- Returns:
- the
VoidType, nevernull
-
ofPrimitive
jakarta.enterprise.lang.model.types.PrimitiveType ofPrimitive(jakarta.enterprise.lang.model.types.PrimitiveType.PrimitiveKind kind) Returns aPrimitiveTypefor the given kind of primitive type.- Parameters:
kind- the primitive type kind, must not benull- Returns:
- the
PrimitiveType, nevernull
-
ofClass
Returns aClassTypefor the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getName().Note that this method returns
ClassType, sonamemay only be a name of a class. For primitives, useofPrimitive(PrimitiveType.PrimitiveKind). For arrays, useofArray(Type, int).- Parameters:
name- the binary name of the class, must not benull- Returns:
- the
ClassTypeornullif the class is not present in any bean archive
-
ofClass
jakarta.enterprise.lang.model.types.ClassType ofClass(jakarta.enterprise.lang.model.declarations.ClassInfo clazz) Returns aClassTypefor the given class declaration.- Parameters:
clazz- theClassInfo, must not benull- Returns:
- the
ClassType, nevernull
-
ofArray
jakarta.enterprise.lang.model.types.ArrayType ofArray(jakarta.enterprise.lang.model.types.Type elementType, int dimensions) Returns anArrayTypefor the given element type and number of dimensions.Note that this method accepts the element type of an array, even though
ArrayTypeuses a component type representation. For example, the component type ofString[][]isString[], while the element type isString.- Parameters:
elementType- the elementType, must not benulldimensions- the number of dimensions- Returns:
- the
ArrayType, nevernull - Throws:
IllegalArgumentException- if the element type is an array type, a wildcard type, or the void pseudo-type
-
parameterized
jakarta.enterprise.lang.model.types.ParameterizedType parameterized(Class<?> genericType, Class<?>... typeArguments) Returns aParameterizedTypefor 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- the type to parameterize, must not benulltypeArguments- one or more type arguments- Returns:
- the parameterized type, never
null - Throws:
IllegalArgumentException- if givengenericTypeis not generic or if the number of type arguments does not match the number of type parameters declared bygenericType
-
parameterized
jakarta.enterprise.lang.model.types.ParameterizedType parameterized(Class<?> genericType, jakarta.enterprise.lang.model.types.Type... typeArguments) Returns aParameterizedTypefor 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- the type to parameterize, must not benulltypeArguments- one or more type arguments- Returns:
- the parameterized type, never
null - Throws:
IllegalArgumentException- if givengenericTypeis not generic or if the number of type arguments does not match the number of type parameters declared bygenericType
-
parameterized
jakarta.enterprise.lang.model.types.ParameterizedType parameterized(jakarta.enterprise.lang.model.types.ClassType genericType, jakarta.enterprise.lang.model.types.Type... typeArguments) Returns aParameterizedTypefor 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- the type to parameterize, must not benulltypeArguments- one or more type arguments- Returns:
- the parameterized type, never
null - Throws:
IllegalArgumentException- if givengenericTypeis not generic or if the number of type arguments does not match the number of type parameters declared bygenericType
-
wildcardWithUpperBound
jakarta.enterprise.lang.model.types.WildcardType wildcardWithUpperBound(jakarta.enterprise.lang.model.types.Type upperBound) Returns aWildcardTypethat represents an equivalent of? extends upperBound. Note that ifupperBoundrepresents thejava.lang.Objecttype, then the result is equivalent towildcardUnbounded().- Parameters:
upperBound- upper bound type, must not benull- Returns:
- a
WildcardTypeobject representing a wildcard type with given upper bound
-
wildcardWithLowerBound
jakarta.enterprise.lang.model.types.WildcardType wildcardWithLowerBound(jakarta.enterprise.lang.model.types.Type lowerBound) Returns aWildcardTypethat represents an equivalent of? super lowerBound.- Parameters:
lowerBound- lower bound type, must not benull- Returns:
- a
WildcardTypeobject representing a wildcard type with given upper bound
-
wildcardUnbounded
jakarta.enterprise.lang.model.types.WildcardType wildcardUnbounded()Returns aWildcardTypethat represents an equivalent of?.- Returns:
- a
WildcardTypeobject representing an unbounded wildcard type
-