public class Types extends Object
Types API.| Modifier and Type | Class and Description |
|---|---|
static class |
Types.GenericArrayTypeImpl |
static class |
Types.ParameterizedTypeImpl |
static class |
Types.WildcardTypeImpl
The WildcardType interface supports multiple upper bounds and multiple
lower bounds.
|
| Modifier and Type | Field and Description |
|---|---|
static Type[] |
EMPTY_TYPE_ARRAY |
| Modifier and Type | Method and Description |
|---|---|
static GenericArrayType |
arrayOf(Type componentType)
Returns an array type whose elements are all instances of
componentType. |
static Type |
canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal
according to
Object.equals(). |
static void |
checkIdenticalTypes(Class expected,
Class actual) |
static boolean |
equals(Type a,
Type b)
Returns true if
a and b are equal. |
static Type |
getGenericSupertype(Type type,
Class<?> rawType,
Class<?> toResolve)
Returns the generic supertype for
type. |
static Class<?> |
getRawType(Type type) |
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 Type |
resolveTypeVariable(Type type,
Class<?> rawType,
TypeVariable unknown) |
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. |
static String |
typeToString(Type type) |
public static final Type[] EMPTY_TYPE_ARRAY
public static Type canonicalize(Type type)
Object.equals(). The returned
type is Serializable.public static Type getGenericSupertype(Type type, Class<?> rawType, Class<?> toResolve)
type. For example, given a class IntegerSet,
the result for when supertype is Set.class is Set<Integer> and the result
when the supertype is Collection.class is Collection<Integer>.public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown)
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.Copyright © 2016. All rights reserved.