Package com.inductiveautomation.rm.base
Class RMMapUtils
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMMapUtils
-
public class RMMapUtils extends java.lang.Object
Utility methods for use with Java.util.Map.
-
-
Constructor Summary
Constructors Constructor Description RMMapUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
anyElement(java.util.Map aMap)
Returns any element from a map.static <K,V>
booleanboolValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as a boolean.static <K,V>
booleanboolValue(java.util.Map<K,V> aMap, K aKey, boolean defaultValue)
Returns a key value interpreted as a boolean (with optional default value).static java.util.Map
clone(java.util.Map aMap)
Clones a map.static <K,V>
floatfloatValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as a float.static <K,V>
floatfloatValue(java.util.Map<K,V> aMap, K aKey, float defaultValue)
Returns a key value interpreted as a float (with optional default value).static <K,V>
Vget(java.util.Map<K,V> aMap, K aKey)
Returns value for aKey in given map (accepts null map).static <K,V>
Vget(java.util.Map<K,V> aMap, K aKey, V defaultValue)
Returns value for aKey in given map with an optional default value for missing keys.static java.lang.Object
getKey(java.util.Map aMap, java.lang.Object aValue)
Returns the key for a given object in the given map.static java.lang.Object
getKeyId(java.util.Map aMap, java.lang.Object aValue)
Returns the key for a given identical object in the given map.static <K,V>
intintValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as an int.static <K,V>
intintValue(java.util.Map<K,V> aMap, K aKey, int defaultValue)
Returns a key value interpreted as an int (with optional default value).static java.util.Map
newMap(java.lang.Object... theKeyValues)
Creates a new map with given args in key/value sequence.static java.util.Map
newMap(java.lang.Object aKey, java.lang.Object anObj)
Creates a new map for given key and object.static <K,V>
Vput(java.util.Map<K,V> aMap, K aKey, V aValue)
Adds given key and value to given map (removes key if value is null).static java.util.Map
putAllIfAbsent(java.util.Map m1, java.util.Map m2, boolean copyIfAbsent)
Same as putAll, but only adds absent keys (option to copy if there are absent keys).static int
size(java.util.Map aMap)
Returns the size of given map (accepts null map).static java.lang.String
toStringSafe(java.util.Map aMap)
Returns a string representation of map that doesn't recurse.
-
-
-
Method Detail
-
newMap
public static java.util.Map newMap(java.lang.Object aKey, java.lang.Object anObj)
Creates a new map for given key and object.
-
newMap
public static java.util.Map newMap(java.lang.Object... theKeyValues)
Creates a new map with given args in key/value sequence.
-
size
public static int size(java.util.Map aMap)
Returns the size of given map (accepts null map).
-
get
public static <K,V> V get(java.util.Map<K,V> aMap, K aKey)
Returns value for aKey in given map (accepts null map).
-
get
public static <K,V> V get(java.util.Map<K,V> aMap, K aKey, V defaultValue)
Returns value for aKey in given map with an optional default value for missing keys.
-
put
public static <K,V> V put(java.util.Map<K,V> aMap, K aKey, V aValue)
Adds given key and value to given map (removes key if value is null).
-
clone
public static java.util.Map clone(java.util.Map aMap)
Clones a map.
-
boolValue
public static <K,V> boolean boolValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as a boolean.
-
boolValue
public static <K,V> boolean boolValue(java.util.Map<K,V> aMap, K aKey, boolean defaultValue)
Returns a key value interpreted as a boolean (with optional default value).
-
intValue
public static <K,V> int intValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as an int.
-
intValue
public static <K,V> int intValue(java.util.Map<K,V> aMap, K aKey, int defaultValue)
Returns a key value interpreted as an int (with optional default value).
-
floatValue
public static <K,V> float floatValue(java.util.Map<K,V> aMap, K aKey)
Returns a key value interpreted as a float.
-
floatValue
public static <K,V> float floatValue(java.util.Map<K,V> aMap, K aKey, float defaultValue)
Returns a key value interpreted as a float (with optional default value).
-
putAllIfAbsent
public static java.util.Map putAllIfAbsent(java.util.Map m1, java.util.Map m2, boolean copyIfAbsent)
Same as putAll, but only adds absent keys (option to copy if there are absent keys).
-
getKey
public static java.lang.Object getKey(java.util.Map aMap, java.lang.Object aValue)
Returns the key for a given object in the given map.
-
getKeyId
public static java.lang.Object getKeyId(java.util.Map aMap, java.lang.Object aValue)
Returns the key for a given identical object in the given map.
-
anyElement
public static java.lang.Object anyElement(java.util.Map aMap)
Returns any element from a map.
-
toStringSafe
public static java.lang.String toStringSafe(java.util.Map aMap)
Returns a string representation of map that doesn't recurse.
-
-