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