544 * @return the hash code value for this map
545 * @see Map.Entry#hashCode()
546 * @see Object#equals(Object)
547 * @see #equals(Object)
548 */
549 int hashCode();
550
551 // Defaultable methods
552
553 /**
554 * Returns the value to which the specified key is mapped,
555 * or {@code defaultValue} if this map contains no mapping
556 * for the key.
557 *
558 * <p>The default implementation makes no guarantees about synchronization
559 * or atomicity properties of this method. Any implementation providing
560 * atomicity guarantees must override this method and document its
561 * concurrency properties.
562 *
563 * @param key the key whose associated value is to be returned
564 * @return the value to which the specified key is mapped, or
565 * {@code defaultValue} if this map contains no mapping for the key
566 * @throws ClassCastException if the key is of an inappropriate type for
567 * this map
568 * (<a href="Collection.html#optional-restrictions">optional</a>)
569 * @throws NullPointerException if the specified key is null and this map
570 * does not permit null keys
571 * (<a href="Collection.html#optional-restrictions">optional</a>)
572 */
573 default V getOrDefault(Object key, V defaultValue) {
574 V v;
575 return (((v = get(key)) != null) || containsKey(key))
576 ? v
577 : defaultValue;
578 }
579
580 /**
581 * Performs the given action on each entry in this map, in the order entries
582 * are returned by an entry set iterator (which may be unspecified), until
583 * all entries have been processed or the action throws an {@code Exception}.
|
544 * @return the hash code value for this map
545 * @see Map.Entry#hashCode()
546 * @see Object#equals(Object)
547 * @see #equals(Object)
548 */
549 int hashCode();
550
551 // Defaultable methods
552
553 /**
554 * Returns the value to which the specified key is mapped,
555 * or {@code defaultValue} if this map contains no mapping
556 * for the key.
557 *
558 * <p>The default implementation makes no guarantees about synchronization
559 * or atomicity properties of this method. Any implementation providing
560 * atomicity guarantees must override this method and document its
561 * concurrency properties.
562 *
563 * @param key the key whose associated value is to be returned
564 * @param defaultValue the default mapping of the key
565 * @return the value to which the specified key is mapped, or
566 * {@code defaultValue} if this map contains no mapping for the key
567 * @throws ClassCastException if the key is of an inappropriate type for
568 * this map
569 * (<a href="Collection.html#optional-restrictions">optional</a>)
570 * @throws NullPointerException if the specified key is null and this map
571 * does not permit null keys
572 * (<a href="Collection.html#optional-restrictions">optional</a>)
573 */
574 default V getOrDefault(Object key, V defaultValue) {
575 V v;
576 return (((v = get(key)) != null) || containsKey(key))
577 ? v
578 : defaultValue;
579 }
580
581 /**
582 * Performs the given action on each entry in this map, in the order entries
583 * are returned by an entry set iterator (which may be unspecified), until
584 * all entries have been processed or the action throws an {@code Exception}.
|