Add getReplies() method to Post.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 16 Oct 2013 19:03:32 +0000 (21:03 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:28 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Post.java
src/main/java/net/pterodactylus/sone/data/impl/DefaultPost.java

index 759a8ba..145170d 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.data;
 
 import java.util.Comparator;
+import java.util.List;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
@@ -114,4 +115,6 @@ public interface Post extends Identified {
         */
        public Post setKnown(boolean known);
 
+       List<PostReply> getReplies();
+
 }
index cb8fa2f..1f9c62c 100644 (file)
 
 package net.pterodactylus.sone.data.impl;
 
+import static com.google.common.collect.FluentIterable.from;
+
+import java.util.List;
 import java.util.UUID;
 
 import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.PostReply;
+import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.database.Database;
 
@@ -123,6 +128,11 @@ public class DefaultPost implements Post {
                return this;
        }
 
+       @Override
+       public List<PostReply> getReplies() {
+               return from(database.getReplies(getId())).toSortedList(Reply.TIME_COMPARATOR);
+       }
+
        //
        // OBJECT METHODS
        //