public final class Serializers
extends java.lang.Object
Transformers.| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.Class<? extends Transformer<?,?>>> |
getSerializerClasses(java.lang.reflect.Type type,
ApiSerializationConfig config)
Gets the
Transformer class for a particular data type. |
static java.lang.reflect.Type |
getSourceType(java.lang.Class<? extends Transformer<?,?>> clazz)
Gets the
Serializer source type for a class. |
static java.lang.reflect.Type |
getTargetType(java.lang.Class<? extends Transformer<?,?>> clazz)
Gets the
Serializer target type for a class. |
static <S extends Transformer<?,?>> |
instantiate(java.lang.Class<S> serializerClass,
java.lang.reflect.Type sourceType)
Instantiates a new serializer instance.
|
public static <S extends Transformer<?,?>> S instantiate(java.lang.Class<S> serializerClass, java.lang.reflect.Type sourceType)
serializerClass - a serializer classsourceType - the type being serializedjava.lang.IllegalStateException - if instantiation failed, or the class does not implement
Serializerpublic static java.util.List<java.lang.Class<? extends Transformer<?,?>>> getSerializerClasses(@Nullable java.lang.reflect.Type type, @Nullable ApiSerializationConfig config)
Transformer class for a particular data type. This first checks to see if the
type or any of its parents is annotated with ApiTransformer. If that fails, a lookup
is made in the serialization config.type - a type to find a serializer forconfig - a serialization config@Nullable
public static java.lang.reflect.Type getSourceType(@Nullable
java.lang.Class<? extends Transformer<?,?>> clazz)
Serializer source type for a class. This resolves placeholders in generics.clazz - a class, possibly implementing Serializer@Nullable
public static java.lang.reflect.Type getTargetType(@Nullable
java.lang.Class<? extends Transformer<?,?>> clazz)
Serializer target type for a class. This resolves placeholders in generics.clazz - a class, possibly implementing Serializer