Replace utils’ HashCode by Java’s hashCode().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 17 Jan 2013 14:41:50 +0000 (15:41 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 17 Jan 2013 14:41:50 +0000 (15:41 +0100)
Actually, Collection.hashCode() is already required to calculate a “good” hashcode
to fulfill the contract of equals() and hashCode().

src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java

index 8c196e5..7dfdfe7 100644 (file)
@@ -31,7 +31,6 @@ import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.sone.web.page.FreenetTemplatePage;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.sone.web.page.FreenetTemplatePage;
 import net.pterodactylus.util.notify.Notification;
-import net.pterodactylus.util.object.HashCode;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
@@ -267,7 +266,7 @@ public class SoneTemplatePage extends FreenetTemplatePage {
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
                Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                templateContext.set("notifications", notifications);
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
                Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                templateContext.set("notifications", notifications);
-               templateContext.set("notificationHash", HashCode.hashCode(notifications));
+               templateContext.set("notificationHash", notifications.hashCode());
        }
 
        /**
        }
 
        /**
index d4be6be..6573dda 100644 (file)
@@ -32,7 +32,6 @@ import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.TemplateNotification;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.TemplateNotification;
-import net.pterodactylus.util.object.HashCode;
 import net.pterodactylus.util.template.TemplateContext;
 
 /**
 import net.pterodactylus.util.template.TemplateContext;
 
 /**
@@ -81,12 +80,11 @@ public class GetNotificationsAjaxPage extends JsonPage {
                Collection<Notification> notifications = webInterface.getNotifications().getNotifications();
                List<Notification> filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone);
                Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER);
                Collection<Notification> notifications = webInterface.getNotifications().getNotifications();
                List<Notification> filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone);
                Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER);
-               int notificationHash = HashCode.hashCode(filteredNotifications);
                JsonArray jsonNotifications = new JsonArray();
                for (Notification notification : filteredNotifications) {
                        jsonNotifications.add(createJsonNotification(request, notification));
                }
                JsonArray jsonNotifications = new JsonArray();
                for (Notification notification : filteredNotifications) {
                        jsonNotifications.add(createJsonNotification(request, notification));
                }
-               return createSuccessJsonObject().put("notificationHash", notificationHash).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone));
+               return createSuccessJsonObject().put("notificationHash", filteredNotifications.hashCode()).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone));
        }
 
        //
        }
 
        //
index 25c8713..8657a6a 100644 (file)
@@ -36,7 +36,6 @@ import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 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;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
@@ -89,7 +88,6 @@ public class GetStatusAjaxPage extends JsonPage {
                /* load notifications. */
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
                Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                /* 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. */
                Collection<Post> newPosts = webInterface.getNewPosts();
                if (currentSone != null) {
                /* load new posts. */
                Collection<Post> newPosts = webInterface.getNewPosts();
                if (currentSone != null) {
@@ -140,7 +138,7 @@ public class GetStatusAjaxPage extends JsonPage {
                        jsonReply.put("postSone", reply.getPost().getSone().getId());
                        jsonReplies.add(jsonReply);
                }
                        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);
        }
 
        /**
        }
 
        /**