-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathDeleteHistory.java
More file actions
58 lines (44 loc) · 1.75 KB
/
DeleteHistory.java
File metadata and controls
58 lines (44 loc) · 1.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package nextstep.qna.domain;
import nextstep.users.domain.NsUser;
import java.time.LocalDateTime;
import java.util.Objects;
public class DeleteHistory {
private Long id;
private ContentType contentType;
private Long contentId;
private NsUser deletedBy;
private LocalDateTime createdDate = LocalDateTime.now();
public DeleteHistory() {
}
public static DeleteHistory ofQuestion(Question question) {
return new DeleteHistory(ContentType.QUESTION, question.getId(), question.getWriter(), LocalDateTime.now());
}
public static DeleteHistory ofAnswer(Answer answer) {
return new DeleteHistory(ContentType.ANSWER, answer.getId(), answer.getWriter(), LocalDateTime.now());
}
public DeleteHistory(ContentType contentType, Long contentId, NsUser deletedBy, LocalDateTime createdDate) {
this.contentType = contentType;
this.contentId = contentId;
this.deletedBy = deletedBy;
this.createdDate = createdDate;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeleteHistory that = (DeleteHistory) o;
return Objects.equals(id, that.id) &&
contentType == that.contentType &&
Objects.equals(contentId, that.contentId) &&
Objects.equals(deletedBy, that.deletedBy);
}
@Override
public int hashCode() {
return Objects.hash(id, contentType, contentId, deletedBy);
}
@Override
public String toString() {
return "DeleteHistory [id=" + id + ", contentType=" + contentType + ", contentId=" + contentId + ", deletedBy="
+ deletedBy + ", createdDate=" + createdDate + "]";
}
}