Post fix
It works again!
@Builder
public record MyRecord(String myField) {
}
Pre fix
It was a known IntelliJ bug. There was, however, a workaround:
public record MyRecord(String myField) {
@Builder public MyRecord {}
}
Important: Once you insert the @builder inside the record, you must remove the @builder above it
Post fix
It works again!
@Builder
public record MyRecord(String myField) {
}
Pre fix
It was a known IntelliJ bug. There was, however, a workaround:
public record MyRecord(String myField) {
@Builder public MyRecord {}
}
Important: Once you insert the @builder inside the record, you must remove the @builder above it
According to this, records are supported from Lombok version v1.18.20
@Builderon records is supported since the last release v1.18.20. Which version are you using?Note that this may also be just an IDE issue. If you are using IntelliJ, it may not be supported, yet.
Probably an IntelliJ issue. Try writing the code without IntelliJ auto-complete, see if it compiles. If it does, it's an IntelliJ issue; if it does not, something is wrong with your code.
Records and @Builder
[BUG] `@Builder` not working as expected with Java records
Why Java's Records Are Better* Than Lombok's @Data and Kotlin's Data Classes
Record Success Stories
Videos
Is it worth using the Builder pattern with Java Records, or does it defeat the purpose of using Records in the first place? I'm trying to decide if I should combine these two, especially for scenarios where I have optional fields. Any advice or best practices?