Ensure when equals() is implemented so is hashCode()

Update classes that override `equals()` to ensure that they also
implement `hashCode()`.

Issue: SPR-16968
This commit is contained in:
Phillip Webb
2018-06-25 18:15:59 -07:00
committed by Juergen Hoeller
parent 9de3689f63
commit 634f5c2792
3 changed files with 29 additions and 1 deletions

View File

@@ -192,6 +192,14 @@ public abstract class MethodMatchers {
return (targetClass != null && this.cf2.matches(targetClass));
}
@Override
public int hashCode() {
int hashCode = 17;
hashCode = 37 * hashCode + this.cf1.hashCode();
hashCode = 37 * hashCode + this.cf2.hashCode();
return hashCode;
}
@Override
public boolean equals(Object other) {
if (this == other) {