public class SimpleSerializers extends Serializers.Base implements java.io.Serializable
Serializers
which allows registration of
serializers based on raw (type erased class).
It can work well for basic bean and scalar type serializers, but is not
a good fit for handling generic types (like Map
s and Collection
s).
Type registrations are assumed to be general; meaning that registration of serializer
for a super type will also be used for handling subtypes, unless an exact match
is found first. As an example, handler for CharSequence
would also be used
serializing StringBuilder
instances, unless a direct mapping was found.
Serializers.Base
Constructor and Description |
---|
SimpleSerializers() |
SimpleSerializers(java.util.List<JsonSerializer<?>> sers) |
Modifier and Type | Method and Description |
---|---|
<T> void |
addSerializer(java.lang.Class<? extends T> type,
JsonSerializer<T> ser) |
void |
addSerializer(JsonSerializer<?> ser)
Method for adding given serializer for type that
JsonSerializer.handledType()
specifies (which MUST return a non-null class; and can NOT be Object , as a
sanity check). |
void |
addSerializers(java.util.List<JsonSerializer<?>> sers) |
JsonSerializer<?> |
findArraySerializer(SerializationConfig config,
ArrayType type,
BeanDescription beanDesc,
TypeSerializer elementTypeSerializer,
JsonSerializer<java.lang.Object> elementValueSerializer)
Method called by serialization framework first time a serializer is needed for
specified array type.
|
JsonSerializer<?> |
findCollectionLikeSerializer(SerializationConfig config,
CollectionLikeType type,
BeanDescription beanDesc,
TypeSerializer elementTypeSerializer,
JsonSerializer<java.lang.Object> elementValueSerializer)
Method called by serialization framework first time a serializer is needed for
specified "Collection-like" type (type that acts like
Collection ,
but does not implement it). |
JsonSerializer<?> |
findCollectionSerializer(SerializationConfig config,
CollectionType type,
BeanDescription beanDesc,
TypeSerializer elementTypeSerializer,
JsonSerializer<java.lang.Object> elementValueSerializer)
Method called by serialization framework first time a serializer is needed for
specified
Collection type. |
JsonSerializer<?> |
findMapLikeSerializer(SerializationConfig config,
MapLikeType type,
BeanDescription beanDesc,
JsonSerializer<java.lang.Object> keySerializer,
TypeSerializer elementTypeSerializer,
JsonSerializer<java.lang.Object> elementValueSerializer)
Method called by serialization framework first time a serializer is needed for
specified "Map-like" type (type that acts like
Map ,
but does not implement it). |
JsonSerializer<?> |
findMapSerializer(SerializationConfig config,
MapType type,
BeanDescription beanDesc,
JsonSerializer<java.lang.Object> keySerializer,
TypeSerializer elementTypeSerializer,
JsonSerializer<java.lang.Object> elementValueSerializer)
Method called by serialization framework first time a serializer is needed for
specified
Map type. |
JsonSerializer<?> |
findSerializer(SerializationConfig config,
JavaType type,
BeanDescription beanDesc)
Method called by serialization framework first time a serializer is needed for
specified type, which is not of a container or reference type (for which
other methods are called).
|
findReferenceSerializer
public SimpleSerializers()
public SimpleSerializers(java.util.List<JsonSerializer<?>> sers)
public void addSerializer(JsonSerializer<?> ser)
JsonSerializer.handledType()
specifies (which MUST return a non-null class; and can NOT be Object
, as a
sanity check).
For serializers that do not declare handled type, use the variant that takes
two arguments.ser
- public <T> void addSerializer(java.lang.Class<? extends T> type, JsonSerializer<T> ser)
public void addSerializers(java.util.List<JsonSerializer<?>> sers)
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc)
Serializers
findSerializer
in interface Serializers
findSerializer
in class Serializers.Base
config
- Serialization configuration in usetype
- Fully resolved type of instances to serializebeanDesc
- Additional information about typepublic JsonSerializer<?> findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<java.lang.Object> elementValueSerializer)
Serializers
findArraySerializer
in interface Serializers
findArraySerializer
in class Serializers.Base
public JsonSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<java.lang.Object> elementValueSerializer)
Serializers
Collection
type.
Implementation should return a serializer instance if it supports
specified type; or null if it does not.findCollectionSerializer
in interface Serializers
findCollectionSerializer
in class Serializers.Base
public JsonSerializer<?> findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<java.lang.Object> elementValueSerializer)
Serializers
Collection
,
but does not implement it).
Implementation should return a serializer instance if it supports
specified type; or null if it does not.findCollectionLikeSerializer
in interface Serializers
findCollectionLikeSerializer
in class Serializers.Base
public JsonSerializer<?> findMapSerializer(SerializationConfig config, MapType type, BeanDescription beanDesc, JsonSerializer<java.lang.Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<java.lang.Object> elementValueSerializer)
Serializers
Map
type.
Implementation should return a serializer instance if it supports
specified type; or null if it does not.findMapSerializer
in interface Serializers
findMapSerializer
in class Serializers.Base
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config, MapLikeType type, BeanDescription beanDesc, JsonSerializer<java.lang.Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<java.lang.Object> elementValueSerializer)
Serializers
Map
,
but does not implement it).
Implementation should return a serializer instance if it supports
specified type; or null if it does not.findMapLikeSerializer
in interface Serializers
findMapLikeSerializer
in class Serializers.Base
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"