Ray Milkey

Add equals() methods because hashCode() was defined

These are reported as 'Blocker' bugs by SonarQube

Change-Id: I6c25e365522f26e9f50b67a57878ad75c42aa9d2
...@@ -49,6 +49,20 @@ public class Leadership { ...@@ -49,6 +49,20 @@ public class Leadership {
49 } 49 }
50 50
51 @Override 51 @Override
52 + public boolean equals(Object obj) {
53 + if (this == obj) {
54 + return true;
55 + }
56 + if (obj instanceof Leadership) {
57 + final Leadership other = (Leadership) obj;
58 + return Objects.equals(this.topic, other.topic) &&
59 + Objects.equals(this.leader, other.leader) &&
60 + Objects.equals(this.epoch, other.epoch);
61 + }
62 + return false;
63 + }
64 +
65 + @Override
52 public String toString() { 66 public String toString() {
53 return MoreObjects.toStringHelper(this.getClass()) 67 return MoreObjects.toStringHelper(this.getClass())
54 .add("topic", topic) 68 .add("topic", topic)
...@@ -56,4 +70,4 @@ public class Leadership { ...@@ -56,4 +70,4 @@ public class Leadership {
56 .add("epoch", epoch) 70 .add("epoch", epoch)
57 .toString(); 71 .toString();
58 } 72 }
59 -}
...\ No newline at end of file ...\ No newline at end of file
73 +}
......
...@@ -77,6 +77,20 @@ public class LeadershipEvent extends AbstractEvent<LeadershipEvent.Type, Leaders ...@@ -77,6 +77,20 @@ public class LeadershipEvent extends AbstractEvent<LeadershipEvent.Type, Leaders
77 } 77 }
78 78
79 @Override 79 @Override
80 + public boolean equals(Object obj) {
81 + if (this == obj) {
82 + return true;
83 + }
84 + if (obj instanceof LeadershipEvent) {
85 + final LeadershipEvent other = (LeadershipEvent) obj;
86 + return Objects.equals(this.type(), other.type()) &&
87 + Objects.equals(this.subject(), other.subject()) &&
88 + Objects.equals(this.time(), other.time());
89 + }
90 + return false;
91 + }
92 +
93 + @Override
80 public String toString() { 94 public String toString() {
81 return MoreObjects.toStringHelper(this.getClass()) 95 return MoreObjects.toStringHelper(this.getClass())
82 .add("type", type()) 96 .add("type", type())
......