public final class MapUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object[] |
getKeyObjects(Map<?,?> m) |
static String[] |
getKeyStrings(Map<?,?> m) |
static <K> Set<K> |
getNullValueKeys(Map<K,?> map)
Gets all keys which map to a null value
|
static <K,V> V |
getWithDefault(Map<K,V> m,
K key,
V defaultValue) |
static boolean |
isAllStrings(Map<?,?> map) |
static boolean |
mapsEqual(Map<?,?> map1,
Map<?,?> map2) |
static <K,V> Map<K,V> |
newMap()
assignable to any map type, keeps things short on the rhs
|
static <K,V> Map<K,V> |
newMap(Map<K,V> m1,
Map<K,V> m2)
Create a new Map combined all entries of two other maps.
|
static Map<String,String> |
newMap(String... mappings)
Create a new Map and insert the specified mappings as found in 'mappings'.
|
static <V> Map<String,V> |
newMap(String key,
V value)
Create a new Map consisting of a single key/value pair.
|
static <T> Map<T,T> |
newMap(T... mappings)
Create a new Map and insert the specified mappings as found in 'mappings'.
|
static <K,V> Map<K,V> |
newMapNoNullValues(Map<K,V> map)
Creates a new map with all the old key/value pairs unless the value
was null
|
static <K> void |
removeAll(Map<K,?> map,
Set<K> keySet)
Removes all keys in a set from a map
|
static <T> void |
removeAll(Map<T,?> map,
T[] keys)
Remove all entries keyed by 'keys'
|
static <K,V> Map<K,V> |
toMap(Object[] params,
Class<K> keyClass,
Class<V> valueClass) |
static <K,V> Map<K,V> |
toMap(Properties props,
Class<K> kClass,
Class<V> vClass) |
static String |
toString(Map<?,?> m) |
static String |
toString(Map<?,?> map,
String separator) |
static Map<String,String> |
toStringStringMap(Map<?,?> map)
Convert an arbitrary Map to one whose keys and values
are both of type String.
|
public static <K,V> V getWithDefault(Map<K,V> m, K key, V defaultValue)
public static <K,V> Map<K,V> newMap()
public static <V> Map<String,V> newMap(String key, V value)
public static <K,V> Map<K,V> newMap(Map<K,V> m1, Map<K,V> m2)
public static <T> Map<T,T> newMap(T... mappings)
public static Map<String,String> newMap(String... mappings)
public static <T> void removeAll(Map<T,?> map, T[] keys)
public static <K,V> Map<K,V> newMapNoNullValues(Map<K,V> map)
map - the old map to convertpublic static <K> Set<K> getNullValueKeys(Map<K,?> map)
public static <K,V> Map<K,V> toMap(Properties props, Class<K> kClass, Class<V> vClass)
public static <K> void removeAll(Map<K,?> map, Set<K> keySet)
map - the map to remove keys fromkeySet - a set of keys to removepublic static boolean isAllStrings(Map<?,?> map)
Copyright © 2019. All rights reserved.