Top Description Fields Constructors Methods
tools.jackson.databind.ser

public abstract Class ValueSerializerModifier

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.List, tools.jackson.databind.*, tools.jackson.databind.deser.DeserializerFactory, tools.jackson.databind.type.*

Abstract class that defines API for objects that can be registered (via ObjectMapper configuration process, using tools.jackson.databind.cfg.MapperBuilder) to participate in constructing ValueSerializer instances (including but not limited to BeanSerializers). This is typically done by modules that want alter some aspects of the typical serialization process.

Sequence in which callback methods are called is as follows:

  1. After factory has collected tentative set of properties (instances of BeanPropertyWriter) is sent for modification via changeProperties. Changes can include removal, addition and replacement of suggested properties.
  2. Resulting set of properties are ordered (sorted) by factory, as per configuration, and then orderProperties is called to allow modifiers to alter ordering.
  3. After all bean properties and related information is accumulated, updateBuilder is called with builder, to allow builder state to be modified (including possibly replacing builder itself if necessary)
  4. Once all bean information has been determined, factory creates default BeanSerializer instance and passes it to modifiers using modifySerializer (or type-specic alternative modifyXxxSerializer() method), for possible modification or replacement (by any tools.jackson.databind.ValueSerializer instance)

Default method implementations are "no-op"s, meaning that methods are implemented but have no effect.

Note

In Jackson 2.x was named BeanSerializerModifier

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public List<BeanPropertyWriter>
changeProperties(SerializationConfig config, BeanDescription.Supplier beanDesc, List<BeanPropertyWriter> beanProperties)

Method called by BeanSerializerFactory with tentative set of discovered properties.

public ValueSerializer<?>

Returns:

Serializer to use; either serializer that was passed in, or an instance method constructed.
modifyArraySerializer
(SerializationConfig
Configuration in use
config
,
ArrayType
Type of the value serializer is used for.
valueType
,
BeanDescription.Supplier
Details of the type in question, to allow checking class annotations
beanDesc
,
ValueSerializer<?>
Default serializer that would be used.
serializer
)

Method called by DeserializerFactory after it has constructed the standard serializer for given ArrayType to make it possible to either replace or augment this serializer with additional functionality.

public ValueSerializer<?>
public ValueSerializer<?>
public ValueSerializer<?>
public ValueSerializer<?>

Returns:

Serializer to use; either serializer that was passed in, or an instance method constructed.
modifyKeySerializer
(SerializationConfig
Configuration in use
config
,
JavaType
Type of keys the serializer is used for.
valueType
,
BeanDescription.Supplier
Details of the type in question, to allow checking class annotations
beanDesc
,
ValueSerializer<?>
Default serializer that would be used.
serializer
)

Method called by DeserializerFactory after it has constructed the default key serializer to use for serializing java.util.Map keys of given type.

public ValueSerializer<?>
public ValueSerializer<?>
public ValueSerializer<?>
modifySerializer(SerializationConfig config, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)

Method called by BeanSerializerFactory after constructing default bean serializer instance with properties collected and ordered earlier.

public List<BeanPropertyWriter>
orderProperties(SerializationConfig config, BeanDescription.Supplier beanDesc, List<BeanPropertyWriter> beanProperties)

Method called by BeanSerializerFactory with set of properties to serialize, in default ordering (based on defaults as well as possible type annotations).

public BeanSerializerBuilder
updateBuilder(SerializationConfig config, BeanDescription.Supplier beanDesc, BeanSerializerBuilder builder)

Method called by BeanSerializerFactory after collecting all information regarding POJO to serialize and updating builder with it, but before constructing serializer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ValueSerializerModifierback to summary
public ValueSerializerModifier()

Method Detail

changePropertiesback to summary
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription.Supplier beanDesc, List<BeanPropertyWriter> beanProperties)

Method called by BeanSerializerFactory with tentative set of discovered properties. Implementations can add, remove or replace any of passed properties. Properties List passed as argument is modifiable, and returned List must likewise be modifiable as it may be passed to multiple registered modifiers.

modifyArraySerializerback to summary
public ValueSerializer<?> modifyArraySerializer(SerializationConfig config, ArrayType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)

Method called by DeserializerFactory after it has constructed the standard serializer for given ArrayType to make it possible to either replace or augment this serializer with additional functionality.

Parameters
config:SerializationConfig

Configuration in use

valueType:ArrayType

Type of the value serializer is used for.

beanDesc:BeanDescription.Supplier

Details of the type in question, to allow checking class annotations

serializer:ValueSerializer<?>

Default serializer that would be used.

Returns:ValueSerializer<?>

Serializer to use; either serializer that was passed in, or an instance method constructed.

modifyCollectionLikeSerializerback to summary
public ValueSerializer<?> modifyCollectionLikeSerializer(SerializationConfig config, CollectionLikeType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)
modifyCollectionSerializerback to summary
public ValueSerializer<?> modifyCollectionSerializer(SerializationConfig config, CollectionType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)
modifyEnumSerializerback to summary
public ValueSerializer<?> modifyEnumSerializer(SerializationConfig config, JavaType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)
modifyKeySerializerback to summary
public ValueSerializer<?> modifyKeySerializer(SerializationConfig config, JavaType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)

Method called by DeserializerFactory after it has constructed the default key serializer to use for serializing java.util.Map keys of given type. This makes it possible to either replace or augment default serializer with additional functionality.

Parameters
config:SerializationConfig

Configuration in use

valueType:JavaType

Type of keys the serializer is used for.

beanDesc:BeanDescription.Supplier

Details of the type in question, to allow checking class annotations

serializer:ValueSerializer<?>

Default serializer that would be used.

Returns:ValueSerializer<?>

Serializer to use; either serializer that was passed in, or an instance method constructed.

modifyMapLikeSerializerback to summary
public ValueSerializer<?> modifyMapLikeSerializer(SerializationConfig config, MapLikeType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)
modifyMapSerializerback to summary
public ValueSerializer<?> modifyMapSerializer(SerializationConfig config, MapType valueType, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)
modifySerializerback to summary
public ValueSerializer<?> modifySerializer(SerializationConfig config, BeanDescription.Supplier beanDesc, ValueSerializer<?> serializer)

Method called by BeanSerializerFactory after constructing default bean serializer instance with properties collected and ordered earlier. Implementations can modify or replace given serializer and return serializer to use. Note that although initial serializer being passed is of type BeanSerializer, modifiers may return serializers of other types; and this is why implementations must check for type before casting.

Note

this method gets called for serializer of those non-POJO types that do not go through any of more specific modifyXxxSerializer methods; mostly for JDK types like java.util.Iterator and such.

orderPropertiesback to summary
public List<BeanPropertyWriter> orderProperties(SerializationConfig config, BeanDescription.Supplier beanDesc, List<BeanPropertyWriter> beanProperties)

Method called by BeanSerializerFactory with set of properties to serialize, in default ordering (based on defaults as well as possible type annotations). Implementations can change ordering any way they like. Properties List passed as argument is modifiable, and returned List must likewise be modifiable as it may be passed to multiple registered modifiers.

updateBuilderback to summary
public BeanSerializerBuilder updateBuilder(SerializationConfig config, BeanDescription.Supplier beanDesc, BeanSerializerBuilder builder)

Method called by BeanSerializerFactory after collecting all information regarding POJO to serialize and updating builder with it, but before constructing serializer. Implementations may choose to modify state of builder (to affect serializer being built), or even completely replace it (if they want to build different kind of serializer). Typically, however, passed-in builder is returned, possibly with some modifications.