From: David ‘Bombe’ Roden Date: Fri, 11 Jan 2013 08:56:55 +0000 (+0100) Subject: Use watcher in equals() and hashCode() if it’s not null. X-Git-Tag: 0.1~30 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=dfe8081e8b9036a606bd313239c319cceb52e7df;p=rhynodge.git Use watcher in equals() and hashCode() if it’s not null. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/loader/Chain.java b/src/main/java/net/pterodactylus/rhynodge/loader/Chain.java index 2587d09..d54fae0 100644 --- a/src/main/java/net/pterodactylus/rhynodge/loader/Chain.java +++ b/src/main/java/net/pterodactylus/rhynodge/loader/Chain.java @@ -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;