Java Utililty Methods Map Add

List of utility methods to do Map Add

Description

The list of methods to do Map Add are organized into topic(s).

Method

voidaddToMap(String aDimensionCriteria, Map aDrilldownDimensions)
add To Map
int p = aDimensionCriteria.indexOf("=");
aDrilldownDimensions.put(aDimensionCriteria.substring(0, p), aDimensionCriteria.substring(p + 1));
voidaddToMap(String key, Map map, String value)
add To Map
map.put(key, value);
voidaddToMapIfNotNull(Map map, K key, V value)
Adds a value V into a map under key K only if the value is not null.
if (value == null) {
    return;
map.put(key, value);
voidaddToMapIfNotNull(Map map, String key, Object value)
add To Map If Not Null
addToMapIfNotNull(map, key, value, "");
voidaddToMapListUnique(Map> mapList, T key, List values)
add To Map List Unique
List<U> list = mapList.get(key);
if (list == null) {
    list = new ArrayList<U>(values.size());
    mapList.put(key, list);
for (U value : values) {
    if (!list.contains(value)) {
        list.add(value);
...
voidaddToMapMap(Map> map, K1 key1, K2 key2, V value)
Adds the given key-value mapping to the given map.
Map<K2, V> innerMap = map.get(key1);
if (innerMap == null) {
    innerMap = new HashMap<K2, V>();
    map.put(key1, innerMap);
innerMap.put(key2, value);
voidaddToMapMap(Map> map, T key, V val)
add To Map Map
if (!map.containsKey(key)) {
    Map<V, Integer> newMap = new HashMap<V, Integer>();
    addToMap(newMap, val);
    map.put(key, newMap);
} else {
    addToMap(map.get(key), val);
voidaddToMapOfLists(Map> map, S key, T value)
add To Map Of Lists
List<T> list = map.get(key);
if (list == null) {
    list = new ArrayList<T>();
    map.put(key, list);
list.add(value);
MaparrayAsMap(Object... t)
array As Map
if (t == null || t.length <= 0) {
    return null;
if (t.length % 2 != 0) {
    throw new RuntimeException("illegal args count");
Map<String, Object> params = new HashMap<String, Object>(t.length);
for (int i = 0; i < t.length; i += 2) {
...
MaparrayToMap(int[] array)
array To Map
Map<Integer, Integer> ret = new HashMap<Integer, Integer>();
for (int i = 0; i < array.length; i++)
    ret.put(i + 1, array[i]);
return ret;