java.lang.Object
org.litebridge.commons.collector.MapCollector
Utility class for Collectors providing functionality to create
LinkedHashMap instances.
This class contains static methods for collecting elements of a Stream into a
LinkedHashMap. It uses user-provided mapping functions to determine
both the keys and values of the resulting map.
The class is final and contains a private constructor to prevent instantiation, as it is intended to be used solely as a utility class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,K, U> Collector <T, ?, LinkedHashMap<K, U>> toLinkedHashMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Returns aCollectorthat accumulates elements into aLinkedHashMap.
-
Method Details
-
toLinkedHashMap
public static <T,K, Collector<T,U> ?, toLinkedHashMapLinkedHashMap<K, U>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Returns aCollectorthat accumulates elements into aLinkedHashMap.- Type Parameters:
T- the type of the input elements.K- the output type of the key mapping function.U- the output type of the value mapping function.- Parameters:
keyMapper- a mapping function to produce keys.valueMapper- a mapping function to produce values.- Returns:
- a
Collectorwhich collects elements into aLinkedHashMapin insertion order.
-