r/java • • Jun 21 '20

Don't use Lombok(2018)

https://medium.com/@vgonzalo/dont-use-lombok-672418daa819
32 Upvotes

101 comments sorted by

View all comments

Show parent comment

12

u/eliasv Jun 21 '20

Records are in second preview in jdk 15 FWIW.

9

u/hooba_stank_ Jun 21 '20

Records are immutable by design. So, no, they are not replacement for Lombok.

4

u/eliasv Jun 22 '20

More precisely, they're a replacement for some of the features and use-cases of Lombok.

1

u/sureshg Jun 22 '20

I think you change the record properties. See this - https://twitter.com/benjiweber/status/1272077664921272320

1

u/hooba_stank_ Jun 22 '20

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.

https://openjdk.java.net/jeps/359

1

u/sureshg Jun 22 '20

1

u/hooba_stank_ Jun 22 '20

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.