Replace utils’ HashCode by Java’s hashCode().
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / GetStatusAjaxPage.java
index 4c61f89..8657a6a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - GetStatusAjaxPage.java - Copyright © 2010–2012 David Roden
+ * Sone - GetStatusAjaxPage.java - Copyright © 2010–2013 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
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
@@ -32,12 +33,12 @@ import net.pterodactylus.sone.notify.ListNotificationFilters;
 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
@@ -87,14 +88,13 @@ public class GetStatusAjaxPage extends JsonPage {
                /* load notifications. */
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
                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);
                                }
 
@@ -110,22 +110,22 @@ public class GetStatusAjaxPage extends JsonPage {
                        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);
                        }
                });
@@ -138,7 +138,7 @@ public class GetStatusAjaxPage extends JsonPage {
                        jsonReply.put("postSone", reply.getPost().getSone().getId());
                        jsonReplies.add(jsonReply);
                }
-               return createSuccessJsonObject().put("loggedIn", currentSone != null).put("options", createJsonOptions(currentSone)).put("sones", jsonSones).put("notificationHash", notificationHash).put("newPosts", jsonPosts).put("newReplies", jsonReplies);
+               return createSuccessJsonObject().put("loggedIn", currentSone != null).put("options", createJsonOptions(currentSone)).put("sones", jsonSones).put("notificationHash", notifications.hashCode()).put("newPosts", jsonPosts).put("newReplies", jsonReplies);
        }
 
        /**