Official website : https://projectlombok.org/
- Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
- Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more can be done via lombok.
Intro to lombok :
- Project Lombok is a Java library tool that is used to minimize boilerplate code and save timeduring development.
- It is no doubt that Java is a great language, but recently, it is criticized by the community for one important reason — verbosity.
- Lombok generates code, for example, getters, setters, and
toString
, and the IDE does the same thing for us only it generates in our source code while Lombok generates it in the “.class” file directly.
Configure Eclipse for Lombok :
- Download the lombok jar from “https://projectlombok.org/download“
- Copy paste the jar into the eclipse installed folder
- Modify eclipse.ini file by adding below line at the end of eclipse
-javaagent:/home/tyson/programFiles/eclipse/jee-2019-06/eclipse/lombok.jar - Now clean and restart the eclipse
./eclipse -clean
If you are using gradle you just need to add one plugin for build process :
id "io.freefair.lombok" version "5.0.0-rc6"
Lombok Annotations :
Link : https://projectlombok.org/features/all
@Getter and @Setter
@ToString
@Builder
@Log4j, @Slf4j
@Synchronized
@NoArgsConstructor
@RequiredArgsConstructor
@Data
@Cleanup