Wednesday, March 4, 2015

Project Lombok

Lombok  is a plugin that Java developers can use to save time and effort writing repeated code like one we see in data classes. I will describe it with examples and will include a link to video and the project site to download and try.

Consider the following data class Student which has some attributes and access to it Getters/Setters.


Too much code for a data class :-S

Look at Lombok and what it can do :-P


You can also control if you want only getters or setters using the @Getter and @Setter annotation before each attribute.


Now the code looks more pretty and readable as a data class. It has lots of other useful annotations that will save you lots of repeated code.

For example you can look at the @Cleanup annotation and what it does.

References: