final class SerializableTypeWrapper
extends java.lang.Object
Serializable
variants of java.lang.reflect.Types
.
Fields
or MethodParameters
can be used as the root source for a serializable type.
Alternatively, a regular Class
can also be used as source.
The returned type will either be a Class
or a serializable proxy of
GenericArrayType
, ParameterizedType
, TypeVariable
or
WildcardType
. With the exception of Class
(which is final) calls
to methods that return further Types
(for example
GenericArrayType.getGenericComponentType()
) will be automatically wrapped.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SerializableTypeWrapper.FieldTypeProvider
|
(package private) static class |
SerializableTypeWrapper.MethodInvokeTypeProvider
SerializableTypeWrapper.TypeProvider for Types obtained by invoking a no-arg method. |
(package private) static class |
SerializableTypeWrapper.MethodParameterTypeProvider
|
(package private) static interface |
SerializableTypeWrapper.SerializableTypeProxy
Additional interface implemented by the type proxy.
|
(package private) static interface |
SerializableTypeWrapper.TypeProvider
A
Serializable interface providing access to a Type . |
private static class |
SerializableTypeWrapper.TypeProxyInvocationHandler
Serializable InvocationHandler used by the proxied Type . |
Modifier and Type | Field and Description |
---|---|
(package private) static ConcurrentReferenceHashMap<java.lang.reflect.Type,java.lang.reflect.Type> |
cache |
private static java.lang.Class<?>[] |
SUPPORTED_SERIALIZABLE_TYPES |
Modifier | Constructor and Description |
---|---|
private |
SerializableTypeWrapper() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Type |
forField(java.lang.reflect.Field field)
Return a
Serializable variant of Field.getGenericType() . |
static java.lang.reflect.Type |
forMethodParameter(MethodParameter methodParameter)
Return a
Serializable variant of
MethodParameter.getGenericParameterType() . |
(package private) static java.lang.reflect.Type |
forTypeProvider(SerializableTypeWrapper.TypeProvider provider)
|
static <T extends java.lang.reflect.Type> |
unwrap(T type)
Unwrap the given type, effectively returning the original non-serializable type.
|
private static final java.lang.Class<?>[] SUPPORTED_SERIALIZABLE_TYPES
static final ConcurrentReferenceHashMap<java.lang.reflect.Type,java.lang.reflect.Type> cache
@Nullable public static java.lang.reflect.Type forField(java.lang.reflect.Field field)
Serializable
variant of Field.getGenericType()
.@Nullable public static java.lang.reflect.Type forMethodParameter(MethodParameter methodParameter)
Serializable
variant of
MethodParameter.getGenericParameterType()
.public static <T extends java.lang.reflect.Type> T unwrap(T type)
type
- the type to unwrap@Nullable static java.lang.reflect.Type forTypeProvider(SerializableTypeWrapper.TypeProvider provider)
Serializable
Type
backed by a SerializableTypeWrapper.TypeProvider
.
If type artifacts are generally not serializable in the current runtime
environment, this delegate will simply return the original Type
as-is.