java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.collect.Maps |
Utility methods for map.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Maps() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static <K, V extends Comparable<V>> LinkedHashMap<K, V> |
createSortedMapByValue(Map<K, V> map, boolean ascending)
Sort a map by its values.
| ||||||||||
static <K, V> V |
get(Map<K, V> map, K key)
Get a value from a potentially null map.
| ||||||||||
static <K, V> V |
get(Map<K, V> map, K key, V safeValue)
Get a value from a potentially null map.
| ||||||||||
static <K, V extends Comparable<V>> List<V> |
getSortedValues(Map<K, V> map)
Retrieve the values of a map, sorted by natural ascending.
| ||||||||||
static <K, V extends Comparable<V>> List<V> |
getSortedValues(Map<K, V> map, boolean ascending)
Retrieve the values of a map, sorted by natural ascending or descending order.
| ||||||||||
static <K, V> HashMap<K, V> |
toMap(K key, V value)
Build a HashMap containing 1 element (key, value).
| ||||||||||
static <K, V> Map<K, V> |
toMap(K key, V value, Class<? extends Map> c)
Build a map containing 1 element (key, value).
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Sort a map by its values. The values must be Comparable objects.
map | a map; it must not contain null values |
---|---|
ascending | true to sort by ascending order, false to sort by descending order |
Get a value from a potentially null map.
map | optional map |
---|---|
key | key |
Get a value from a potentially null map.
map | optional map |
---|---|
key | key |
safeValue | value returned if the map is null or does not contain the provided key |
Retrieve the values of a map, sorted by natural ascending. The values must be Comparable objects.
map | a map; it must not contain null values |
---|
Retrieve the values of a map, sorted by natural ascending or descending order. The values must be Comparable objects.
map | a map; it must not contain null values |
---|---|
ascending | true to sort by ascending order, false to sort by descending order |
Build a HashMap containing 1 element (key, value).
Build a map containing 1 element (key, value).
c | optional requested map type; use null to obtain a HashMap |
---|