Commit 100988c5 authored by liaozan's avatar liaozan 🏀

Remove StreamUtils#toMap duplicate message

parent 5a58e3d9
...@@ -88,11 +88,7 @@ public class StreamUtils { ...@@ -88,11 +88,7 @@ public class StreamUtils {
} }
public static <K, T, V, M extends Map<K, V>> Map<K, V> toMap(Iterable<T> data, Function<T, K> keyMapper, Function<T, V> valueMapper, Supplier<M> mapFactory) { public static <K, T, V, M extends Map<K, V>> Map<K, V> toMap(Iterable<T> data, Function<T, K> keyMapper, Function<T, V> valueMapper, Supplier<M> mapFactory) {
return from(data).collect(Collectors.toMap(keyMapper, valueMapper, (oldValue, newValue) -> { return from(data).collect(Collectors.toMap(keyMapper, valueMapper, (oldValue, newValue) -> oldValue, mapFactory));
// Could not get the key when mergeFunction invoke
log.warn("There are multiple values with the same key when toMap, return the old one");
return oldValue;
}, mapFactory));
} }
public static <K, T> Map<K, List<T>> groupBy(Iterable<T> data, Function<T, K> mapper) { public static <K, T> Map<K, List<T>> groupBy(Iterable<T> data, Function<T, K> mapper) {
...@@ -156,4 +152,4 @@ public class StreamUtils { ...@@ -156,4 +152,4 @@ public class StreamUtils {
return StreamSupport.stream(source.spliterator(), parallel); return StreamSupport.stream(source.spliterator(), parallel);
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment