Java is a great language but more than often we have to write lots of boiler plate code to get the project started. These include writing getter methods, setter methods, constructors etc. Also, maintaining these classes is an ongoing process, example if you have to add or change a member variable to a class, you must remember to add corresponding setter and getter.
Lombok is a Java library that takes care of generating lot of this boiler plate code for the developers.
Lombok works by plugging into your build process and hooking into Java byte-code generation stage to add required code based on your specifications. Lombok uses annotations to identify which piece of code needs to be auto generated.
As per official definition:
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.
Lombok provides plugins for most of the major Java IDEs to support development.
Tutorials:
- Auto generate Setters and Getters in Java Objects using Lombok
- Auto generate constructors in Java object using Lombok
- Immutable Java class using Lombok
- Declare final local variables in Java using Lombok
- How to override Builder methods of Lombok in Java
- How to override methods of SuperBuilder of Lombok in Java
- Adding Custom Validation in Lombok Builder
- Lombok with Spring Boot
Comments
Post a Comment