From 78de3bef22bba378ed97fbeff430022dd2385096 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 16 Oct 2013 21:03:32 +0200 Subject: [PATCH] Add getReplies() method to Post. --- src/main/java/net/pterodactylus/sone/data/Post.java | 3 +++ .../java/net/pterodactylus/sone/data/impl/DefaultPost.java | 10 ++++++++++ 2 files changed, 13 insertions(+) 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 // -- 2.7.4