What is Project Lombok

Lombok is a java library that is used to cut down repetitive and boiler plate code from applications.

This boiler plate code includes:
1. Getter and Setter methods of class fields or instance variables.
2. Constructors.
3. toString() method.
4. Overriding equals() and hashCode() methods.
5. Calling close() on database connection or file streams.
6. Using synchronized keyword to make methods thread safe.
7. Creating logger objects(log4j, Slf4j) for logging.
8. Adding  builder pattern support to create class objects.

With lombok, you can add all these using annotations. Yes, you read that right !!.

If lombok is added to your project, there is no need to manually create getter/setter methods, constructors and all those listed above.
These will be automatically taken care of by lombok library.

Lombok documentation states

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.

In this easy to understand lombok tutorial, you will learn everything right from setting up lombok in your projects to using its features with examples.

Before moving further, first let’s install lombok in your favorite IDE and project.

Liked the article ? Spread the word...