Skip to content

Commit

Permalink
Fix #3047 (Bean[De]SerializerModifier->Value[De]SerializerModifier)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 8, 2021
1 parent c59045b commit 3db9730
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 130 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ Versions: 3.x (for earlier see VERSION-2.x)
`JsonGenerator.canWriteBinaryNatively()`
#3037: Rename `Module` as `JacksonModule` in 3.0 (to avoid overlap with `java.lang.Module`)
#3046: Rename `JsonSerializable` as `JacksonSerializable` in 3.0
#3047: Rename `Bean[De]SerializerModifier` as `Value[De]SerializerModifier` in 3.0
- Remove `MappingJsonFactory`
- Add context parameter for `TypeSerializer` contextualization (`forProperty()`)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.fasterxml.jackson.databind.cfg.MutableConfigOverride;
import com.fasterxml.jackson.databind.deser.*;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import com.fasterxml.jackson.databind.ser.ValueSerializerModifier;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.databind.type.TypeModifier;
Expand Down Expand Up @@ -199,7 +199,7 @@ public static interface SetupContext
*
* @param mod Modifier to register
*/
public SetupContext addDeserializerModifier(BeanDeserializerModifier mod);
public SetupContext addDeserializerModifier(ValueDeserializerModifier mod);

/**
* Method that module can use to register additional {@link com.fasterxml.jackson.databind.deser.ValueInstantiator}s,
Expand Down Expand Up @@ -239,7 +239,7 @@ public static interface SetupContext
*
* @param mod Modifier to register
*/
public SetupContext addSerializerModifier(BeanSerializerModifier mod);
public SetupContext addSerializerModifier(ValueSerializerModifier mod);

/**
* Method that module can use to override handler called to write JSON Object key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DeserializerFactoryConfig
private static final long serialVersionUID = 3L;

protected final static Deserializers[] NO_DESERIALIZERS = new Deserializers[0];
protected final static BeanDeserializerModifier[] NO_MODIFIERS = new BeanDeserializerModifier[0];
protected final static ValueDeserializerModifier[] NO_MODIFIERS = new ValueDeserializerModifier[0];
protected final static ValueInstantiators[] NO_VALUE_INSTANTIATORS = new ValueInstantiators[0];

/**
Expand All @@ -42,7 +42,7 @@ public class DeserializerFactoryConfig
* List of modifiers that can change the way {@link BeanDeserializer} instances
* are configured and constructed.
*/
protected final BeanDeserializerModifier[] _modifiers;
protected final ValueDeserializerModifier[] _modifiers;

/**
* List of objects that know how to create instances of POJO types;
Expand All @@ -67,7 +67,7 @@ public DeserializerFactoryConfig() {
*/
protected DeserializerFactoryConfig(Deserializers[] allAdditionalDeserializers,
KeyDeserializers[] allAdditionalKeyDeserializers,
BeanDeserializerModifier[] modifiers,
ValueDeserializerModifier[] modifiers,
ValueInstantiators[] vi)
{
_additionalDeserializers = (allAdditionalDeserializers == null) ?
Expand Down Expand Up @@ -116,12 +116,12 @@ public DeserializerFactoryConfig withAdditionalKeyDeserializers(KeyDeserializers
* deserialiazer modifier. Added modifier has the highest priority (that is, it
* gets called before any already registered modifier).
*/
public DeserializerFactoryConfig withDeserializerModifier(BeanDeserializerModifier modifier)
public DeserializerFactoryConfig withDeserializerModifier(ValueDeserializerModifier modifier)
{
if (modifier == null) {
throw new IllegalArgumentException("Cannot pass null modifier");
}
BeanDeserializerModifier[] all = ArrayBuilders.insertInListNoDup(_modifiers, modifier);
ValueDeserializerModifier[] all = ArrayBuilders.insertInListNoDup(_modifiers, modifier);
return new DeserializerFactoryConfig(_additionalDeserializers, _additionalKeyDeserializers,
all, _valueInstantiators);
}
Expand Down Expand Up @@ -162,8 +162,8 @@ public Iterable<KeyDeserializers> keyDeserializers() {
return new ArrayIterator<KeyDeserializers>(_additionalKeyDeserializers);
}

public Iterable<BeanDeserializerModifier> deserializerModifiers() {
return new ArrayIterator<BeanDeserializerModifier>(_modifiers);
public Iterable<ValueDeserializerModifier> deserializerModifiers() {
return new ArrayIterator<ValueDeserializerModifier>(_modifiers);
}

public Iterable<ValueInstantiators> valueInstantiators() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.fasterxml.jackson.databind.JacksonModule.SetupContext;
import com.fasterxml.jackson.databind.deser.*;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import com.fasterxml.jackson.databind.ser.ValueSerializerModifier;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.fasterxml.jackson.databind.type.TypeFactory;
Expand Down Expand Up @@ -141,7 +141,7 @@ public SetupContext addKeyDeserializers(KeyDeserializers kd) {
}

@Override
public SetupContext addDeserializerModifier(BeanDeserializerModifier modifier) {
public SetupContext addDeserializerModifier(ValueDeserializerModifier modifier) {
_set(_deserializerFactory().withDeserializerModifier(modifier));
return this;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public SetupContext addKeySerializers(Serializers s) {
}

@Override
public SetupContext addSerializerModifier(BeanSerializerModifier modifier) {
public SetupContext addSerializerModifier(ValueSerializerModifier modifier) {
_set(_serializerFactory().withSerializerModifier(modifier));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class SerializerFactoryConfig
*/
protected final static Serializers[] NO_SERIALIZERS = new Serializers[0];

protected final static BeanSerializerModifier[] NO_MODIFIERS = new BeanSerializerModifier[0];
protected final static ValueSerializerModifier[] NO_MODIFIERS = new ValueSerializerModifier[0];

/**
* List of providers for additional serializers, checked before considering default
Expand All @@ -44,7 +44,7 @@ public final class SerializerFactoryConfig
* List of modifiers that can change the way {@link BeanSerializer} instances
* are configured and constructed.
*/
protected final BeanSerializerModifier[] _modifiers;
protected final ValueSerializerModifier[] _modifiers;

/**
* Serializer used to output a null value, unless explicitly redefined for property.
Expand All @@ -65,7 +65,7 @@ public SerializerFactoryConfig() {

protected SerializerFactoryConfig(Serializers[] allAdditionalSerializers,
Serializers[] allAdditionalKeySerializers,
BeanSerializerModifier[] modifiers,
ValueSerializerModifier[] modifiers,
JsonSerializer<Object> nullKeySer,
JsonSerializer<Object> nullValueSer)
{
Expand Down Expand Up @@ -94,10 +94,10 @@ public SerializerFactoryConfig withAdditionalKeySerializers(Serializers addition
_nullKeySerializer, _nullValueSerializer);
}

public SerializerFactoryConfig withSerializerModifier(BeanSerializerModifier modifier)
public SerializerFactoryConfig withSerializerModifier(ValueSerializerModifier modifier)
{
Objects.requireNonNull(modifier, "Cannot pass null BeanSerializerModifier");
BeanSerializerModifier[] modifiers = ArrayBuilders.insertInListNoDup(_modifiers, modifier);
Objects.requireNonNull(modifier, "Cannot pass null ValueSerializerModifier");
ValueSerializerModifier[] modifiers = ArrayBuilders.insertInListNoDup(_modifiers, modifier);
return new SerializerFactoryConfig(_additionalSerializers, _additionalKeySerializers, modifiers,
_nullKeySerializer, _nullValueSerializer);
}
Expand All @@ -122,7 +122,7 @@ public SerializerFactoryConfig withNullKeySerializer(JsonSerializer<?> nks) {

public Iterable<Serializers> serializers() { return new ArrayIterator<Serializers>(_additionalSerializers); }
public Iterable<Serializers> keySerializers() { return new ArrayIterator<Serializers>(_additionalKeySerializers); }
public Iterable<BeanSerializerModifier> serializerModifiers() { return new ArrayIterator<BeanSerializerModifier>(_modifiers); }
public Iterable<ValueSerializerModifier> serializerModifiers() { return new ArrayIterator<ValueSerializerModifier>(_modifiers); }

public JsonSerializer<Object> getNullKeySerializer() { return _nullKeySerializer; }
public JsonSerializer<Object> getNullValueSerializer() { return _nullValueSerializer; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers

/**
* Convenience method for creating a new factory instance with additional
* {@link BeanDeserializerModifier}.
* {@link ValueDeserializerModifier}.
*/
@Override
public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier) {
public final DeserializerFactory withDeserializerModifier(ValueDeserializerModifier modifier) {
return withConfig(_factoryConfig.withDeserializerModifier(modifier));
}

Expand Down Expand Up @@ -1299,7 +1299,7 @@ public JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
}
// and then new with 2.2: ability to post-process it too (databind#120)
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyArrayDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext c
}
// allow post-processing it too
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyCollectionDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1432,7 +1432,7 @@ public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConte
if (deser != null) {
// and then new with 2.2: ability to post-process it too (Issue#120)
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyCollectionLikeDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1551,7 +1551,7 @@ public JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
}
}
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyMapDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1599,7 +1599,7 @@ public JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt
if (deser != null) {
// and then new with 2.2: ability to post-process it too (Issue#120)
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyMapLikeDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1667,7 +1667,7 @@ public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt,

// and then post-process it too
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyEnumDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1734,7 +1734,7 @@ public JsonDeserializer<?> createReferenceDeserializer(DeserializationContext ct
if (deser != null) {
// and then post-process
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyReferenceDeserializer(config, type, beanDesc, deser);
}
}
Expand Down Expand Up @@ -1798,7 +1798,7 @@ public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
// and then post-processing
if (deser != null) {
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyKeyDeserializer(config, type, deser);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ct
if (deser != null) {
// [databind#2392]
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyDeserializer(ctxt.getConfig(), beanDesc, deser);
}
}
Expand Down Expand Up @@ -181,7 +181,7 @@ protected JsonDeserializer<?> findStdDeserializer(DeserializationContext ctxt,
// Also: better ensure these are post-processable?
if (deser != null) {
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deser = mod.modifyDeserializer(ctxt.getConfig(), beanDesc, deser);
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public JsonDeserializer<Object> buildBeanDeserializer(DeserializationContext ctx

final DeserializationConfig config = ctxt.getConfig();
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
builder = mod.updateBuilder(config, beanDesc, builder);
}
}
Expand All @@ -289,7 +289,7 @@ public JsonDeserializer<Object> buildBeanDeserializer(DeserializationContext ctx
// may have modifier(s) that wants to modify or replace serializer we just built
// (note that `resolve()` and `createContextual()` called later on)
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deserializer = mod.modifyDeserializer(config, beanDesc, deserializer);
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ protected JsonDeserializer<Object> buildBuilderBasedDeserializer(
builder.setPOJOBuilder(buildMethod, builderConfig);
// this may give us more information...
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
builder = mod.updateBuilder(config, builderDesc, builder);
}
}
Expand All @@ -355,7 +355,7 @@ protected JsonDeserializer<Object> buildBuilderBasedDeserializer(

// [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built:
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deserializer = mod.modifyDeserializer(config, builderDesc, deserializer);
}
}
Expand Down Expand Up @@ -438,7 +438,7 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex

// update builder now that all information is in?
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
builder = mod.updateBuilder(config, beanDesc, builder);
}
}
Expand All @@ -453,7 +453,7 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex

// may have modifier(s) that wants to modify or replace serializer we just built:
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
deserializer = mod.modifyDeserializer(config, beanDesc, deserializer);
}
}
Expand Down Expand Up @@ -550,7 +550,7 @@ protected void addBeanProps(DeserializationContext ctxt,
beanDesc, builder, beanDesc.findProperties(), ignored, included);
// After which we can let custom code change the set
if (_factoryConfig.hasDeserializerModifiers()) {
for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public abstract boolean hasExplicitDeserializerFor(DatabindContext ctxt,

/**
* Convenience method for creating a new factory instance with additional
* {@link BeanDeserializerModifier}.
* {@link ValueDeserializerModifier}.
*/
public abstract DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier);
public abstract DeserializerFactory withDeserializerModifier(ValueDeserializerModifier modifier);

/**
* Convenience method for creating a new factory instance with additional
Expand Down
Loading

0 comments on commit 3db9730

Please sign in to comment.