public class MapExtensions extends Object
| Constructor and Description |
|---|
MapExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> K |
getKeyFromValue(Map<K,V> map,
V value)
Returns the first founded key from the given value or null if nothing is found.
|
static <K,V> Collection<K> |
getKeysFromValue(Map<K,V> map,
V value)
Returns a Collection from all founded keys from the given value or null if nothing found.
|
static Map<Integer,Map<String,String>> |
newAssosiativeArrayMap()
Factory method for
Map that acts like a javascript associative array. |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap()
Factory method for create a new
ConcurrentHashMap. |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap(int initialCapacity)
Factory method for create a new
ConcurrentHashMap. |
static <K,V> Map<K,V> |
newHashMap()
Factory method for create a new
HashMap. |
static <K,V> Map<K,V> |
newHashMap(int initialCapacity)
Factory method for create a new
HashMap. |
static <K,V> Map<K,V> |
newLazyMap()
Factory method for create a new
LazyMap from commons-collections4. |
static <K,V> void |
printMap(Map<K,V> msg)
The Method printMap prints the HashMap to the console.
|
static <T> Map<T,T> |
toGenericMap(T[][] twoDimArray)
Converts a two dimensional Array to a Map.
|
static Map<String,String> |
toMap(String[][] twoDimArray)
Converts a two dimensional String Array to a Map.
|
public static <K,V> K getKeyFromValue(Map<K,V> map, V value)
K - the generic type of the keyV - the generic type of the valuemap - The Map.value - The value.public static <K,V> Collection<K> getKeysFromValue(Map<K,V> map, V value)
K - the generic type of the keyV - the generic type of the valuemap - The Map.value - The value.public static Map<Integer,Map<String,String>> newAssosiativeArrayMap()
Map that acts like a javascript associative array.
This Map is the counterpart for the associative array in js.
For instance: in js you can create and fetch associative arrays like this:
$arrayObj[0]['firstName'] = 'Albert'; $arrayObj[0]['lastName'] = 'Einstein'; $arrayObj[1]['firstName'] = 'Neil'; $arrayObj[0]['lastName'] = 'Armstrong';With this method you can do the same like this:
final Map<Integer, Map<String, String>> arrayMap = MapExtensions.newAssosiativeArrayMap();
arrayMap.get(0).put("firstName", "Albert");
arrayMap.get(0).put("lastName", "Einstein");
arrayMap.get(1).put("firstName", "Neil");
arrayMap.get(1).put("lastName", "Armstrong");
Map that acts like a javascript associative array.public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap()
ConcurrentHashMap.K - the generic type of the keyV - the generic type of the valueConcurrentHashMap.public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int initialCapacity)
ConcurrentHashMap.K - the generic type of the keyV - the generic type of the valueinitialCapacity - the initial capacityConcurrentHashMap.public static <K,V> Map<K,V> newHashMap()
HashMap.K - the generic type of the keyV - the generic type of the valueHashMap.public static <K,V> Map<K,V> newHashMap(int initialCapacity)
HashMap.K - the generic type of the keyV - the generic type of the valueinitialCapacity - the initial capacityHashMap.public static <K,V> Map<K,V> newLazyMap()
LazyMap from commons-collections4.K - the generic type of the keyV - the generic type of the valueLazyMap.public static <K,V> void printMap(Map<K,V> msg)
K - the generic type of the keyV - the generic type of the valuemsg - The map to print.public static <T> Map<T,T> toGenericMap(T[][] twoDimArray)
T - the generic typetwoDimArray - The two dimensional Array.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.