10
10
/**
11
11
* {@link SettableBeanProperty} implementation that will try to access value of
12
12
* the property first, and if non-null value found, pass that for update
13
- * (using {@link com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, Object)}
14
- * ) instead of constructing a new value. This is necessary to support "merging" properties.
13
+ * (using {@link com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, Object)})
14
+ * instead of constructing a new value. This is necessary to support "merging" properties.
15
+ *<p>
16
+ * Note that there are many similarities to {@link SetterlessProperty}, which predates
17
+ * this variant; and that one is even used in cases where there is no mutator
18
+ * available.
15
19
*
16
20
* @since 2.9
17
21
*/
@@ -76,7 +80,11 @@ public void deserializeAndSet(JsonParser p, DeserializationContext ctxt,
76
80
newValue = delegate .deserializeWith (p , ctxt , oldValue );
77
81
}
78
82
if (newValue != oldValue ) {
79
- delegate .set (instance , newValue );
83
+ // 31-Oct-2016, tatu: Basically should just ignore as null can't really
84
+ // contribute to merging.
85
+ if (newValue != null ) {
86
+ delegate .set (instance , newValue );
87
+ }
80
88
}
81
89
}
82
90
@@ -97,20 +105,31 @@ public Object deserializeSetAndReturn(JsonParser p,
97
105
// try calling setter on builder? Presumably should not be required,
98
106
// but may need to revise
99
107
if (newValue != oldValue ) {
100
- return delegate .setAndReturn (instance , newValue );
108
+ // 31-Oct-2016, tatu: Basically should just ignore as null can't really
109
+ // contribute to merging.
110
+ if (newValue != null ) {
111
+ return delegate .setAndReturn (instance , newValue );
112
+ }
101
113
}
102
114
return instance ;
103
115
}
104
116
105
117
@ Override
106
118
public void set (Object instance , Object value ) throws IOException {
107
- delegate .set (instance , value );
119
+ // 31-Oct-2016, tatu: Basically should just ignore as null can't really
120
+ // contribute to merging.
121
+ if (value != null ) {
122
+ delegate .set (instance , value );
123
+ }
108
124
}
109
125
110
126
@ Override
111
- public Object setAndReturn (Object instance , Object value )
112
- throws IOException
113
- {
114
- return delegate .setAndReturn (instance , value );
127
+ public Object setAndReturn (Object instance , Object value ) throws IOException {
128
+ // 31-Oct-2016, tatu: Basically should just ignore as null can't really
129
+ // contribute to merging.
130
+ if (value != null ) {
131
+ return delegate .setAndReturn (instance , value );
132
+ }
133
+ return instance ;
115
134
}
116
135
}
0 commit comments