From the course: Learning Lombok: Streamlined Java Programming

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

JEP 359 record versus @Data and @Value

JEP 359 record versus @Data and @Value - Spring Tutorial

From the course: Learning Lombok: Streamlined Java Programming

JEP 359 record versus @Data and @Value

- [Instructor] It's been a common complaint with Java that it is too verbose or involves too much ceremony, especially for simple data carriers. Most protests are over boilerplate code involved with creating constructors, equals, hashCode, toString, and accessor methods. Okay, I mean that's what Lombok is meant to address, right, with the immutable Data annotation and immutable @Value annotation. Well, it appears that the JCP has caught on to all of the complaints and provided an initial answer to this back in preview release with JEP 359 for JDK 14. By making available an immutable Data carrier class, a type called the Record. JEP 384 provided a second preview in JDK 15, and this has now been finalized in JEP 395 with JDK 16. Well, does this mean that learning Lombok is a waste? No. The Record class only answers a limited use case, whereas Lombok provides solutions for many different scenarios. So one might ask, what are the…

Contents