Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "merge" annotation, to use existing POJO/Map/Collection property value #1050

Closed
cowtowncoder opened this issue Dec 16, 2015 · 1 comment

Comments

@cowtowncoder
Copy link
Member

By default, Jackson will try to construct a new property value Object, regardless of its type, and for POJO/Map/Collection types add contents into that new Object. The main alternative would be to first check if property already has a value, and if so, use that value instead.
Currently such "merge" approach can only be used for 2 cases:

  1. For root value, via "updateValue()" for ObjectReader
  2. For Map/Collection values, if (and only if!) there is no setter method (or visible field)

It seems, however, that the ability to specify "merge" as the default approach (but fall back to new Object in case property is null) would be useful. This could be supported via annotation; either a new one, or perhaps additional property to an existing one (@JsonProperty(valueCreation=CREATE/MERGE/MERGE_ONLY))... or ideally something better).

If this can be made to work on per-property basis, we could perhaps also consider ability to specify global default (alternative to "always create").

@cowtowncoder cowtowncoder changed the title [2.8] Add support for "merge" annotation, to use existing POJO/Map/Collection property value Add support for "merge" annotation, to use existing POJO/Map/Collection property value Sep 30, 2016
@cowtowncoder cowtowncoder removed the 2.9 label Oct 5, 2016
@cowtowncoder
Copy link
Member Author

Seems like I have created dups... since #1399 is closer to my current values, keeping that as open, closing this as dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant