I was looking for ways to reduce my class LOC. most of the time, setters and getters lengthens my code length and gives me a hard time to look at the important parts of it. so I decided to on a journey to reduce my boilerplate code.
During this quest, I found . Project Lombok.
In a nutshell project lombok replaces your common java boilerplate code with a simple annotations.
One of the things I like about Project Lombok is their
it shortens your class LOC, say good bye to those (getBar(),setBar(String bar))
Installation In Eclipse.
Adding the jar the alone is not enough for lombok to work. what we need to do is.
is to ‘Install’ Lombok.
java -jar lombok.jar
We run this command in our CMD, make sure that when you are going to run/execute lombok.jar, make you are in the directory on where it is located. upon running that command a screen will show up.
Right after that check your IDE’s .ini file or configuration file. the following parameters should be added (below -vmargs for Eclipse)
Once it is done. we can now already add lombok.jar in our projects.
A Simple Example Using Lombok.
here’s a simple example of Lombok (taken from my personal project)
As you can see on our Outline, the Annotations
@Setter created the setters and getters for our class instance variables.
Other Concerns And references:
I just found out that they have support for IntelliJ Idea. Checkout the plugin here