You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might sound counter-intuitive given that even though Java records are immutable by their very definition, I want to use @Value.Immutable annotation with them. That's because one delightful feature that @Value.Immutable annotation provides for conventional Java interfaces and abstract classes is the builder-methods that enable graceful object construction, especially DTOs within multiple fields including several Optionals
Presently to use builder-pattern with Java records, we have 3 paths as per this article
Hand-written Builder class nested within Java record class
Lombok (no, please no)
This small RecordBuilder library of which I'm sceptical as to how long would it be supported by community (plus it also offers several customizations around pure / simple builders that i'm not too keen about & don't want those unnecessary loopholes in my project)
So then are there any plans to support @Value.Immutable annotation for Java records and by when?
The text was updated successfully, but these errors were encountered:
We're planning to add quite full support for records. Most probably it will be Immutables 3 . But there's the way now, using @Builder.Constructor annotation on a compact constructor. @Builder.Constructor was originally was created to support free-form objects/pojo constructors.
See #1285 for the details, in particular, here's the example (#1285 (comment))
record
s are immutable by their very definition, I want to use@Value.Immutable
annotation with them. That's because one delightful feature that@Value.Immutable
annotation provides for conventional Javainterface
s andabstract class
es is the builder-methods that enable graceful object construction, especially DTOs within multiple fields including severalOptional
srecord
classSo then are there any plans to support
@Value.Immutable
annotation for Javarecord
s and by when?The text was updated successfully, but these errors were encountered: