import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
import net.pterodactylus.util.json.JsonArray;
import net.pterodactylus.util.json.JsonObject;
import net.pterodactylus.util.notify.Notification;
import net.pterodactylus.util.object.HashCode;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
/**
* The “get status” AJAX handler returns all information that is necessary to
* update the web interface in real-time.
Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
int notificationHash = HashCode.hashCode(notifications);
/* load new posts. */
- Set<Post> newPosts = webInterface.getNewPosts();
+ Collection<Post> newPosts = webInterface.getNewPosts();
if (currentSone != null) {
- newPosts = Filters.filteredSet(newPosts, new Filter<Post>() {
+ newPosts = Collections2.filter(newPosts, new Predicate<Post>() {
@Override
- public boolean filterObject(Post post) {
+ public boolean apply(Post post) {
return ListNotificationFilters.isPostVisible(currentSone, post);
}
jsonPosts.add(jsonPost);
}
/* load new replies. */
- Set<PostReply> newReplies = webInterface.getNewReplies();
+ Collection<PostReply> newReplies = webInterface.getNewReplies();
if (currentSone != null) {
- newReplies = Filters.filteredSet(newReplies, new Filter<PostReply>() {
+ newReplies = Collections2.filter(newReplies, new Predicate<PostReply>() {
@Override
- public boolean filterObject(PostReply reply) {
+ public boolean apply(PostReply reply) {
return ListNotificationFilters.isReplyVisible(currentSone, reply);
}
});
}
/* remove replies to unknown posts. */
- newReplies = Filters.filteredSet(newReplies, new Filter<PostReply>() {
+ newReplies = Collections2.filter(newReplies, new Predicate<PostReply>() {
@Override
- public boolean filterObject(PostReply reply) {
+ public boolean apply(PostReply reply) {
return (reply.getPost() != null) && (reply.getPost().getSone() != null);
}
});
* The current Sone (may be {@code null})
* @return The current options
*/
- private JsonObject createJsonOptions(Sone currentSone) {
+ private static JsonObject createJsonOptions(Sone currentSone) {
JsonObject options = new JsonObject();
if (currentSone != null) {
options.put("ShowNotification/NewSones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get());