- All Known Implementing Classes:
Serializers.Base,SimpleSerializers
public interface Serializers
Interface that defines API for simple extensions that can provide additional serializers
for various types. Access is by a single callback method; instance is to either return
a configured
ValueSerializer for specified type, or null to indicate that it
does not support handling of the type. In latter case, further calls can be made
for other providers; in former case returned serializer is used for handling of
instances of specified type.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBasicSerializersimplementation that implements all methods but provides no serializers. -
Method Summary
Modifier and TypeMethodDescriptiondefault ValueSerializer<?>findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified array type.default ValueSerializer<?>findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Collection-like" type (type that acts likeCollection, but does not implement it).default ValueSerializer<?>findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedCollectiontype.default ValueSerializer<?>findEnumSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Method called by serialization framework first time a serializer is needed for givenEnumtype.default ValueSerializer<?>findExplicitPOJOSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Method called in case that a given type or property is declared to use shapeJsonFormat.Shape.POJOand is expected to be serialized "as POJO", that is, as an (JSON) Object.default ValueSerializer<?>findMapLikeSerializer(SerializationConfig config, MapLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, ValueSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Map-like" type (type that acts likeMap, but does not implement it).default ValueSerializer<?>findMapSerializer(SerializationConfig config, MapType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, ValueSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedMaptype.default ValueSerializer<?>findReferenceSerializer(SerializationConfig config, ReferenceType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer contentTypeSerializer, ValueSerializer<Object> contentValueSerializer) Method called by serialization framework first time a serializer is needed for givenReferenceTypedefault ValueSerializer<?>findSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Fallback ethod called by serialization framework first time a serializer is needed for given type, which is not of any more specific type (like enum, tree node, reference or container type) for which other methods are called).default ValueSerializer<?>findTreeNodeSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides)
-
Method Details
-
findSerializer
default ValueSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Fallback ethod called by serialization framework first time a serializer is needed for given type, which is not of any more specific type (like enum, tree node, reference or container type) for which other methods are called).Basically called for types for which none of other callbacks are called.
- Parameters:
type- Fully resolved type of instances to serializeconfig- Serialization configuration in usebeanDescRef- Accessor to additional information about typeformatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.- Returns:
- Configured serializer to use for the type; or null if implementation does not recognize or support type
-
findArraySerializer
default ValueSerializer<?> findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified array type. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findCollectionSerializer
default ValueSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedCollectiontype. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findCollectionLikeSerializer
default ValueSerializer<?> findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Collection-like" type (type that acts likeCollection, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findMapSerializer
default ValueSerializer<?> findMapSerializer(SerializationConfig config, MapType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, ValueSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedMaptype. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findMapLikeSerializer
default ValueSerializer<?> findMapLikeSerializer(SerializationConfig config, MapLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, ValueSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Map-like" type (type that acts likeMap, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findEnumSerializer
default ValueSerializer<?> findEnumSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Method called by serialization framework first time a serializer is needed for givenEnumtype.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescRefmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findTreeNodeSerializer
default ValueSerializer<?> findTreeNodeSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Method called by serialization framework first time a serializer is needed for givenTreeNode(usuallyJsonNode) type.- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescRefmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findReferenceSerializer
default ValueSerializer<?> findReferenceSerializer(SerializationConfig config, ReferenceType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides, TypeSerializer contentTypeSerializer, ValueSerializer<Object> contentValueSerializer) Method called by serialization framework first time a serializer is needed for givenReferenceType- Parameters:
formatOverrides- (nullable) Optional format overrides (usually from property definition), to change definitions thatbeanDescmay have (and which are NOT included). Usually combined callingSerializers.Base#calculateEffectiveFormat.
-
findExplicitPOJOSerializer
default ValueSerializer<?> findExplicitPOJOSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value formatOverrides) Method called in case that a given type or property is declared to use shapeJsonFormat.Shape.POJOand is expected to be serialized "as POJO", that is, as an (JSON) Object. This is usually NOT handled by extension modules as core databind knows how to do this, but sometimes it may be necessary to override this behavior.- Since:
- 3.0
-