Skip to content

Commit e87a739

Browse files
committed
Simplify code with 2.7
1 parent 4547eaf commit e87a739

File tree

3 files changed

+7
-44
lines changed

3 files changed

+7
-44
lines changed

src/main/java/com/fasterxml/jackson/datatype/jdk8/Jdk8OptionalBeanPropertyWriter.java

+3-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
import java.util.Optional;
1010

11-
public class Jdk8OptionalBeanPropertyWriter extends BeanPropertyWriter {
11+
public class Jdk8OptionalBeanPropertyWriter extends BeanPropertyWriter
12+
{
13+
private static final long serialVersionUID = 1L;
1214

1315
protected Jdk8OptionalBeanPropertyWriter(BeanPropertyWriter base) {
1416
super(base);
@@ -18,18 +20,7 @@ protected Jdk8OptionalBeanPropertyWriter(BeanPropertyWriter base, PropertyName n
1820
super(base, newName);
1921
}
2022

21-
// !!! TODO: in 2.7, no need to override
2223
@Override
23-
public BeanPropertyWriter rename(NameTransformer transformer) {
24-
String newName = transformer.transform(_name.getValue());
25-
if (newName.equals(_name.toString())) {
26-
return this;
27-
}
28-
return _new(PropertyName.construct(newName));
29-
}
30-
31-
// NOTE:
32-
// @Override
3324
protected BeanPropertyWriter _new(PropertyName newName) {
3425
return new Jdk8OptionalBeanPropertyWriter(this, newName);
3526
}

src/main/java/com/fasterxml/jackson/datatype/jdk8/Jdk8UnwrappingOptionalBeanPropertyWriter.java

+3-17
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,19 @@
1111

1212
public class Jdk8UnwrappingOptionalBeanPropertyWriter extends UnwrappingBeanPropertyWriter
1313
{
14+
private static final long serialVersionUID = 1L;
15+
1416
public Jdk8UnwrappingOptionalBeanPropertyWriter(BeanPropertyWriter base,
1517
NameTransformer transformer) {
1618
super(base, transformer);
1719
}
1820

1921
protected Jdk8UnwrappingOptionalBeanPropertyWriter(UnwrappingBeanPropertyWriter base,
2022
NameTransformer transformer, SerializedString name) {
21-
// TODO: in 2.7 call this ctor instead:
22-
// super(base, transformer, name);
23-
super(base, transformer);
23+
super(base, transformer, name);
2424
}
2525

26-
// TODO: In 2.7, should not need to override this method, just _new(...)
2726
@Override
28-
public UnwrappingBeanPropertyWriter rename(NameTransformer transformer)
29-
{
30-
String oldName = _name.getValue();
31-
String newName = transformer.transform(oldName);
32-
33-
// important: combine transformers:
34-
transformer = NameTransformer.chainedTransformer(transformer, _nameTransformer);
35-
36-
return _new(transformer, new SerializedString(newName));
37-
}
38-
39-
// NOTE: was added in one of later 2.6.0 RCs; uncomment once available
40-
// @Override
4127
protected UnwrappingBeanPropertyWriter _new(NameTransformer transformer, SerializedString newName)
4228
{
4329
return new Jdk8UnwrappingOptionalBeanPropertyWriter(this, transformer, newName);

src/main/java/com/fasterxml/jackson/datatype/jdk8/OptionalDeserializer.java

+1-15
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import com.fasterxml.jackson.core.JsonParser;
77
import com.fasterxml.jackson.core.JsonToken;
8+
89
import com.fasterxml.jackson.databind.*;
910
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
1011
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
11-
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
1212
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
1313

1414
final class OptionalDeserializer
@@ -74,20 +74,6 @@ public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
7474
JavaType refType = _referenceType;
7575

7676
if (deser == null) {
77-
// 08-Oct-2015, tatu: As per [datatype-jdk8#13], need to use type
78-
// override, if any
79-
if (property != null) {
80-
AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
81-
AnnotatedMember member = property.getMember();
82-
if ((intr != null) && (member != null)) {
83-
Class<?> cc = intr.findDeserializationContentType(member, refType);
84-
if ((cc != null) && !refType.hasRawClass(cc)) {
85-
// 08-Oct-2015, tatu: One open question is whether we should also
86-
// modify "full type"; seems like it's not needed quite yet
87-
refType = refType.narrowBy(cc);
88-
}
89-
}
90-
}
9177
deser = ctxt.findContextualValueDeserializer(refType, property);
9278
} else { // otherwise directly assigned, probably not contextual yet:
9379
deser = ctxt.handleSecondaryContextualization(deser, property, refType);

0 commit comments

Comments
 (0)