28 |
|
* @param <V> the type of mapped values |
29 |
|
*/ |
30 |
|
public interface ConcurrentMap<K,V> extends Map<K,V> { |
31 |
+ |
|
32 |
+ |
/** |
33 |
+ |
* {@inheritDoc} |
34 |
+ |
* |
35 |
+ |
* @implNote This implementation assumes that the ConcurrentMap cannot |
36 |
+ |
* contain null values and get() returning null unambiguously means the key |
37 |
+ |
* is absent. Implementations which support null values must override this |
38 |
+ |
* default implementation. |
39 |
+ |
*/ |
40 |
+ |
@Override |
41 |
+ |
default V getOrDefault(Object key, V defaultValue) { |
42 |
+ |
V v; |
43 |
+ |
return ((v = get(key)) != null) ? v : defaultValue; |
44 |
+ |
} |
45 |
+ |
|
46 |
|
/** |
47 |
|
* If the specified key is not already associated |
48 |
|
* with a value, associate it with the given value. |