Move reply like functionality from Sone to Reply.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Reply.java
index c23426a..510b81f 100644 (file)
@@ -18,7 +18,9 @@
 package net.pterodactylus.sone.data;
 
 import java.util.Comparator;
+import java.util.Set;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 
 /**
@@ -28,7 +30,7 @@ import com.google.common.base.Predicate;
  *            The type of the reply
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public interface Reply<T extends Reply<T>> {
+public interface Reply<T extends Reply<T>> extends Identified {
 
        /** Comparator that sorts replies ascending by time. */
        public static final Comparator<? super Reply<?>> TIME_COMPARATOR = new Comparator<Reply<?>>() {
@@ -51,7 +53,7 @@ public interface Reply<T extends Reply<T>> {
                 */
                @Override
                public boolean apply(Reply<?> reply) {
-                       return reply.getTime() <= System.currentTimeMillis();
+                       return (reply == null) ? false : reply.getTime() <= System.currentTimeMillis();
                }
 
        };
@@ -71,15 +73,6 @@ public interface Reply<T extends Reply<T>> {
        public Sone getSone();
 
        /**
-        * Sets the Sone that posted this reply.
-        *
-        * @param sone
-        *            The Sone that posted this reply
-        * @return This reply
-        */
-       public T setSone(Sone sone);
-
-       /**
         * Returns the time of the reply.
         *
         * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
@@ -87,15 +80,6 @@ public interface Reply<T extends Reply<T>> {
        public long getTime();
 
        /**
-        * Sets the time of the reply.
-        *
-        * @param time
-        *            The time of the reply (in milliseconds since Jan 1, 1970 UTC)
-        * @return This reply
-        */
-       public T setTime(long time);
-
-       /**
         * Returns the text of the reply.
         *
         * @return The text of the reply
@@ -103,28 +87,31 @@ public interface Reply<T extends Reply<T>> {
        public String getText();
 
        /**
-        * Sets the text of the reply.
-        *
-        * @param text
-        *            The text of the reply
-        * @return This reply
-        */
-       public T setText(String text);
-
-       /**
         * Returns whether this reply is known.
         *
         * @return {@code true} if this reply is known, {@code false} otherwise
         */
        public boolean isKnown();
 
-       /**
-        * Sets whether this reply is known.
-        *
-        * @param known
-        *            {@code true} if this reply is known, {@code false} otherwise
-        * @return This reply
-        */
-       public T setKnown(boolean known);
+       void like(Sone localSone);
+       void unlike(Sone localSone);
+
+       boolean isLiked(Sone sone);
+       Set<Sone> getLikes();
+
+       Modifier<T> modify();
+
+       interface Modifier<T> {
+
+               Modifier<T> setKnown();
+               T update(Optional<ReplyUpdated<T>> replyUpdated);
+
+               interface ReplyUpdated<T> {
+
+                       void replyUpdated(T reply);
+
+               }
+
+       }
 
 }