Does the Project Lombok @Data annotation create a constructor of any kind?

JoseHdez_2 picture JoseHdez_2 · Feb 1, 2017 · Viewed 39.3k times · Source

I have a class with a @Data annotation, but I'm not sure whether a constructor with arguments is generated or the only generated constructor is the default (no arguments) one from vanilla Java.

Answer

JoseHdez_2 picture JoseHdez_2 · Feb 1, 2017

A @RequiredArgsConstructor will be generated if no constructor has been defined.

The Project Lombok @Data page explains:

@Data is like having implicit @Getter, @Setter, @ToString, @EqualsAndHashCode and @RequiredArgsConstructor annotations on the class (except that no constructor will be generated if any explicitly written constructor exists).