X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fdata%2FComment.java;h=da074820149f4b1fa555036f7890bb1293eafe98;hb=3e62b034c1981ae6329f06b3f8c0ee25c3683789;hp=963d6aa6d6dffe427d5bab979fc20cd1790550e7;hpb=27008a8782c0ed96e07c8dc39ff0ed1f5163a9d0;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/data/Comment.java b/src/be/nikiroo/gofetch/data/Comment.java index 963d6aa..da07482 100644 --- a/src/be/nikiroo/gofetch/data/Comment.java +++ b/src/be/nikiroo/gofetch/data/Comment.java @@ -65,9 +65,33 @@ public class Comment implements Iterable { return lines; } + /** + * Find a comment or sub-comment by its id. + * + * @param id + * the id to look for F + * @return this if it has the given id, or a child of this if the child have + * the given id, or NULL if not + */ + public Comment getById(String id) { + if (id != null) { + if (id.equals(this.id)) { + return this; + } + + for (Comment subComment : this) { + if (id.equals(subComment.getId())) { + return subComment; + } + } + } + + return null; + } + public boolean isEmpty() { return children.isEmpty() && lines.isEmpty() - && ("" + author + title).trim().isEmpty(); + && ("" + author + title).isEmpty(); } @Override