src/main/java/com/zandero/utils/MapUtils.java
public static <K, V, M extends Map<K, V>> M merge(Stream<? extends Map<K, V>> stream,
	                                                  BinaryOperator<V> mergeFunction,
	                                                  Supplier<M> mapSupplier) {

		Assert.notNull(stream, "Missing map merge function!");
		Assert.notNull(mergeFunction, "Missing map merge function!");
		Assert.notNull(mapSupplier, "Missing map supplier!");

		return stream.collect(mapSupplier,
		                      (a, b) -> b.forEach((k, v) -> a.merge(k, v, mergeFunction)),
		                      Map::putAll);
	}
public static <K, V, M extends Map<K, V>> M merge(Stream<? extends Map<K, V>> stream,
	                                                  BinaryOperator<V> mergeFunction,
	                                                  Supplier<M> mapSupplier) {

		Assert.notNull(stream, "Missing map merge function!");
		Assert.notNull(mergeFunction, "Missing map merge function!");
		Assert.notNull(mapSupplier, "Missing map supplier!");

		return stream.collect(mapSupplier,
		                      (a, b) -> b.forEach((k, v) -> a.merge(k, v, mergeFunction)),
		                      Map::putAll);
	}
public static < K , V , M extends Map < K , V > > M merge ( Stream < ? extends Map < K , V > > stream , BinaryOperator < V > mergeFunction , Supplier < M > mapSupplier ) { Assert . notNull ( stream , "Missing map merge function!" ) ; Assert . notNull ( mergeFunction , "Missing map merge function!" ) ; Assert . notNull ( mapSupplier , "Missing map supplier!" ) ; return stream . collect ( mapSupplier , ( a , b ) -> b . forEach ( ( k , v ) -> a . merge ( k , v , mergeFunction ) ) , Map :: putAll ) ; }
Merging single level aggregation maps

@param stream        source to merge
@param mergeFunction operation
@param mapSupplier   new map supplier
@param <K>           type of key
@param <V>           type of value
@param <M>           type of map supplier
@return new merged map
Merging single level aggregation maps