8311170: Simplify and modernize equals and hashCode in security area

Reviewed-by: djelinski, rriggs, valeriep
This commit is contained in:
Pavel Rappo 2023-08-09 12:34:40 +00:00
parent e9f751ab16
commit 19ae62ae2c
96 changed files with 567 additions and 951 deletions

View file

@ -5315,13 +5315,15 @@ class Pair<A, B> {
return "Pair[" + fst + "," + snd + "]";
}
public boolean equals(Object other) {
@Override
public boolean equals(Object obj) {
return
other instanceof Pair &&
Objects.equals(fst, ((Pair)other).fst) &&
Objects.equals(snd, ((Pair)other).snd);
obj instanceof Pair<?, ?> other &&
Objects.equals(fst, other.fst) &&
Objects.equals(snd, other.snd);
}
@Override
public int hashCode() {
if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1;
else if (snd == null) return fst.hashCode() + 2;