-
Notifications
You must be signed in to change notification settings - Fork 1
Lombok
Lombok is a popular Java library that provides a set of annotations that can help reduce boilerplate code in Java classes.
The annotations provided by Lombok can be used to generate common Java code, such as getter and setter methods, constructors, and hashCode/equals methods. By using these annotations, developers can focus more on the business logic of their code rather than writing repetitive code.
Some of the annotations provided by Lombok include @Getter and @Setter, which generate getter and setter methods for fields, @NoArgsConstructor and @AllArgsConstructor, which generate no-argument and all-argument constructors, and @ToString, which generates a toString method.
Lombok has gained popularity among Java developers due to its ability to reduce boilerplate code and make Java code more concise and readable.
If we're using Eclipse IDE, we need to get the Lombok jar first. The latest version is located on Maven Central Repository For our example, we're using lombok-1.18.4.jar.
Next, we can run the jar via java -jar command, and an installer UI will open. This tries to automatically detect all available Eclipse installations, but it's also possible to specify the location manually.
Once we've selected the installations, we press the Install/Update button
If the installation is successful, we can exit the installer.
After installing the plugin, we need to restart the IDE and ensure that Lombok is correctly configured.
The last remaining part is to ensure that Lombok binaries are on the compiler classpath. Using gradle, we can add the dependency to the build.gradle
`dependencies { compileOnly 'org.projectlombok:lombok:1.18.26' annotationProcessor 'org.projectlombok:lombok:1.18.26'
testCompileOnly 'org.projectlombok:lombok:1.18.26'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.26'
} `