Unfortunately I don't think this approach will work due to overhead being added: just looking at code it would make all existing usage measurably slower. And for case where there are actually required properties there's even more due to construction and management of the Map. There are other challenges like there being multiple code paths (this seems to cover just one), both for builder-based properties vs "simple" beans, and various alternative implementations for both, but I think that's what you mean by completing the approach.
What I would like to see from performance perspective is something more along the lines of what is done with creator properties. It is possible to use bit sets for tracking properties for which value is found (these are fixed-length, lower memory and cpu overhead). But they still need to be checked from multiple places; and possibly data structure used needs to be passed across method calls. In addition, performance testing would be needed to make sure that in cases where none of properties are required, there is no measurable overhead. Having said all that I think it would be great to efficient support required-ness checks, so I appreciate your doing the work and proposing changes. -+ Tatu +- On Fri, Aug 12, 2016 at 6:46 AM, Hélder Sousa <[email protected]> wrote: > Hi > > I found the issues #858 > <https://github.com/FasterXML/jackson-databind/issues/858> and #869 > <https://github.com/FasterXML/jackson-databind/issues/869> in GitHub > Issues tracker regarding the required attribute. I understand the current > code works only for creator parameters, as per the example provided > by operatiay in #869 > > public class MyObject { > String req; > > String opt; > > @JsonCreator > public MyObject( > @JsonProperty(required = true, value="req") String req, > @JsonProperty(required = false, value="opt") String opt) { > this.req = req; > this.opt = opt; > } > } > > > I may be oversimplifying the implementation, but I added basic support for > the original request by operatiay: > > public class MyObject { > @JsonProperty(required=true) > String req; > > @JsonProperty > String opt; > } > > > Tatu, can you check my implementation in this commit db0d690 > <https://github.com/htmsousa/jackson-databind/commit/db0d690371ca9cf116c285e03027c00e4b3b3113> > and > maybe provide some feedback. I can improve this implementation and maybe > apply it to other deserializers and do a pull request. What do you think? > > ps. sorry if this topic is duplicated but I can't see my previous post in > the group. > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
