overriding hashCode and equals methods in AbstractClusterMonitor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b17c175a Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b17c175a Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b17c175a Branch: refs/heads/master Commit: b17c175a9b66fbe79cba935e8ac4f0e85ad3b366 Parents: b6cbba2 Author: R-Rajkumar <[email protected]> Authored: Sat Nov 8 21:31:45 2014 +0530 Committer: R-Rajkumar <[email protected]> Committed: Sat Nov 8 21:31:45 2014 +0530 ---------------------------------------------------------------------- .../monitor/cluster/AbstractClusterMonitor.java | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/b17c175a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index 0cac9f2..755931c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -177,6 +177,37 @@ public abstract class AbstractClusterMonitor extends Monitor implements Runnable public abstract void handleClusterRemovedEvent(ClusterRemovedEvent clusterRemovedEvent); public abstract void handleDynamicUpdates(Properties properties) throws InvalidArgumentException; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.clusterId == null) ? 0 : this.clusterId.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof AbstractClusterMonitor)) { + return false; + } + final AbstractClusterMonitor other = (AbstractClusterMonitor) obj; + if (this.clusterId == null) { + if (other.clusterId != null) { + return false; + } + } + if (!this.clusterId.equals(other.clusterId)) { + return false; + } + return true; + } public String getClusterId() { return clusterId;
