@Builder
개념
...
public static class StudentBuilder {
private String name;
private int age;
StudentBuilder() {
}
public StudentBuilder name(String name) {
this.name = name;
return this;
}
public StudentBuilder age(int age) {
this.age = age;
return this;
}
public Student build() {
return new Student(name, age);
}
public String toString() {
return "Student.StudentBuilder(name=" + this.name + ", age=" + this.age + ")";
}
}
...특징
@Builder.Default
GOF 빌더 패턴과 다른 점

출처
Last updated