장의 ‘단계별 생성’에서 소개된 빌더 패턴은 복제 생성자를 도입하여 변경을 보다 쉽게 관리
할 수 있습니다. 이러한 생성자를 사용하고 기존 레코드로 빌더를 초기화한 후, 필요한 변경
을 수행하고 새로운 레코드를 생성할 수 있습니다.
public record Point
(
int x
,
int y
)
{
public static final class Builder
{
private int x
;
private int y
;
public Builder
(
Point point
)
{
this
.
x
=
point
.
x
();
this
.
y
=
point ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.