-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathExampleModel.java
More file actions
44 lines (35 loc) · 1.25 KB
/
ExampleModel.java
File metadata and controls
44 lines (35 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.loopers.domain.example;
import com.loopers.domain.BaseEntity;
import com.loopers.support.error.CoreException;
import com.loopers.support.error.ErrorType;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@Entity
@Table(name = "example")
public class ExampleModel extends BaseEntity {
private String name;
private String description;
protected ExampleModel() {}
public ExampleModel(String name, String description) {
if (name == null || name.isBlank()) {
throw new CoreException(ErrorType.BAD_REQUEST, "이름은 비어있을 수 없습니다.");
}
if (description == null || description.isBlank()) {
throw new CoreException(ErrorType.BAD_REQUEST, "설명은 비어있을 수 없습니다.");
}
this.name = name;
this.description = description;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public void update(String newDescription) {
if (newDescription == null || newDescription.isBlank()) {
throw new CoreException(ErrorType.BAD_REQUEST, "설명은 비어있을 수 없습니다.");
}
this.description = newDescription;
}
}