diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java index 23da89269256..f8d2ade49b49 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMap.java @@ -500,6 +500,23 @@ public boolean containsValue(@Nullable Object value) { @Override public abstract V get(@Nullable Object key); + /** + * {@inheritDoc} + * + *

See {@code + * Map.getOrDefault}. + * + * @since 23.5 (but since 21.0 in the JRE flavor). + * Note that API Level 24 users can call this method with any version of Guava. + */ + // @Override under Java 8 / API Level 24 + public final V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { + V result = get(key); + return (result != null) ? result : defaultValue; + } + @LazyInit private transient ImmutableSet> entrySet; /** diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index 6b8fae8df707..c29dc9f70719 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -681,6 +681,11 @@ public boolean containsValue(@Nullable Object value) { @Override public abstract V get(@Nullable Object key); + /** + * @since 21.0 (but only since 23.5 in the Android flavor). + * Note, however, that Java 8 users can call this method with any version and flavor of Guava. + */ @Override public final V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { V result = get(key);