Add equals() methods because hashCode() was defined

These are reported as 'Blocker' bugs by SonarQube

Change-Id: I6c25e365522f26e9f50b67a57878ad75c42aa9d2
This commit is contained in:
Ray Milkey 2014-11-24 15:02:14 -08:00
parent dde22ae5f4
commit 30edb16a05
2 changed files with 29 additions and 1 deletions

View File

@ -48,6 +48,20 @@ public class Leadership {
return Objects.hash(topic, leader, epoch);
}
@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())

View File

@ -76,6 +76,20 @@ public class LeadershipEvent extends AbstractEvent<LeadershipEvent.Type, Leaders
return Objects.hash(type(), subject(), time());
}
@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())