From: David ‘Bombe’ Roden Date: Wed, 16 Oct 2013 19:03:32 +0000 (+0200) Subject: Add getReplies() method to Post. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=78de3bef22bba378ed97fbeff430022dd2385096;p=Sone.git Add getReplies() method to Post. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Post.java b/src/main/java/net/pterodactylus/sone/data/Post.java index 759a8ba..145170d 100644 --- a/src/main/java/net/pterodactylus/sone/data/Post.java +++ b/src/main/java/net/pterodactylus/sone/data/Post.java @@ -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 getReplies(); + } diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPost.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPost.java index cb8fa2f..1f9c62c 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPost.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPost.java @@ -17,9 +17,14 @@ 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 getReplies() { + return from(database.getReplies(getId())).toSortedList(Reply.TIME_COMPARATOR); + } + // // OBJECT METHODS //