Details
-
Type:
New Feature
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7
-
Fix Version/s: 2.0.0
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
(suggested by Dain the awesome)
—
In addition to existing ways of using @JsonCreator, there is one obvious way to further improve support for deserializing immutable objects. While constructor-based deserialization works correctly, it becomes unwieldy when number of properties grows. One good way to get around this would be to support builder-style, in which a builder type has "setters" to call, which return an instance of builder (which may be the same builder or a new instance); and once all data has been passed, a build method is called to produce actual value instance.
To do this, couple of things need to be added; for example:
- A mechanism to indicate which builder type to use for building value types; can probably just add either a new annotation (@JsonBuild?) or add a property to @JsonDeserialize (.usingBuilder=MyBuilder.class). Since this is resolved using AnnotationIntrospector, it will be extensible for custom mechanisms as well (including non-annotation-based extensions)
- A way to indicate "build" method (@JsonBuildMethod?)
- Possibly ability to support setter-like methods with different naming convention? (I like withXxx naming convention, but I have no idea if anyone else uses things other than setXxx)
I may be missing other pieces, but at least above need to be considered.