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

Support handling of @JsonProperty.required for Creator methods #781

Closed
cowtowncoder opened this issue May 5, 2015 · 1 comment
Closed

Comments

@cowtowncoder
Copy link
Member

Currently required property of @JsonProperty is only provided as metadata, and used for creating things like JSON Schemas. Deserialization does not enforce required-ness due to technical difficulties; specifically, since JsonDeserializer instances can not have state (they are shared and need to be stateless), any state needs to be either stored in DeserializationContext somehow, or carried along as extra parameter throughout internal calls within BeanDeserializer.

However: handling of Creator methods is different in that state is already tracked: values of Creator parameters must be buffered, to be passed when everything has been collected. Adding bit of extra tracking and checking for required-ness should be much less work.

The initial implementation could just use required property; and once this works, additional functionality for per-creator/global-defaults (DeserializationFeature) may be considered as well.

@cowtowncoder
Copy link
Member Author

Implement this so that:

  1. Any creator property explicitly marked as required must be provided by content or injected via annotation
  2. If (new) DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES is enabled, all creator properties must be provided by content or injection

I did not yet add "requireAll" property for @JsonCreator, but addition should be easy if such is desired.

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