public abstract class MapUtils extends Object
Some methods to work with maps.
| Modifier and Type | Method and Description |
|---|---|
static Object |
getFirstValue(Map<?,?> map,
Object key,
Object defaultValue)
Get the first value with the specified key.
|
static BigDecimal |
getValueAsBigDecimal(Map<?,?> map,
Object key,
BigDecimal defaultValue)
Get a value as
BigDecimal. |
static BigInteger |
getValueAsBigInteger(Map<?,?> map,
Object key,
BigInteger defaultValue)
Get a value as
BigInteger. |
static Boolean |
getValueAsBoolean(Map<?,?> map,
Object key,
Boolean defaultValue)
Get a value as boolean.
|
static Byte |
getValueAsByte(Map<?,?> map,
Object key,
Byte defaultValue)
Get a value as byte.
|
static Collection<?> |
getValueAsCollection(Map<?,?> map,
Object key)
Get a value as collection.
|
static Double |
getValueAsDouble(Map<?,?> map,
Object key,
Double defaultValue)
Get a value as double.
|
static <T extends Enum<T>> |
getValueAsEnum(Map<?,?> map,
Object key,
Class<T> enumType,
T defaultValue)
Get a value as enumeration.
|
static Float |
getValueAsFloat(Map<?,?> map,
Object key,
Float defaultValue)
Get a value as float.
|
static Integer |
getValueAsInteger(Map<?,?> map,
Object key,
Integer defaultValue)
Get a value as integer.
|
static List<?> |
getValueAsList(Map<?,?> map,
Object key)
Get a value as list.
|
static Long |
getValueAsLong(Map<?,?> map,
Object key,
Long defaultValue)
Get a value as long.
|
static Set<?> |
getValueAsSet(Map<?,?> map,
Object key)
Get a value as set.
|
static Short |
getValueAsShort(Map<?,?> map,
Object key,
Short defaultValue)
Get a value as short.
|
static String |
getValueAsString(Map<?,?> map,
Object key,
String defaultValue)
Get a value as string.
|
static <K,V> Map<K,V> |
sort(Map<? extends K,? extends V> map)
Sort the map by the values natural sort order and return an unmodifiable
map.
|
static <K,V> Map<K,V> |
sort(Map<? extends K,? extends V> map,
Comparator<? extends V> valueComparator)
Sort the map by it's values and return an unmodifiable map.
|
public static <K,V> Map<K,V> sort(Map<? extends K,? extends V> map)
map - the mappublic static <K,V> Map<K,V> sort(Map<? extends K,? extends V> map, Comparator<? extends V> valueComparator)
map - the mapvalueComparator - a value comparatorpublic static Object getFirstValue(Map<?,?> map, Object key, Object defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Collection<?> getValueAsCollection(Map<?,?> map, Object key)
map - the mapkey - the keypublic static List<?> getValueAsList(Map<?,?> map, Object key)
map - the mapkey - the keypublic static Set<?> getValueAsSet(Map<?,?> map, Object key)
map - the mapkey - the keypublic static String getValueAsString(Map<?,?> map, Object key, String defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Boolean getValueAsBoolean(Map<?,?> map, Object key, Boolean defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static BigInteger getValueAsBigInteger(Map<?,?> map, Object key, BigInteger defaultValue)
BigInteger. If no value exists with the specified
key, the default value will be returned. If the value cannot be cast to
the return type, the default value will be returned, too.map - the mapkey - the keydefaultValue - a default valuepublic static Long getValueAsLong(Map<?,?> map, Object key, Long defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Integer getValueAsInteger(Map<?,?> map, Object key, Integer defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Byte getValueAsByte(Map<?,?> map, Object key, Byte defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Short getValueAsShort(Map<?,?> map, Object key, Short defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static BigDecimal getValueAsBigDecimal(Map<?,?> map, Object key, BigDecimal defaultValue)
BigDecimal. If no value exists with the specified
key, the default value will be returned. If the value cannot be cast to
the return type, the default value will be returned, too.map - the mapkey - the keydefaultValue - a default valuepublic static Double getValueAsDouble(Map<?,?> map, Object key, Double defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static Float getValueAsFloat(Map<?,?> map, Object key, Float defaultValue)
map - the mapkey - the keydefaultValue - a default valuepublic static <T extends Enum<T>> T getValueAsEnum(Map<?,?> map, Object key, Class<T> enumType, T defaultValue)
map - the mapkey - the keyenumType - the enumeration type (can only be null if default value is not
null or a value of the specified key exists and has a type of
the wanted enumerationdefaultValue - a default valueCopyright © 2017 bremersee.org. All rights reserved.