Class BLCMapUtils
java.lang.Object
org.broadleafcommerce.common.util.BLCMapUtils
Convenience methods for interacting with maps
- Author:
- Andre Azzolini (apazzolini)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionkeyedListMap
(CV values, TypedClosure<K, V> closure) Given a collection of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to a list of values that map to that key.keyedMap
(CV values, TypedClosure<K, V> closure) Given a collection of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to the value.static <K,
V> Map<K, V> keyedMap
(V[] values, TypedClosure<K, V> closure) Given an array of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to the value.static <K,
V> Map<K, V> valueSortedMap
(Map<K, V> map, Comparator<Map.Entry<K, V>> comparator)
-
Constructor Details
-
BLCMapUtils
public BLCMapUtils()
-
-
Method Details
-
keyedMap
public static <K,CV extends Iterable<V>, Map<K,V> V> keyedMap(CV values, TypedClosure<K, V> closure) Given a collection of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to the value. Note: If two values share the same key, the later one will override the previous one in the returned map- Parameters:
values
-closure
-- Returns:
- the map
- See Also:
-
keyedMap
Given an array of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to the value. Note: If two values share the same key, the later one will override the previous one in the returned map- Parameters:
values
-closure
-- Returns:
- the map
- See Also:
-
keyedListMap
public static <K,CV extends Iterable<V>, Map<K,V> List<V>> keyedListMap(CV values, TypedClosure<K, V> closure) Given a collection of values and a TypedClosure that maps an appropriate key for a given value, returns a HashMap of the key to a list of values that map to that key.- Parameters:
values
-closure
-- Returns:
- the map
- See Also:
-
valueSortedMap
-