Skip to content

[refactor] #150 builder 메서드 접근제어자 public -> private 변경#151

Merged
2hyunjinn merged 2 commits intomainfrom
refactor/#150
Jul 24, 2025
Merged

[refactor] #150 builder 메서드 접근제어자 public -> private 변경#151
2hyunjinn merged 2 commits intomainfrom
refactor/#150

Conversation

@2hyunjinn
Copy link
Copy Markdown
Member

@2hyunjinn 2hyunjinn commented Jul 23, 2025

📌 PR 제목

[refactor] #150 builder 메서드 접근제어자 public -> private 변경

📌 PR 내용

  • 객체 생성 방식을 통제하기 위해 builder 메서드의 접근 제어자를 public에서 private으로 변경하였습니다.
  • 불필요한 외부 생성 경로를 차단하여, 생성자 또는 정적 팩토리 메서드를 통한 일관된 객체 생성을 유도합니다.

🛠 작업 내용

  • entity builder 메서드의 접근 제어자 private 로 변경

🔍 관련 이슈

Closes #150

📸 스크린샷 (Optional)

image

📚 레퍼런스 (Optional)

N/A

Summary by CodeRabbit

  • Refactor
    • Improved formatting for better readability in some user and authentication request/response screens.
    • Updated internal object creation methods to enhance consistency and enforce best practices across several features. No visible changes to user-facing functionality.

@2hyunjinn 2hyunjinn self-assigned this Jul 23, 2025
@2hyunjinn 2hyunjinn added the refactor This doesn't seem right label Jul 23, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 23, 2025

Walkthrough

This update changes the access modifier of constructors annotated with @Builder in several entity classes from public to private, enforcing use of the builder pattern for object creation. Additionally, some DTO record declarations are reformatted for improved readability without altering their logic or signatures.

Changes

File(s) Change Summary
.../api/auth/dto/TokenResponse.java
.../api/user/dto/SignUpRequest.java
Reformatted record declarations for readability; no logic or signature changes.
.../domain/festival/entity/Festival.java
.../festivalHost/entity/FestivalHost.java
.../matching/entity/Matching.java
.../participant/entity/Participant.java
.../point/entity/Point.java
.../user/entity/User.java
Changed @Builder constructor visibility from public to private in each entity class.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant EntityClass

    Client->>EntityClass: EntityClass.builder() // now only via builder, not constructor
    EntityClass-->>Client: Builder instance
    Client->>EntityClass: builder.build()
    EntityClass-->>Client: New Entity instance
Loading

Estimated code review effort

2 (~15 minutes)

Poem

In fields of code, the builders hide,
No longer public, they turn aside.
With private doors, they guard their way,
For rabbits and devs, a safer day!
DTOs lined up, neat and bright—
Refactored fields, a tidy sight.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 016ee9d and 027954e.

📒 Files selected for processing (8)
  • src/main/java/org/festimate/team/api/auth/dto/TokenResponse.java (1 hunks)
  • src/main/java/org/festimate/team/api/user/dto/SignUpRequest.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festival/entity/Festival.java (1 hunks)
  • src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java (1 hunks)
  • src/main/java/org/festimate/team/domain/matching/entity/Matching.java (1 hunks)
  • src/main/java/org/festimate/team/domain/participant/entity/Participant.java (1 hunks)
  • src/main/java/org/festimate/team/domain/point/entity/Point.java (1 hunks)
  • src/main/java/org/festimate/team/domain/user/entity/User.java (1 hunks)
🔇 Additional comments (8)
src/main/java/org/festimate/team/domain/festivalHost/entity/FestivalHost.java (1)

44-44: LGTM! Constructor access modifier change strengthens encapsulation.

Changing the @builder constructor from public to private is an excellent practice that enforces the use of the builder pattern while preventing direct instantiation. The protected no-args constructor remains available for JPA, ensuring proper entity management.

src/main/java/org/festimate/team/domain/festival/entity/Festival.java (1)

60-60: LGTM! Constructor access modifier change improves encapsulation.

The private constructor enforces the builder pattern usage, which is already demonstrated consistently in this class (see addHost method using FestivalHost.builder()). This change strengthens the domain model's encapsulation.

src/main/java/org/festimate/team/domain/user/entity/User.java (1)

56-57: LGTM! Private constructor enforces builder pattern for complex entity creation.

This change is particularly beneficial for the User entity due to its many constructor parameters. The builder pattern significantly improves code readability and maintainability while the private constructor ensures proper encapsulation.

src/main/java/org/festimate/team/api/user/dto/SignUpRequest.java (1)

8-16: LGTM! Improved readability with multi-line record parameter formatting.

The reformatted parameter declaration enhances code readability by placing each parameter on its own line. This is particularly beneficial for records with multiple parameters like this one.

src/main/java/org/festimate/team/api/auth/dto/TokenResponse.java (1)

3-6: LGTM! Consistent multi-line formatting improves readability.

The reformatted record parameter declaration is consistent with the formatting changes applied to other DTO classes in this PR and enhances code readability.

src/main/java/org/festimate/team/domain/participant/entity/Participant.java (1)

55-55: LGTM! Excellent encapsulation improvement.

Changing the builder constructor from public to private properly enforces the builder pattern usage and prevents direct instantiation outside the class. This aligns perfectly with the PR objective of strengthening encapsulation.

src/main/java/org/festimate/team/domain/point/entity/Point.java (1)

35-35: LGTM! Consistent with encapsulation improvements.

The private access modifier on the builder constructor properly restricts direct instantiation while maintaining the builder pattern functionality. This change is consistent with the overall refactoring strategy.

src/main/java/org/festimate/team/domain/matching/entity/Matching.java (1)

46-46: LGTM! Completes the systematic encapsulation improvement.

The private access modifier on the builder constructor maintains consistency with the other entity classes in this refactoring. This change successfully enforces the builder pattern while preserving JPA functionality through the protected no-args constructor.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

Test Results

47 tests   47 ✅  1s ⏱️
10 suites   0 💤
10 files     0 ❌

Results for commit 027954e.

@2hyunjinn 2hyunjinn merged commit 5b03d1b into main Jul 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] builder 메서드 접근제어자 public → private 변경

1 participant