Top Description Inners Methods
tools.jackson.databind.ser

public Interface Serializers

Known Direct Implementers
tools.jackson.databind.ser.Serializers.Base
Imports
com.fasterxml.jackson.annotation.JsonFormat, tools.jackson.core.TreeNode, tools.jackson.databind.*, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.type.*

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
Serializers.Base

Basic Serializers implementation that implements all methods but provides no serializers.

Method Summary

Modifier and TypeMethod and Description
public default ValueSerializer<?>
findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
,
TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer)

Method called by serialization framework first time a serializer is needed for specified array type.

public default ValueSerializer<?>
findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
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 like java.util.Collection, but does not implement it).

public default ValueSerializer<?>
findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
,
TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer)

Method called by serialization framework first time a serializer is needed for specified java.util.Collection type.

public default ValueSerializer<?>
findEnumSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDescRef may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
)

Method called by serialization framework first time a serializer is needed for given java.lang.Enum type.

public 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 shape JsonFormat.Shape.POJO and is expected to be serialized "as POJO", that is, as an (JSON) Object.

public default ValueSerializer<?>
findMapLikeSerializer(SerializationConfig config, MapLikeType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
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 like java.util.Map, but does not implement it).

public default ValueSerializer<?>
findMapSerializer(SerializationConfig config, MapType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
,
ValueSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, ValueSerializer<Object> elementValueSerializer)

Method called by serialization framework first time a serializer is needed for specified java.util.Map type.

public default ValueSerializer<?>
findReferenceSerializer(SerializationConfig config, ReferenceType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
,
TypeSerializer contentTypeSerializer, ValueSerializer<Object> contentValueSerializer)

Method called by serialization framework first time a serializer is needed for given ReferenceType

public default ValueSerializer<?>

Returns:

Configured serializer to use for the type; or null if implementation does not recognize or support type
findSerializer
(SerializationConfig
Serialization configuration in use
config
,
JavaType
Fully resolved type of instances to serialize
type
,
BeanDescription.Supplier
Accessor to additional information about type
beanDescRef
,
JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
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).

public default ValueSerializer<?>
findTreeNodeSerializer(SerializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef, JsonFormat.Value
(nullable) Optional format overrides (usually from property definition), to change definitions that beanDescRef may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.
formatOverrides
)

Method called by serialization framework first time a serializer is needed for given TreeNode (usually JsonNode) type.

Method Detail

findArraySerializerback to summary
public 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:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findCollectionLikeSerializerback to summary
public 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 like java.util.Collection, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findCollectionSerializerback to summary
public 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 specified java.util.Collection type. Implementation should return a serializer instance if it supports specified type; or null if it does not.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findEnumSerializerback to summary
public 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 given java.lang.Enum type.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDescRef may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findExplicitPOJOSerializerback to summary
public 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 shape JsonFormat.Shape.POJO and 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
findMapLikeSerializerback to summary
public 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 like java.util.Map, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findMapSerializerback to summary
public 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 specified java.util.Map type. Implementation should return a serializer instance if it supports specified type; or null if it does not.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findReferenceSerializerback to summary
public 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 given ReferenceType

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

findSerializerback to summary
public 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
config:SerializationConfig

Serialization configuration in use

type:JavaType

Fully resolved type of instances to serialize

beanDescRef:BeanDescription.Supplier

Accessor to additional information about type

formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDesc may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

Returns:ValueSerializer<?>

Configured serializer to use for the type; or null if implementation does not recognize or support type

findTreeNodeSerializerback to summary
public 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 given TreeNode (usually JsonNode) type.

Parameters
formatOverrides:JsonFormat.Value

(nullable) Optional format overrides (usually from property definition), to change definitions that beanDescRef may have (and which are NOT included). Usually combined calling Serializers.Base#calculateEffectiveFormat.

tools.jackson.databind.ser back to summary

public Class Serializers.Base

extends Object
implements Serializers
Class Inheritance
All Implemented Interfaces
tools.jackson.databind.ser.Serializers
Known Direct Subclasses
tools.jackson.databind.module.SimpleSerializers

Basic Serializers implementation that implements all methods but provides no serializers. Its main purpose is to serve as a base class so that sub-classes only need to override methods they need.

Constructor Summary

AccessConstructor and Description
public
Base()

Method Summary

Modifier and TypeMethod and Description
protected JsonFormat.Value
calculateEffectiveFormat(BeanDescription.Supplier beanDescRef, Class<?> baseType, JsonFormat.Value formatOverrides)

Helper method for determining effective combination of formatting settings from combination of Class annotations and config overrides for type and possible per-property overrides (in this order of precedence from lowest to highest).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Baseback to summary
public Base()

Method Detail

calculateEffectiveFormatback to summary
protected JsonFormat.Value calculateEffectiveFormat(BeanDescription.Supplier beanDescRef, Class<?> baseType, JsonFormat.Value formatOverrides)

Helper method for determining effective combination of formatting settings from combination of Class annotations and config overrides for type and possible per-property overrides (in this order of precedence from lowest to highest).