Move unliking a post from Sone to Post.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Reply.java
index a686023..c660f27 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.data;
 
 import java.util.Comparator;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 
 /**
@@ -28,7 +29,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 +52,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();
                }
 
        };
@@ -91,13 +92,19 @@ public interface Reply<T extends Reply<T>> {
         */
        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);
+       Modifier<T> modify();
+
+       interface Modifier<T> {
+
+               Modifier<T> setKnown();
+               T update(Optional<ReplyUpdated<T>> replyUpdated);
+
+               interface ReplyUpdated<T> {
+
+                       void replyUpdated(T reply);
+
+               }
+
+       }
 
 }