Replace utils’ filter with Guava’s predicate.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Reply.java
index 780fe69..f6e4a2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - Reply.java - Copyright © 2011 David Roden
+ * Sone - Reply.java - Copyright © 2011–2012 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@ package net.pterodactylus.sone.data;
 import java.util.Comparator;
 import java.util.UUID;
 
-import net.pterodactylus.util.filter.Filter;
+import com.google.common.base.Predicate;
 
 /**
  * Abstract base class for all replies.
@@ -45,13 +45,13 @@ public abstract class Reply<T extends Reply<T>> {
        };
 
        /** Filter for replies with timestamps from the future. */
-       public static final Filter<Reply<?>> FUTURE_REPLY_FILTER = new Filter<Reply<?>>() {
+       public static final Predicate<Reply<?>> FUTURE_REPLY_FILTER = new Predicate<Reply<?>>() {
 
                /**
                 * {@inheritDoc}
                 */
                @Override
-               public boolean filterObject(Reply<?> reply) {
+               public boolean apply(Reply<?> reply) {
                        return reply.getTime() <= System.currentTimeMillis();
                }
 
@@ -69,6 +69,9 @@ public abstract class Reply<T extends Reply<T>> {
        /** The text of the reply. */
        private volatile String text;
 
+       /** Whether the reply is known. */
+       private volatile boolean known;
+
        /**
         * Creates a new reply with the given ID.
         *
@@ -187,6 +190,28 @@ public abstract class Reply<T extends Reply<T>> {
                return (T) this;
        }
 
+       /**
+        * Returns whether this reply is known.
+        *
+        * @return {@code true} if this reply is known, {@code false} otherwise
+        */
+       public boolean isKnown() {
+               return known;
+       }
+
+       /**
+        * Sets whether this reply is known.
+        *
+        * @param known
+        *            {@code true} if this reply is known, {@code false} otherwise
+        * @return This reply
+        */
+       @SuppressWarnings("unchecked")
+       public T setKnown(boolean known) {
+               this.known = known;
+               return (T) this;
+       }
+
        //
        // OBJECT METHODS
        //