DEV Community

davino
davino

Posted on

Lombok Library practices note

My Usage:

  1. Bean: @Builder, @NoArgsConstructor, @Setter, @Getter, @Data
  2. Service/Component: @Slf4j, @RequiredArgsConstructor

Because I heavily use JSON in my application, I generally need a no-args constructor in the beans.


Notes:

  • @Builder can't work with only @NoArgsConstructor; it also requires @AllArgsConstructor.
  • @SuperBuilder works only with @NoArgsConstructor and without @AllArgsConstructor.
  • Using @Builder on a superclass and @SuperBuilder on the subclass works, but only the superclass instance is built.

Best Practices:

  • Prefer @SuperBuilder over @Builder when working with inheritance.

Top comments (0)