A Practical Guide to Project Lombok

A Practical Guide to Project Lombok

Java is a powerful language but often criticized for being too verbose (aka boilerplate – term used to describe code that is repeated in many parts of an application with little alteration). Project Lombok came to help the lazy coder in you. It basically generates code for you. But instead of adding code to your non-compiled classes, like an IDE generally does, Lombok works during the build process by modifying the Java bytecode of your class files.

It’s very simple to configure it, their project page has all you need to help you to add it in your projects.

Lombok Annotations

1. @Getter and @Setter

The @Getter and @Setter annotations are used to generate accessor methods for fields, @Getter annotation respects the convention if the field is a boolean property. Both @Getter and @Setter take an optional parameter to specify the access level for the generated method:

Lombok code:

Equivalent Java native code:

Continue reading »