jackson-databind
jackson-databind copied to clipboard
Allow @JsonAnySetter on Creator constructors
resolves #562
Impressive. I am bit hesitant to consider this as one more thing before work on Property Introspection rewrite, but no harm in figuring out how this could work. Added some notes.
Impressive. I am bit hesitant to consider this as one more thing before work on Property Introspection rewrite,
I concur. And also in the issue #562, this feature is to get included in 3.x.
So I think we can safely consider this feature only after Property Introspection rewrite.
but no harm in figuring out how this could work. Added some notes.
Thankssss! I will keep them updated
Cool, this is much improved. I'll make tiny changes, wrt suggestions I added.
@JooHyukKim Ok, I made a few changes that I think help, including validation that only one "any-setter" is specified.
I was also wondering if it wouldn't make sense to add knowledge of "any-setter" creator property directly into PropertyValueBuffer
(make it take SettableAnyProperty
).
Also I think validation wrt DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES
need to be able to skip check for placeholder there.
I was also wondering if it wouldn't make sense to add knowledge of "any-setter" creator property directly into PropertyValueBuffer (make it take SettableAnyProperty).
Do you mean do the PropertyValueBuffer
construction with anySetter in it in the first place, in earlier part of _deserializeUsingPropertyBased
? If so, sounds like an idea.
Also I think validation wrt DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES need to be able to skip check for placeholder there.
Placeholder? 🤔 Could u elaborate a bit more?
I was also wondering if it wouldn't make sense to add knowledge of "any-setter" creator property directly into PropertyValueBuffer (make it take SettableAnyProperty).
Do you mean do the
PropertyValueBuffer
construction with anySetter in it in the first place, in earlier part of_deserializeUsingPropertyBased
? If so, sounds like an idea.
Right.
Also I think validation wrt DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES need to be able to skip check for placeholder there.
Placeholder? 🤔 Could u elaborate a bit more?
What I mean is to test to see that if this setting is enabled, it will not cause failure since property that represents "any-setter" has no associated value. So by placeholder I meant constructor parameter that is not a "real" parameter, similar to how injectable value isn't required to come from input.
I was also wondering if it wouldn't make sense to add knowledge of "any-setter" creator property directly into PropertyValueBuffer (make it take SettableAnyProperty).
cc/ @cowtowncoder Implemented as suggested in commit https://github.com/FasterXML/jackson-databind/pull/4366/commits/8612433174444c364f704fa6a82c802baba3f959. Apologies in advance for formatter taking up large portion.
IMO, this new version seems more appropriate in that we don't handle values twice --first buffering in PropertyValueBuffer then transfer to map for AnySetter parameter.