public class MapUtils extends Object
Constructor and Description |
---|
MapUtils() |
Modifier and Type | Method and Description |
---|---|
static <K,V> Map<K,V> |
cloneMap(Map<K,V> originalMap)
Creates a clone of a given
Map . |
static List<StringPair> |
toListOfStringPairs(Map<String,String> sourceMap) |
static List<StringTrio> |
toListOfStringTrios(Map<String,Map<String,String>> sourceMap) |
static <T> Map<String,List<T>> |
toMapOfListType(Map<String,List<Object>> map,
Class<T> type)
|
static <T> Map<String,T> |
toMapOfType(Map<String,Object> map,
Class<T> type)
|
static Map<String,List<String>> |
toStringListMap(Map<String,List<Object>> map)
|
static Map<String,String> |
toStringValuedMap(Map<String,Object> map)
|
public static <T> Map<String,T> toMapOfType(Map<String,Object> map, Class<T> type)
T
- the type of the values in the resulting mapmap
- the map with String
keys and Object
valuestype
- the class of the type of the resulting map valuesString
keys and type
valuesIllegalArgumentException
- if the any of the values in the map cannot be converted to the given typepublic static Map<String,List<String>> toStringListMap(Map<String,List<Object>> map)
public static <T> Map<String,List<T>> toMapOfListType(Map<String,List<Object>> map, Class<T> type)
String
keys and List
of Object
values to a map with String
keys and List
of given type of valuesT
- the type of the resulting values in the List
values in the Map
map
- the map with String
keys and List
of Object
valuestype
- the class of the type that the resulting values in the List
values of the Map
String
keys and List
of given type of valuesIllegalArgumentException
- if the any of the objects in any of the lists in the map cannot be converted to
the given typepublic static List<StringPair> toListOfStringPairs(Map<String,String> sourceMap)
public static List<StringTrio> toListOfStringTrios(Map<String,Map<String,String>> sourceMap)
public static <K,V> Map<K,V> cloneMap(Map<K,V> originalMap)
Map
. The original and cloned maps will refer separate objects for Java
immutable entries (keys or values) while both will refer the same objects for mutable objects.K
- the type of the entry keysV
- the type of the entry valuesoriginalMap
- the map to be clonedMap
with the contents of the original map, or empty map if the original map is nullCopyright © 2016–2019 AdroitLogic. All rights reserved.