-
Notifications
You must be signed in to change notification settings - Fork 423
Expand file tree
/
Copy pathAnswerList.java
More file actions
35 lines (27 loc) · 826 Bytes
/
AnswerList.java
File metadata and controls
35 lines (27 loc) · 826 Bytes
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
package qna.domain;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import org.hibernate.annotations.Where;
@Embeddable
public class AnswerList {
@OneToMany(mappedBy = "question", cascade = CascadeType.ALL)
@Where(clause = "deleted = false")
@OrderBy("id ASC")
private final List<Answer> answers = new ArrayList<>();
public boolean isEmpty() {
return answers.isEmpty();
}
public void add(final Answer answer) {
answers.add(answer);
}
public void deleteAll(final User loginUser) {
answers.forEach(answer -> answer.delete(loginUser));
}
public List<Answer> getAnswers() {
return answers;
}
}