Change all copyright headers to include 2012.
[Sone.git] / src / main / java / net / pterodactylus / sone / notify / ListNotification.java
index c66d376..f1343ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ListNotification.java - Copyright © 2010 David Roden
+ * Sone - ListNotification.java - Copyright © 2010–2012 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
@@ -101,7 +101,8 @@ public class ListNotification<T> extends TemplateNotification {
        }
 
        /**
-        * Sets the elements to show in this notification.
+        * Sets the elements to show in this notification. This method will not call
+        * {@link #touch()}.
         *
         * @param elements
         *            The elements to show
@@ -160,4 +161,46 @@ public class ListNotification<T> extends TemplateNotification {
                elements.clear();
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               int hashCode = super.hashCode();
+               for (T element : elements) {
+                       hashCode ^= element.hashCode();
+               }
+               return hashCode;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof ListNotification)) {
+                       return false;
+               }
+               ListNotification<?> listNotification = (ListNotification<?>) object;
+               if (!super.equals(listNotification)) {
+                       return false;
+               }
+               if (!key.equals(listNotification.key)) {
+                       return false;
+               }
+               if (elements.size() != listNotification.elements.size()) {
+                       return false;
+               }
+               for (int index = 0; index < elements.size(); ++index) {
+                       if (!elements.get(index).equals(listNotification.elements.get(index))) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
 }