New getComentById() method
[gofetch.git] / src / be / nikiroo / gofetch / data / Story.java
index 9fd4c1495b882ccf8591489cb901137b01271418..a2ad7d3b9e3a3660d18c951c6c3904b49a91c6b6 100644 (file)
@@ -130,4 +130,25 @@ public class Story {
        public void setComments(List<Comment> comments) {
                this.comments = comments;
        }
+
+       /**
+        * 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 getCommentById(String id) {
+               if (id != null && comments != null) {
+                       for (Comment comment : comments) {
+                               Comment found = comment.getById(id);
+                               if (found != null) {
+                                       return found;
+                               }
+                       }
+               }
+
+               return null;
+       }
 }
\ No newline at end of file