Actually, Collection.hashCode() is already required to calculate a “good” hashcode
to fulfill the contract of equals() and hashCode().
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;
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());
}
/**
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;
/**
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));
}
- 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));
}
//
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;
/* 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) {
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);
}
/**