ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentMap.java (file contents):
Revision 1.40 by dl, Mon Mar 18 12:40:30 2013 UTC vs.
Revision 1.41 by dl, Mon May 27 13:04:27 2013 UTC

# Line 28 | Line 28 | import java.util.Map;
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.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines