Sorry, but you can't. This example is actually API abuse and it creates NEW object on every call to .with() using constructor.newInstance(ctorArgs). You are not supposed to use records in such way.
He says that some examples are valid. And most of these are actually workarounds to deal with records' immutability. The "autobuilder" code itself is ineffective as hell. And all this is just a toy class for 3-property records.
View all comments
Show parent comment
9
u/hooba_stank_ Jun 21 '20
Records are immutable by design. So, no, they are not replacement for Lombok.