mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8267110: Update java.util to use instanceof pattern variable
Reviewed-by: lancea, naoto
This commit is contained in:
parent
0a03fc84b3
commit
a52c4ede2f
29 changed files with 142 additions and 266 deletions
|
@ -307,13 +307,10 @@ public class HashMap<K,V> extends AbstractMap<K,V>
|
|||
public final boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (o instanceof Map.Entry) {
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
||||
if (Objects.equals(key, e.getKey()) &&
|
||||
Objects.equals(value, e.getValue()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return o instanceof Map.Entry<?, ?> e
|
||||
&& Objects.equals(key, e.getKey())
|
||||
&& Objects.equals(value, e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1100,16 +1097,14 @@ public class HashMap<K,V> extends AbstractMap<K,V>
|
|||
return new EntryIterator();
|
||||
}
|
||||
public final boolean contains(Object o) {
|
||||
if (!(o instanceof Map.Entry))
|
||||
if (!(o instanceof Map.Entry<?, ?> e))
|
||||
return false;
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
||||
Object key = e.getKey();
|
||||
Node<K,V> candidate = getNode(key);
|
||||
return candidate != null && candidate.equals(e);
|
||||
}
|
||||
public final boolean remove(Object o) {
|
||||
if (o instanceof Map.Entry) {
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
||||
if (o instanceof Map.Entry<?, ?> e) {
|
||||
Object key = e.getKey();
|
||||
Object value = e.getValue();
|
||||
return removeNode(hash(key), key, value, true, true) != null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue