import java.util.Comparator;
+import com.google.common.base.Optional;
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<?>>() {
*/
@Override
public boolean apply(Reply<?> reply) {
- return reply.getTime() <= System.currentTimeMillis();
+ return (reply == null) ? false : reply.getTime() <= System.currentTimeMillis();
}
};
*/
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);
+
+ }
+
+ }
}