public final class Types extends Object
Modifier and Type | Method and Description |
---|---|
static GenericArrayType |
arrayOf(Type componentType)
Returns an array type whose elements are all instances of
componentType . |
static ParameterizedType |
listOf(Type elementType)
Returns a type modelling a
List whose elements are of type
elementType . |
static ParameterizedType |
mapOf(Type keyType,
Type valueType)
Returns a type modelling a
Map whose keys are of type
keyType and whose values are of type valueType . |
static ParameterizedType |
newParameterizedType(Type rawType,
Type... typeArguments)
Returns a new parameterized type, applying
typeArguments to
rawType . |
static ParameterizedType |
newParameterizedTypeWithOwner(Type ownerType,
Type rawType,
Type... typeArguments)
Returns a new parameterized type, applying
typeArguments to
rawType and enclosed by ownerType . |
static ParameterizedType |
providerOf(Type providedType)
Returns a type modelling a
Provider that provides elements of type
elementType . |
static ParameterizedType |
setOf(Type elementType)
Returns a type modelling a
Set whose elements are of type
elementType . |
static WildcardType |
subtypeOf(Type bound)
Returns a type that represents an unknown type that extends
bound . |
static WildcardType |
supertypeOf(Type bound)
Returns a type that represents an unknown supertype of
bound . |
public static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
typeArguments
to
rawType
. The returned type does not have an owner type.serializable
parameterized type.public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
typeArguments
to
rawType
and enclosed by ownerType
.serializable
parameterized type.public static GenericArrayType arrayOf(Type componentType)
componentType
.serializable
generic array type.public static WildcardType subtypeOf(Type bound)
bound
.
For example, if bound
is CharSequence.class
, this returns
? extends CharSequence
. If bound
is Object.class
,
this returns ?
, which is shorthand for ? extends Object
.public static WildcardType supertypeOf(Type bound)
bound
. For
example, if bound
is String.class
, this returns ?
super String
.public static ParameterizedType listOf(Type elementType)
List
whose elements are of type
elementType
.serializable
parameterized type.public static ParameterizedType setOf(Type elementType)
Set
whose elements are of type
elementType
.serializable
parameterized type.public static ParameterizedType mapOf(Type keyType, Type valueType)
Map
whose keys are of type
keyType
and whose values are of type valueType
.serializable
parameterized type.public static ParameterizedType providerOf(Type providedType)
Provider
that provides elements of type
elementType
.serializable
parameterized type.