public <K, D> Map<K, D> groupingBy(Function<? super T, ? extends K> classifier,
            Collector<? super T, ?, D> downstream) {
        if (isParallel() && downstream.characteristics().contains(Characteristics.UNORDERED))
            return rawCollect(Collectors.groupingByConcurrent(classifier, downstream));
        return rawCollect(Collectors.groupingBy(classifier, downstream));
    }
public < K , D > Map < K , D > groupingBy ( Function < ? super T , ? extends K > classifier , Collector < ? super T , ? , D > downstream ) { if ( isParallel ( ) && downstream . characteristics ( ) . contains ( Characteristics . UNORDERED ) ) return rawCollect ( Collectors . groupingByConcurrent ( classifier , downstream ) ) ; return rawCollect ( Collectors . groupingBy ( classifier , downstream ) ) ; }
Returns a {@code Map} whose keys are the values resulting from applying
the classification function to the input elements, and whose
corresponding values are the result of reduction of the input elements
which map to the associated key under the classification function.

<p>
There are no guarantees on the type, mutability or serializability of the
{@code Map} objects returned.

<p>
This is a <a href="package-summary.html#StreamOps">terminal</a>
operation.

@param <K> the type of the keys
@param <D> the result type of the downstream reduction
@param classifier the classifier function mapping input elements to keys
@param downstream a {@code Collector} implementing the downstream
reduction
@return a {@code Map} containing the results of the group-by operation

@see #groupingBy(Function)
@see Collectors#groupingBy(Function, Collector)
@see Collectors#groupingByConcurrent(Function, Collector)