top of page
Search
Writer's pictureNina Koninckx

Records and builders

Welcome to our quick guide on records and builders in pure Java.


Since Java 14 we can make records instead of having to do a lot of boilerplate code to create entities or data transfer objects.

Because of this a lot of us are phasing out Lombok, but what about our builders?


I have made a simple IntelliJ Live Template to make this transition as smooth as possible, you can find the template underneath with screenshots and a quick explanation:


First you will have to put the Live Template into IntelliJ using the settings seen in the screenshot below.

To get to this screen you have to go to **File>Settings>Editor>Live Templates** and click the '+' icon and select Live Template.





Template in text form for easy copying and pasting:



After you have added the template and selected it to be applicable in Java you will have it at your disposal at all times by typing your chosen abbreviation. Below you can see a short gif that shows how to best apply it:






Your final result is a record class with a lombok style builder, which can be used in the same way calling Foo.builder().build();


I hope you enjoyed this quick guide and will enjoy using this in the future.


57 views0 comments

Comments


Post: Blog2_Post
bottom of page