1 package be
.nikiroo
.gofetch
.data
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Iterator
;
7 public class Comment
implements Iterable
<Comment
> {
12 private List
<String
> lines
;
13 private List
<Comment
> children
;
15 public Comment(String id
, String author
, String title
, String date
,
22 this.children
= new ArrayList
<Comment
>();
25 public void add(Comment comment
) {
26 children
.add(comment
);
29 public void addAll(List
<Comment
> comments
) {
30 children
.addAll(comments
);
36 public String
getId() {
43 public String
getAuthor() {
50 public String
getTitle() {
57 public String
getDate() {
64 public List
<String
> getContentLines() {
69 * Find a comment or sub-comment by its id.
72 * the id to look for F
73 * @return this if it has the given id, or a child of this if the child have
74 * the given id, or NULL if not
76 public Comment
getById(String id
) {
78 if (id
.equals(this.id
)) {
82 for (Comment subComment
: this) {
83 if (id
.equals(subComment
.getId())) {
92 public boolean isEmpty() {
93 return children
.isEmpty() && lines
.isEmpty()
94 && ("" + author
+ title
).isEmpty();
98 public Iterator
<Comment
> iterator() {
99 return children
.iterator();