-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Content): Feedback의 본문 내용인 Content 를 값객체로 리팩토링
- Loading branch information
1 parent
17f0b25
commit 844fc69
Showing
3 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/kustacks/kuring/user/domain/Content.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.kustacks.kuring.user.domain; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Content { | ||
|
||
private static final int MAX_LENGTH = 256; | ||
|
||
@Column(name = "content", length = 256, nullable = false) | ||
private String value; | ||
|
||
public Content(String content) { | ||
validate(content); | ||
this.value = content; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
private void validate(String content) { | ||
if (content.length() > MAX_LENGTH) throw new IllegalArgumentException("본문 내용은 " + MAX_LENGTH + "자 이하여야 합니다"); | ||
if (content.isBlank()) throw new IllegalArgumentException("본문은 공백일 수 없습니다"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters