Package org.ametys.core.util
Class LambdaUtils.Collectors
java.lang.Object
org.ametys.core.util.LambdaUtils.Collectors
- Enclosing class:
- LambdaUtils
Some useful
collectors
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiontoLinkedHashMap
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Returns aCollector
that accumulates elements into aLinkedHashMap
whose keys and values are the result of applying the provided mapping functions to the input elements.withListAccumulation
(Function<List<T>, R> finisher)
-
Constructor Details
-
Collectors
public Collectors()
-
-
Method Details
-
toLinkedHashMap
public static <T,K, Collector<T,U> ?, toLinkedHashMapMap<K, U>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Returns aCollector
that accumulates elements into aLinkedHashMap
whose keys and values are the result of applying the provided mapping functions to the input elements.
This is the same asCollectors.toMap(Function, Function)
, but elements are collected into aLinkedHashMap
instead of aHashMap
- Type Parameters:
T
- the type of the input elementsK
- the output type of the key mapping functionU
- the output type of the value mapping function- Parameters:
keyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce values- Returns:
- a
Collector
which collects elements into aLinkedHashMap
whose keys and values are the result of applying mapping functions to the input elements
-
withListAccumulation
A convenient method for creating aCollector
which accumulates elements into aList
, this list being transformed by the provided finisher into the final result.- Type Parameters:
T
- the type of the input elementsR
- the final result type- Parameters:
finisher
- The finisher function for the new collector- Returns:
- the new collector
-