Package com.persequor.helpers
Class Collectors
java.lang.Object
com.persequor.helpers.Collectors
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <X> XthrowOnMerge(X a, X b) Helper method to be used as merge function, when duplicate keys are not expected.static <T,K> Collector<T, ?, LinkedHashMap<K, T>> toOrderedMap(Function<T, K> keyMapper) Returns a Collector that accumulates elements into a LinkedHashMap whose keys are the result of applying the provided keyMapper function to the input elements, and whose values are the input elements.static <T,K, U> Collector<T, ?, LinkedHashMap<K, U>> toOrderedMap(Function<T, K> keyMapper, Function<T, U> valueMapper) Returns a Collector that accumulates elements into a LinkedHashMap whose keys and values are the result of applying the provided mapping functions to the input elements.
- 
Constructor Details- 
Collectorspublic Collectors()
 
- 
- 
Method Details- 
toOrderedMapReturns a Collector that accumulates elements into a LinkedHashMap whose keys are the result of applying the provided keyMapper function to the input elements, and whose values are the input elements.- Type Parameters:
- T- the type of the input elements and map values
- K- the type of the map keys
- Parameters:
- keyMapper- A function that returns a key for an element
- Returns:
- a Collector which collects elements into a LinkedHashMap, in encounter order
 
- 
toOrderedMappublic static <T,K, Collector<T,U> ?, toOrderedMapLinkedHashMap<K, U>> (Function<T, K> keyMapper, Function<T, U> valueMapper) Returns a Collector that accumulates elements into a LinkedHashMap whose keys and values are the result of applying the provided mapping functions to the input elements.- Type Parameters:
- T- the type of the input elements
- K- the type of the map keys
- U- the type of the map values
- Parameters:
- keyMapper- a mapping function to produce keys
- valueMapper- a mapping function to produce values
- Returns:
- a Collector which collects elements into a LinkedHashMap, in encounter order
 
- 
throwOnMergepublic static <X> X throwOnMerge(X a, X b) Helper method to be used as merge function, when duplicate keys are not expected.- Parameters:
- a- ignored
- b- ignored
- Throws:
- IllegalStateException- always
 
 
-