static <K, V, U extends V, M extends Map<K, V>> M put(M map, Tuple2<? extends K, U> entry, BiFunction<? super V, ? super U, ? extends V> merge) { Objects.requireNonNull(merge, "the merge function is null"); final Option<V> currentValue = map.get(entry._1); if (currentValue.isEmpty()) { return put(map, entry); } else { return put(map, entry.map2(value -> merge.apply(currentValue.get(), value))); } }
static <K, V, U extends V, M extends Map<K, V>> M put(M map, Tuple2<? extends K, U> entry, BiFunction<? super V, ? super U, ? extends V> merge) { Objects.requireNonNull(merge, "the merge function is null"); final Option<V> currentValue = map.get(entry._1); if (currentValue.isEmpty()) { return put(map, entry); } else { return put(map, entry.map2(value -> merge.apply(currentValue.get(), value))); } }