Files
llm-wiki/raw/official-docs/lombok-builder-data-features-official.md

8.8 KiB

title, source_type, url, archive_url, related_branches, related_projects, tags, created
title source_type url archive_url related_branches related_projects tags created
official-doc / Lombok @Builder and @Data — Feature Reference (projectlombok.org) official-doc https://projectlombok.org/features/Builder
feature-architecture-enforcement-rules
ca-skeleton
official-doc
ca-skeleton
architecture
lombok
code-generation
domain-purity
clean-architecture
2026-05-28

official-doc / Lombok @Builder and @Data — Feature Reference (projectlombok.org)

Layer: raw/ — 외부 자료(공식 문서)의 원문 발췌·출처 기록. Primary URL: https://projectlombok.org/features/Builder (§Builder) Secondary URL: https://projectlombok.org/features/Data (§Data — 추가 인용) 검증된 요약은 /ingestwiki/concepts/source-summary-template 형식으로 별도 작성. 원본은 raw에 영구 보관.

Parent / 활용 branch (필수, 최소 1개+)

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-architecture-enforcement-rules domain-core Lombok 금지 결정(Option A) — @Builder·@Data 가 생성하는 inner class·생성자·setter가 framework-neutral POJO 요건과 충돌함을 공식 문서로 근거 삼음

출처 / Source

왜 저장했는지 / Why archived

ca-tmpl 의 domain-core 는 framework-neutral POJO 만 허용하는데, Lombok 정책이 architecture enforcement 명세에 없었다. @Builder 가 생성하는 inner static class, setter-like 메서드, 그리고 @Data 가 생성하는 @Setter 는 domain model 을 mutable 하게 만들거나 빌더 추상화를 통해 생성자 시그니처를 숨길 수 있다. Lombok 공식 문서가 이 생성 범위를 명시하므로 D3 (domain-core forbidden import rule) 에서 "Lombok 어노테이션도 framework import 와 동일하게 취급하는 이유"를 뒷받침하는 근거 자료로 보관.

핵심 인용 / Key quotes (verbatim, 5문장)

[§Builder / 7 things list intro] "A method annotated with @Builder (from now on called the target) causes the following 7 things to be generated:"

[§Builder / item 1] "An inner static class named _Foo_Builder, with the same type arguments as the static method (called the builder)."

[§Builder / item 5] "In the builder: A build() method which calls the method, passing in each field."

[§Data / shortcut description] "A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, @Setter on all non-final fields, and @RequiredArgsConstructor!"

[§Data / POJO description] "In other words, @Data generates all the boilerplate that is normally associated with simple POJOs (Plain Old Java Objects) and beans: getters for all fields, setters for all non-final fields, and appropriate toString, equals and hashCode implementations that involve the fields of the class, and a constructor that initializes all final fields, as well as all non-final fields with no initializer that have been marked with @NonNull, in order to ensure the field is never null."

Claims Extracted / 추출된 주장

이 자료가 직접 말하는 것만 claim 으로 분리한다. 내 프로젝트에 적용한 결론은 여기 쓰지 않는다.

Claim ID Claim (이 자료가 직접 말하는 것) Evidence quote Strength Applies to Does not prove
LMB-C1 @Builder 는 7가지 요소를 생성하며, 그 중 하나는 inner static builder class 다 [§Builder / 7 things intro] "A method annotated with @Builder (from now on called the target) causes the following 7 things to be generated:" official-vendor-doc Lombok 이 적용된 모든 클래스·생성자·메서드 대상 @Builder 를 금지해야 한다는 결론을 직접 도출하지는 않음. 금지 여부는 별도 architecture policy 결정
LMB-C2 생성된 inner static class 는 빌더의 타입 인자를 가지며 _Foo_Builder 라 불린다 [§Builder / item 1] "An inner static class named _Foo_Builder, with the same type arguments as the static method (called the builder)." official-vendor-doc @Builder 가 클래스에 붙을 때 inner static class 가 Spring/JPA 등 특정 framework 의존성을 유발하는지는 이 자료로 증명 불가
LMB-C3 @Builderbuild() 메서드를 생성하며, 이 메서드는 각 필드를 인자로 전달해 원본 메서드를 호출한다 [§Builder / item 5] "In the builder: A build() method which calls the method, passing in each field." official-vendor-doc Lombok @Builder 가 적용된 대상 생성된 build() 가 특정 런타임/프레임워크에 의존하는지는 이 자료로 알 수 없음
LMB-C4 @Data@ToString, @EqualsAndHashCode, @Getter, @Setter(비-final 필드), @RequiredArgsConstructor 를 묶은 단축 어노테이션이다 [§Data / shortcut] "A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, @Setter on all non-final fields, and @RequiredArgsConstructor!" official-vendor-doc Lombok @Data 가 적용된 모든 클래스 @Data 를 붙이면 반드시 문제가 생긴다는 결론은 이 자료로 도출 불가. POJO 정의에 따라 허용 여부가 달라짐
LMB-C5 @Data 는 비-final 필드에 setter 를 포함한 POJO 전체 boilerplate 를 생성하며, @NonNull 비-final 필드도 생성자에서 초기화한다 [§Data / POJO description] "@Data generates all the boilerplate that is normally associated with simple POJOs [...]: getters for all fields, setters for all non-final fields, and appropriate toString, equals and hashCode implementations [...]" official-vendor-doc Lombok @Data 가 적용된 클래스 setter 생성이 domain 불변 원칙을 깨는지 여부는 별도 아키텍처 정책으로 판단해야 함

Usage Boundaries / 적용 경계

  • 이 자료가 직접 증명하는 것:

    • LMB-C1, LMB-C2, LMB-C3: @Builder 를 붙이면 inner static class, setter-like 메서드, build() 메서드 등 7가지 코드가 컴파일 시점에 생성된다.
    • LMB-C4, LMB-C5: @Data 를 붙이면 비-final 필드에 setter 가 포함된 전체 POJO boilerplate 가 생성된다.
  • 이 자료가 증명하지 않는 것:

    • Lombok 어노테이션 자체가 Spring/JPA 등 특정 framework 에 의존하는지 여부 (Lombok 은 annotation processor 이며 런타임 의존성을 직접 추가하지 않음).
    • domain-core 에서 Lombok 을 금지해야 한다는 architecture policy. 그것은 ca-tmpl 의 자체 설계 결정이며 이 자료는 그 결정에서 "어떤 코드가 생성되는가"를 뒷받침하는 사실 근거만 제공함.
    • inner static builder class 나 setter 의 존재가 domain model 의 불변성을 "자동으로" 깨는지. 설계 의도에 따라 문제 없을 수도 있음.
  • 내 프로젝트에 적용하려면 추가 확인이 필요한 것:

    • ca-tmpl domain-core 에서 @Builder / @Data 를 실제로 추가했을 때 ArchUnit rule 이 실패하는지 실증 필요 (ArchUnit 은 annotation processor 가 생성한 inner class 의 import 를 정적 분석 가능한지 확인 필요).
    • "Lombok 금지" 가 @Value (immutable builder), @Getter (field-only) 에도 동일하게 적용되는지 별도 정책 결정 필요.

메모 / Notes

  • @Builder 생성 7가지 중 4번 항목("setter-like method") 은 원문에서 'setter'-like method for each parameter of the _target_ 로 표현. 따옴표를 직접 사용한 것은 setter 와 완전히 동일하지 않음을 암시할 수 있으나, 실제 코드 패턴은 builder 체이닝 setter 임 — 해석은 wiki/concepts 에서 다룰 것.
  • @Data@Setter 는 비-final 필드에만 생성됨. final 필드로만 구성한 불변 POJO 라면 @Setter 생성이 억제되나, @Builder.Default 와 함께 쓰면 mutable default 필드가 생길 수 있음.
  • 추가로 봐야 할 동일 출처 페이지: @Value (https://projectlombok.org/features/Value — 불변 POJO, domain 허용 여부 검토 후보), @Getter / @Setter (https://projectlombok.org/features/GetterSetter).