/*
- * Sone - Post.java - Copyright © 2010–2013 David Roden
+ * Sone - Post.java - Copyright © 2010–2020 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
import static com.google.common.base.Optional.absent;
-import java.util.Comparator;
-
import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
/**
* A post is a short message that a user writes in his Sone to let other users
* know what is going on.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Post extends Identified {
- /** Comparator for posts, sorts descending by time. */
- public static final Comparator<Post> TIME_COMPARATOR = new Comparator<Post>() {
-
- @Override
- public int compare(Post leftPost, Post rightPost) {
- return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, rightPost.getTime() - leftPost.getTime()));
- }
-
- };
-
- /** Filter for posts with timestamps from the future. */
- public static final Predicate<Post> FUTURE_POSTS_FILTER = new Predicate<Post>() {
-
- @Override
- public boolean apply(Post post) {
- return (post != null) && (post.getTime() <= System.currentTimeMillis());
- }
-
- };
-
//
// ACCESSORS
//
/**
* Shell for a post that has not yet been loaded.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’
- * Roden</a>
*/
public static class EmptyPost implements Post {