Removes the entry for a key only if currently mapped to a given value.
This is equivalent to, for this {@code map}:
<pre> {@code
if (map.containsKey(key)
&& Objects.equals(map.get(key), value)) {
map.remove(key);
return true;
} else {
return false;
}}</pre>
except that the action is performed atomically.
@implNote This implementation intentionally re-abstracts the
inappropriate default provided in {@code Map}.
@param key key with which the specified value is associated
@param value value expected to be associated with the specified key
@return {@code true} if the value was removed
@throws UnsupportedOperationException if the {@code remove} operation
is not supported by this map
@throws ClassCastException if the key or value is of an inappropriate
type for this map
(<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>)
@throws NullPointerException if the specified key or value is null,
and this map does not permit null keys or values
(<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>)
Removes the entry for a key only if currently mapped to a given value. This is equivalent to, for this {@code map}: <pre> {@code if (map.containsKey(key) && Objects.equals(map.get(key), value)) { map.remove(key); return true; } else { return false; }}</pre>
except that the action is performed atomically.
@implNote This implementation intentionally re-abstracts the inappropriate default provided in {@code Map}.
@param key key with which the specified value is associated @param value value expected to be associated with the specified key @return {@code true} if the value was removed @throws UnsupportedOperationException if the {@code remove} operation is not supported by this map @throws ClassCastException if the key or value is of an inappropriate type for this map (<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>) @throws NullPointerException if the specified key or value is null, and this map does not permit null keys or values (<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>)