Builder design pattern for Address class - with defaults.

This commit is contained in:
Paweł Dyda 2022-10-25 20:02:48 +02:00
parent 36d31c8e6f
commit df2161b1af

View File

@ -2,12 +2,20 @@ package pl.amu.edu.demo.data;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.experimental.FieldDefaults;
@AllArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true)
@Builder(builderClassName = "AddressBuilder", setterPrefix = "with")
public class Address {
String addressLine1;
String addressLine2;
String zipCode;
}
final class AddressBuilder {
String addressLine1;
String addressLine2 = null;
String zipCode;
}