NOT FOUND

lombok @Builder 특정 필드만 재정의하는 법 본문

카테고리 없음

lombok @Builder 특정 필드만 재정의하는 법

이종은 2025. 2. 17. 17:17

빌더에서 특정 필드를 재정의하는 걸 원했다

 

public static class ABuilder {
    public ABuilder owner(String owner) {
        this.isOwner = Objects.equals(owner, "소유자");
        return this;
    }

    public ABuilder landShare(String share) {
        this.isOwner = Objects.equals(share, "공유");
        return this;
    }
}

 

A class라고 쳤을 때 클래스 안에 이런식으로 ABuilder을 적고 아래 원하는 필드만 재정의해주면 된다