Use watcher in equals() and hashCode() if it’s not null.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 11 Jan 2013 08:56:55 +0000 (09:56 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 11 Jan 2013 08:57:57 +0000 (09:57 +0100)
src/main/java/net/pterodactylus/rhynodge/loader/Chain.java

index 2587d09..d54fae0 100644 (file)
@@ -279,11 +279,15 @@ public class Chain {
        public int hashCode() {
                int hashCode = 0;
                hashCode ^= name.hashCode();
-               hashCode ^= query.hashCode();
-               for (Part filter : filters) {
-                       hashCode ^= filter.hashCode();
+               if (watcher != null) {
+                       hashCode ^= watcher.hashCode();
+               } else {
+                       hashCode ^= query.hashCode();
+                       for (Part filter : filters) {
+                               hashCode ^= filter.hashCode();
+                       }
+                       hashCode ^= trigger.hashCode();
                }
-               hashCode ^= trigger.hashCode();
                hashCode ^= action.hashCode();
                hashCode ^= updateInterval;
                return hashCode;
@@ -301,19 +305,25 @@ public class Chain {
                if (!name.equals(chain.name)) {
                        return false;
                }
-               if (!query.equals(chain.query)) {
-                       return false;
-               }
-               if (filters.size() != chain.filters.size()) {
-                       return false;
-               }
-               for (int filterIndex = 0; filterIndex < filters.size(); ++filterIndex) {
-                       if (!filters.get(filterIndex).equals(chain.filters.get(filterIndex))) {
+               if (watcher != null) {
+                       if (!watcher.equals(chain.watcher)) {
+                               return false;
+                       }
+               } else {
+                       if (!query.equals(chain.query)) {
+                               return false;
+                       }
+                       if (filters.size() != chain.filters.size()) {
+                               return false;
+                       }
+                       for (int filterIndex = 0; filterIndex < filters.size(); ++filterIndex) {
+                               if (!filters.get(filterIndex).equals(chain.filters.get(filterIndex))) {
+                                       return false;
+                               }
+                       }
+                       if (!trigger.equals(chain.trigger)) {
                                return false;
                        }
-               }
-               if (!trigger.equals(chain.trigger)) {
-                       return false;
                }
                if (!action.equals(chain.action)) {
                        return false;