@SuppressWarnings("unchecked") @Override public M replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { return (M) map((k, v) -> Tuple(k, function.apply(k, v))); }
@SuppressWarnings("unchecked") static <K, V, M extends Map<K, V>> M replaceAll(M map, BiFunction<? super K, ? super V, ? extends V> function) { return (M) map.map((k, v) -> Tuple(k, function.apply(k, v))); }
@SuppressWarnings("unchecked") static <K, V, M extends Map<K, V>> M replace(M map, K key, V oldValue, V newValue) { return map.contains(Tuple(key, oldValue)) ? (M) map.put(key, newValue) : map; }
@SuppressWarnings("unchecked") @Override public M replace(K key, V oldValue, V newValue) { return (M) (contains(Tuple(key, oldValue)) ? remove(key, oldValue).put(key, newValue) : this); }
@SuppressWarnings("unchecked") @Override public M replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { return (M) map((k, v) -> Tuple(k, function.apply(k, v))); }
@SuppressWarnings("unchecked") static <K, V, M extends Map<K, V>> M replaceAll(M map, BiFunction<? super K, ? super V, ? extends V> function) { return (M) map.map((k, v) -> Tuple(k, function.apply(k, v))); }
@SuppressWarnings("unchecked") static <K, V, M extends Map<K, V>> M replace(M map, K key, V oldValue, V newValue) { return map.contains(Tuple(key, oldValue)) ? (M) map.put(key, newValue) : map; }
@SuppressWarnings("unchecked") @Override public M replace(K key, V oldValue, V newValue) { return (M) (contains(Tuple(key, oldValue)) ? remove(key, oldValue).put(key, newValue) : this); }