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 @DefaultValue to be used on record components #29010
Conversation
@An1s9n Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@An1s9n Thank you for signing the Contributor License Agreement! |
Hi! How often do you organise team meetings? :) |
@An1s9n we've just discussed this in a team meeting. While we think it could be an interesting addition for Lombok users, we don't think that adding field+method targets for this annotation is worth it, since it will let most Java users in a position where they can use it in an invalid arrangement. The record component target is valuable for all Spring Boot users and we'd like to implement this. Would you like to amend your PR with the following?
Since this requires more work here and this won't address the Lombok use case, feel free to let us know if you don't feel like tackling this issue. Thanks! |
@bclozel, hi! Yes, I'd like to amend my PR as you described, because I want to contribute to Spring Boot hah :)) I'll try to do it asap. |
@bclozel, I've done what you've asked me for :) Let me know if something else is required - I'll fix it |
I am not sure that the annotation processor would handle such use of |
@snicoll, you mean meta-data generation, am I right? |
…esWithDefaultValues
@snicoll, luckily it works just perfect without any additional changes! :) I've added a unit test for such a case. |
This is targeted at 2.7.x where we compile using Java 8 but |
I think we should move this to 3.0 given the amount of work it will take to get our build to produce a multi-release jar. |
Thanks very much, @An1s9n. |
Since merging these changes, we've learned that they weren't actually necessary. The existing |
#30460 has updated the docs to describe our record support with |
It would be useful to have ability to use
@DefaultValue
annotation with records and Lombok's auto-generated constructors. I've made small code changes in spring-boot, which provide such an ability.I've created a sample project which shows desired usage, please see source code and test in this public repo: https://github.com/An1s9n/spring-boot-sample.
In case of any questions, feel free to contact me, preferred (and fastest as well) way is Telegram: https://t.me/An1s9n.