Class MultiValueMapCollector<T,K,V>
java.lang.Object
org.springframework.util.MultiValueMapCollector<T,K,V>
- Type Parameters:
T- the type of input elements to the reduction operationK- the key typeV- the value element type
- All Implemented Interfaces:
Collector<T, MultiValueMap<K,V>, MultiValueMap<K, V>>
public final class MultiValueMapCollector<T,K,V>
extends Object
implements Collector<T, MultiValueMap<K,V>, MultiValueMap<K,V>>
A
Collector for building a MultiValueMap from a
Stream.
Copied from the Spring Data Commons project.
- Since:
- 7.0.2
- Author:
- Jens Schauder, Florian Hof, Sam Brannen
-
Nested Class Summary
Nested classes/interfaces inherited from interface Collector
Collector.Characteristics -
Method Summary
Modifier and TypeMethodDescriptionBiConsumer<MultiValueMap<K, V>, T> combiner()Function<MultiValueMap<K, V>, MultiValueMap<K, V>> finisher()static <K,V> MultiValueMapCollector <V, K, V> indexingBy(Function<V, K> indexer) Create a newMultiValueMapCollectorusing the givenindexer.static <T,K, V> MultiValueMapCollector <T, K, V> Create a newMultiValueMapCollectorfrom the given key and value functions.supplier()
-
Method Details
-
of
public static <T,K, MultiValueMapCollector<T,V> K, ofV> (Function<T, K> keyFunction, Function<T, V> valueFunction) Create a newMultiValueMapCollectorfrom the given key and value functions.- Type Parameters:
T- the type of input elements to the reduction operationK- the key typeV- the value element type- Parameters:
keyFunction- aFunctionwhich converts an element of typeTto a key of typeKvalueFunction- aFunctionwhich converts an element of typeTto an element of typeV; supplyFunction.identity()if no conversion should be performed- Returns:
- a new
MultiValueMapCollector - See Also:
-
indexingBy
Create a newMultiValueMapCollectorusing the givenindexer.Delegates to
of(Function, Function), supplying the givenindexeras the key function andFunction.identity()as the value function.For example, if you would like to collect the elements of a
Streamof strings into aMultiValueMapkeyed by the lengths of the strings, you could create such aCollectorviaMultiValueMapCollector.indexingBy(String::length).- Type Parameters:
K- the key typeV- the value element type- Parameters:
indexer- aFunctionwhich converts a value of typeVto a key of typeK- Returns:
- a new
MultiValueMapCollectorbased on anindexer - See Also:
-
supplier
-
accumulator
- Specified by:
accumulatorin interfaceCollector<T,K, V>
-
combiner
-
finisher
-
characteristics
- Specified by:
characteristicsin interfaceCollector<T,K, V>
-