Do you feel lazy every time you declared the Java Bean with Getter and Setter method? Do you feel boring when working with boilerplate code in Java? If all answers are yes, let consider to use Project Lombok. It can help you avoid these problems.

So, what is Project Lombok?

Introduction about Project Lombok

Project Lombok is a tool that can generate code for us, but not in the way the IDEs did. Our IDEs generate Getter, Setter, Equals and more methods then put them into the .java file. Project Lombok does the same thing but does it in .class file. All we need to do, that is, add some annotations like @Getter, @Setter, @Builder,… into our code and Project Lombok will generate Getter, Setter and so on for us. You can override the thing you don’t need to generate it automatically.

Because Project Lombok generates code at compile time into .class file, so, to make our IDEs can understand the code at writing time, we must add Lombok plugin into our IDEs.

See how to install Project Lombok plugin in IntelliJ IDEA.

Let take some basic examples about Project Lombok:

In this tutorial, I will show you some instructions how to deal with Getter, Setter and constructors with Project Lombok.

In this tutorial, I will show you how to generate toString(), equals() and hashCode() method automatically with Project Lombok.

Using @Data annotation in Project Lombok, you can avoid to declare Getter, Setter, toString(), equals() and hashCode() method.

In this tutorial, by using @Builder annotation, we can apply Builder Pattern for our objects.

In this tutorial, I will show you how to generate Logger object automatically with Project Lombok.

In this tutorial, I will show you another way to close a resource automatically with Project Lombok.

In this tutorial, I will show you an alternative way to use synchronized keyword in Java with Project Lombok.

Introduction about Project Lombok
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
7Share on Google+
Google+
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.