mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8311170: Simplify and modernize equals and hashCode in security area
Reviewed-by: djelinski, rriggs, valeriep
This commit is contained in:
parent
e9f751ab16
commit
19ae62ae2c
96 changed files with 567 additions and 951 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue