From 63f8dbc1d382d52ca8b2711d4c8dc22265d26865 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Wed, 16 Oct 2013 21:34:26 -0700 Subject: [PATCH] 8026768: java.util.Map.Entry comparingBy methods missing @since 1.8 Reviewed-by: dholmes --- jdk/src/share/classes/java/util/Map.java | 45 +++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/jdk/src/share/classes/java/util/Map.java b/jdk/src/share/classes/java/util/Map.java index d1695ef23ee..d67e58db248 100644 --- a/jdk/src/share/classes/java/util/Map.java +++ b/jdk/src/share/classes/java/util/Map.java @@ -465,6 +465,7 @@ public interface Map { * @param the type of the map values * @return a comparator that compares {@link Map.Entry} in natural order on key. * @see Comparable + * @since 1.8 */ public static , V> Comparator> comparingByKey() { return (Comparator> & Serializable) @@ -481,6 +482,7 @@ public interface Map { * @param the {@link Comparable} type of the map values * @return a comparator that compares {@link Map.Entry} in natural order on value. * @see Comparable + * @since 1.8 */ public static > Comparator> comparingByValue() { return (Comparator> & Serializable) @@ -498,6 +500,7 @@ public interface Map { * @param the type of the map values * @param cmp the key {@link Comparator} * @return a comparator that compares {@link Map.Entry} by the key. + * @since 1.8 */ public static Comparator> comparingByKey(Comparator cmp) { Objects.requireNonNull(cmp); @@ -516,6 +519,7 @@ public interface Map { * @param the type of the map values * @param cmp the value {@link Comparator} * @return a comparator that compares {@link Map.Entry} by the value. + * @since 1.8 */ public static Comparator> comparingByValue(Comparator cmp) { Objects.requireNonNull(cmp); @@ -558,26 +562,27 @@ public interface Map { // Defaultable methods /** - * Returns the value to which the specified key is mapped, - * or {@code defaultValue} if this map contains no mapping - * for the key. - * - *

The default implementation makes no guarantees about synchronization - * or atomicity properties of this method. Any implementation providing - * atomicity guarantees must override this method and document its - * concurrency properties. - * - * @param key the key whose associated value is to be returned - * @param defaultValue the default mapping of the key - * @return the value to which the specified key is mapped, or - * {@code defaultValue} if this map contains no mapping for the key - * @throws ClassCastException if the key is of an inappropriate type for - * this map - * (optional) - * @throws NullPointerException if the specified key is null and this map - * does not permit null keys - * (optional) - */ + * Returns the value to which the specified key is mapped, + * or {@code defaultValue} if this map contains no mapping + * for the key. + * + *

The default implementation makes no guarantees about synchronization + * or atomicity properties of this method. Any implementation providing + * atomicity guarantees must override this method and document its + * concurrency properties. + * + * @param key the key whose associated value is to be returned + * @param defaultValue the default mapping of the key + * @return the value to which the specified key is mapped, or + * {@code defaultValue} if this map contains no mapping for the key + * @throws ClassCastException if the key is of an inappropriate type for + * this map + * (optional) + * @throws NullPointerException if the specified key is null and this map + * does not permit null keys + * (optional) + * @since 1.8 + */ default V getOrDefault(Object key, V defaultValue) { V v; return (((v = get(key)) != null) || containsKey(key))