Add equals() methods because hashCode() was defined
These are reported as 'Blocker' bugs by SonarQube
Change-Id: I6c25e365522f26e9f50b67a57878ad75c42aa9d2
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/Leadership.java b/core/api/src/main/java/org/onlab/onos/cluster/Leadership.java
index dbf36a5..cf247f5 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/Leadership.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/Leadership.java
@@ -49,6 +49,20 @@
}
@Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Leadership) {
+ final Leadership other = (Leadership) obj;
+ return Objects.equals(this.topic, other.topic) &&
+ Objects.equals(this.leader, other.leader) &&
+ Objects.equals(this.epoch, other.epoch);
+ }
+ return false;
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(this.getClass())
.add("topic", topic)
@@ -56,4 +70,4 @@
.add("epoch", epoch)
.toString();
}
-}
\ No newline at end of file
+}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/LeadershipEvent.java b/core/api/src/main/java/org/onlab/onos/cluster/LeadershipEvent.java
index 246f0fc..bf20270 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/LeadershipEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/LeadershipEvent.java
@@ -77,6 +77,20 @@
}
@Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LeadershipEvent) {
+ final LeadershipEvent other = (LeadershipEvent) obj;
+ return Objects.equals(this.type(), other.type()) &&
+ Objects.equals(this.subject(), other.subject()) &&
+ Objects.equals(this.time(), other.time());
+ }
+ return false;
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(this.getClass())
.add("type", type())