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:
parent
5498c4cd8f
commit
dc4a36989a
@ -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();
|
||||
|
@ -105,6 +105,11 @@ public class LabelVote {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 17 * value + name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format();
|
||||
|
Loading…
Reference in New Issue
Block a user