A memo to check when you try to use Lombok

I tried to summarize various things about Lombok. It may be helpful when adopting it in a project.

A brief description of Lombok

What is Lombok? An open source library that simplifies Java-specific redundant code (boilerplate code). Just annotate, getter, setter, toString, equals, etc. "Code to be written over and over again" is automatically generated at compile time.

merit

--Boilerplate code can be removed from the code. --Accessor methods do not remain out of date when renaming fields. --The logic in the accessor method is not buried. --It is easy to get an appropriate value in the test coverage.

Disadvantages (Notes)

--There is a risk of becoming a circular reference with @ToString.
→ In that case, exclusion can be set with exclude.
Click here for details → StackOverflow when using Lombok-toString method --When changing the field name, the reference destination of the accessor method cannot be changed.
→ It is necessary to take measures such as changing from the automatically generated Getter / Setter of the IDE with the refactoring function.

Installation method

Eclipse: Download lombok.jar from the following site and execute it. https://projectlombok.org/download.html Specify the same directory as eclipse.exe in Specify Location and install / update.

NetBeans:

Below, how to write Maven.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.12</version>
    <scope>provided</scope>
</dependency>

Coding convention

Due to the nature of Lombok, it is possible to completely change the coding feeling so far. It's a good idea to use coding conventions when using it in your project. The annotations and classes that can be used are described below.

Dynamic typing

val list = new ArrayList \ (); // Immutable local variables