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