In Lombok and in @AllArgsConstructor annotation you can use final keyword to make sure that object will not change after initialization in constructor. This annotation will get all fields to build your constructor.
There is also @RequiredArgsConstructor annotation which is using fields marked with final to build constructor:
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class Person {
private final String firstName;
private final String middleName;
private String lastName;
}
An you constructor will look like this after delombok:
@java.beans.ConstructorProperties({"firstName", "middleName"})
private Person(String firstName, String middleName) {
this.firstName = firstName;
this.middleName = middleName;
}