On Tue, Jan 23, 2018 at 2:20 AM, 黄浪 <
res.w...@gmail.com> wrote:
> As far as I know, required in JsonProperty(value="xxx", required=true) only
> works in JsonCreator.
>
> But JsonMerge is not compatible with JsonCreator.
Correct: merge is meant for updating existing objects, and creators
are for creating new objects.
> Now I want to do with required fields and deep merge for object updating, is
> there a way to satisfy both?
If you mean that you would want to verify that even in merging case,
certain property is required for any update,
that is not supported. In future (3.x) required-checks may be
implemented for setters/fields as well, but even then
implementation with merge might be tricky... and it's complicated by
the fact that some use cases could prefer not
to apply requirements on merge case (to allow partial updates).
Your best bet as is would probably be to implement merge part
manually, within setter. Setter on existing
POJO would know its own state, be able to update it based on incoming
value created by Jackson.
-+ Tatu +-