Add hashCode method on LabelVote and PatchLineComment classes

According to FindBugs:

"This class overrides equals(Object), but does not override hashCode(),
and inherits the implementation of hashCode() from java.lang.Object
(which returns the identity hash code, an arbitrary value assigned to
the object by the VM).  Therefore, the class is very likely to violate
the invariant that equal objects must have equal hashcodes."

Add implementations of hashCode.

Change-Id: I2d01ecdc51f672b4c9b9d2d1617b3625830f6d7d
This commit is contained in:
David Pursehouse 2014-10-15 10:52:17 +09:00
parent 5498c4cd8f
commit dc4a36989a
2 changed files with 10 additions and 0 deletions

View File

@ -248,6 +248,11 @@ public final class PatchLineComment {
return false;
}
@Override
public int hashCode() {
return key.hashCode();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

View File

@ -105,6 +105,11 @@ public class LabelVote {
return false;
}
@Override
public int hashCode() {
return 17 * value + name.hashCode();
}
@Override
public String toString() {
return format();