Package org.kuali.coeus.s2sgen.impl.util
Class CollectionUtils
java.lang.Object
org.kuali.coeus.s2sgen.impl.util.CollectionUtils
Yet another collection utility. Contains methods that are not found in the apache util classes or the
jdk util classes.
-
Method Summary
Modifier and TypeMethodDescriptionConvenience method to a return a Collector that converts an Map.Entry to a Map.entriesToMap(Supplier<M> mapSupplier) Convenience method to a return a Collector that converts an Map.Entry to a Map which type is provided as a mapSupplier.Convenience method to a return a Collector that converts an Map.Entry to a Map.static <K,V> Map.Entry <K, V> entry(K key, V value) Creates an entry from a key and value.Convenience method to a return a Collector that converts an Map.Entry to a Map.nullSafeToMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Null-safe replacement for Collectors.toMap.
-
Method Details
-
entry
Creates an entry from a key and value.- Type Parameters:
K- the key typeV- the value type- Parameters:
key- the key. Can be null.value- the value. Can be null.- Returns:
- a Map.Entry
-
entriesToMap
public static <K,U, Collector<Map.Entry<K,M extends Map<K, U>> U>, entriesToMap?, M> (Supplier<M> mapSupplier) Convenience method to a return a Collector that converts an Map.Entry to a Map which type is provided as a mapSupplier.- Type Parameters:
K- the key typeU- the value typeM- the map type- Parameters:
mapSupplier- supplies a new instance of a Map. cannot be null.- Returns:
- A Collector from Map.Entry to Map as defined by the mapSupplier
-
entriesToMap
Convenience method to a return a Collector that converts an Map.Entry to a Map.- Type Parameters:
K- the key typeU- the value type- Returns:
- A Collector from Map.Entry to Map
-
entriesToMapWithReplacing
Convenience method to a return a Collector that converts an Map.Entry to a Map. If a duplicate key is detected, the value is replaced rather throwing an exception as is the default behavior.- Type Parameters:
K- the key typeU- the value type- Returns:
- A Collector from Map.Entry to Map
-
nullSafeEntriesToMap
Convenience method to a return a Collector that converts an Map.Entry to a Map.- Type Parameters:
K- the key typeU- the value type- Returns:
- A Collector from Map.Entry to Map
-
nullSafeToMap
public static <T,K, Collector<T,U> ?, nullSafeToMapMap<K, U>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) Null-safe replacement for Collectors.toMap. Allows null keys and values. If a duplicate key is found, throws IllegalStateException- Parameters:
keyMapper- function to get the key from the itemsvalueMapper- function to get the value from the items- Returns:
- A Collector from List to Map
-