Builder design pattern for Address class - with defaults.
This commit is contained in:
parent
36d31c8e6f
commit
df2161b1af
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user