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