Move Sone parsing into its own class.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / DefaultPost.java
index c4dcb62..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;
 
@@ -82,86 +87,61 @@ public class DefaultPost implements Post {
        // ACCESSORS
        //
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String getId() {
                return id.toString();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Sone getSone() {
                return database.getSone(soneId).get();
        }
 
-       /**
-        * {@inheritDocs}
-        */
        @Override
        public Optional<String> getRecipientId() {
                return Optional.fromNullable(recipientId);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Optional<Sone> getRecipient() {
                return database.getSone(recipientId);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public long getTime() {
                return time;
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String getText() {
                return text;
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public boolean isKnown() {
                return known;
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public DefaultPost setKnown(boolean known) {
                this.known = known;
                return this;
        }
 
+       @Override
+       public List<PostReply> getReplies() {
+               return from(database.getReplies(getId())).toSortedList(Reply.TIME_COMPARATOR);
+       }
+
        //
        // OBJECT METHODS
        //
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public int hashCode() {
                return id.hashCode();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public boolean equals(Object object) {
                if (!(object instanceof DefaultPost)) {
@@ -171,9 +151,6 @@ public class DefaultPost implements Post {
                return post.id.equals(id);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String toString() {
                return String.format("%s[id=%s,sone=%s,recipient=%s,time=%d,text=%s]", getClass().getName(), id, soneId, recipientId, time, text);