Package co.kuali.coeus.s3.conv
Class CollectionUtils
- java.lang.Object
-
- co.kuali.coeus.s3.conv.CollectionUtils
-
public final class CollectionUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,U>
Collector<Map.Entry<K,U>,?,ConcurrentMap<K,U>>entriesToConcurrentMap()Convenience method to a return a Collector that converts an Map.Entry to a ConcurrentMap.static <K,U>
Collector<Map.Entry<K,U>,?,Map<K,U>>entriesToMap()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.static <K,V>
Map.Entry<K,V>unsafeCast(Map.Entry entry)This method takes a raw Map.Entry and casts it to a generic kind.static <T,U>
Map<T,U>zipMap(T[] keys, U[] values)Takes an array of keys and an array of values and constructs a map.
-
-
-
Method Detail
-
zipMap
public static <T,U> Map<T,U> zipMap(T[] keys, U[] values)
Takes an array of keys and an array of values and constructs a map. Both key and value arrays must be the same length and non-null.- Type Parameters:
T- the key typeU- the value type- Parameters:
keys- the keys. Cannot be nullvalues- the values. Cannot be null- Returns:
- a map. cannot return null
- Throws:
IllegalArgumentException- if either argument is null or the arrays aren't the same length
-
entry
public static <K,V> Map.Entry<K,V> entry(K key, V value)
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,U>,?,Map<K,U>> 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
-
entriesToConcurrentMap
public static <K,U> Collector<Map.Entry<K,U>,?,ConcurrentMap<K,U>> entriesToConcurrentMap()
Convenience method to a return a Collector that converts an Map.Entry to a ConcurrentMap.- Type Parameters:
K- the key typeU- the value type- Returns:
- A Collector from Map.Entry to ConcurrentMap
-
-