# HG changeset patch # User henryjen # Date 1381984466 25200 # Node ID dcad3ccb889a71659d7eed0aa1d04fea3a8a10c2 # Parent 38b088040f4f81a15e873ef8b555ffe74ca99c95 8026768: java.util.Map.Entry comparingBy methods missing @since 1.8 Reviewed-by: dholmes diff -r 38b088040f4f -r dcad3ccb889a jdk/src/share/classes/java/util/Map.java --- a/jdk/src/share/classes/java/util/Map.java Sun Oct 13 14:19:31 2013 +0400 +++ b/jdk/src/share/classes/java/util/Map.java Wed Oct 16 21:34:26 2013 -0700 @@ -465,6 +465,7 @@ * @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 @@ * @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 @@ * @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 @@ * @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 @@ // 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))