-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow overriding builder's "withPrefix" with new @JsonDeserialize
property
#2624
Comments
Sounds like a reasonable idea, and I think I know the mechanism it should use (since I prefer not adding one-off configuration methods if at all possible: "config overrides". I don't know which version this would go in -- 2.11 is not yet out, but not sure I have time to add it there, as I am hoping to wrap it up. But this could probably work out nicely for 2.12. |
FWIW the Lombok team have implemented a |
@kennethjor Interesting. Thank you for sharing! |
Ok, with #2800, there now IS a way to, I think, configure builder-"with" prefix, using new
or, if you want something more complicated (multiple prefixes, or different naming convention), |
Added a test to verify that case above (no/empty prefix) works as expected. But I think I will leave this open as addition of an annotation in |
@JsonDeserialize
property
It would be nice to be able to configure the builder method name prefix Jackson uses either globally through a configuration on
ObjectMapper
or through the@JsonDeserialize
annotation itself. I'm currently using Lombok to generate my builders for me and to make it work nicely with Jackson I have to write boilerplate code, which is the whole point of lombok.The Problem
Currently, in order to use Jackson and lombok in tandem, I have to write a model class like this:
The issue becomes even worse if using the
@SuperBuilder
annotation:There's also a blurb about the workaround in Lombok's own documentation.
Related issue: https://github.com/FasterXML/jackson-databind/issues/1997
Global Config
One way to fix it would be to allow this to be configured globally on
ObjectMapper
like:JsonDeserialize Property
Another solution would be to allow it to be set on the
@JsonDeserialize
annotation itself, like:Personally, I prefer option 2.
The text was updated successfully, but these errors were encountered: