In Lombok, what is the difference between @AllArgsConstructor and @RequiredArgsConstructor?

In short, use @AllArgsConstructor to generate a constructor for all of your class’s fields and use @RequiredArgsConstructor to generate a constructor for all class’s fields that are marked as final.

From the documentation,

@AllArgsConstructor generates a constructor with 1 parameter for each field in your class.

@RequiredArgsConstructor generates a constructor with 1 parameter for each field that requires special handling. All non-initialized final fields get a parameter, as well as any fields that are marked as @NonNull that aren’t initialized where they are declared.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)