Lombok

What is Lombok?

: A library that allows you to easily generate boilerplate code such as Constructors, Getters/Setters, toString(), etc. through annotations when creating Model Objects like DTOs, VOs, Entities in Java

Of course, you can easily generate them using the auto-generation feature of IDEs like Eclipse, but if a variable name changes, you have to update the corresponding functions like getters/setters as well, which is inconvenient

-> Lombok annotations solve this inconvenience

How to Use

- @Data

​ : Generates all the annotations listed below at once - @ToString

​ : Generates a toString() method that prints all fields - @Getter

​ : Generates Getter methods - @Setter

​ : Generates Setter methods - @EqualsAndHashCode

​ : Generates equals & hashcode methods - @NoArgsConstructor

​ : Generates a constructor with no arguments

- @RequiredArgsConstructor

​ : Generates a constructor with only required arguments

- @AllArgsConstructor

​ : Generates a constructor with all arguments

Usage Example

Last updated