Java Utililty Methods Map Put

List of utility methods to do Map Put

Description

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

Method

voidputBoolean(Map properties, Object key, boolean value)
put Boolean
properties.put(key, value ? Boolean.TRUE : Boolean.FALSE);
ObjectputByFullKey(Map map, String key, Object value)
put By Full Key
if (key.indexOf(MAP_KEY_SEPARATOR) != -1) {
    String subMapKey = key.substring(0, key.indexOf(MAP_KEY_SEPARATOR));
    String nextKey = key.substring(subMapKey.length() + 1);
    Map subMap;
    if (map.containsKey(subMapKey)) {
        subMap = (Map) map.get(subMapKey);
    } else {
        subMap = new HashMap();
...
Map>putCheckedObjectInInnerMap(Map> mapValues, A key, K innerKey, V obj)
Puts an object to an inner Map of the given Map ( initializes it first if null )
Map<K, V> innerMap = null;
if (mapValues != null && mapValues.containsKey(key)) {
    innerMap = mapValues.get(key);
innerMap = addCheckedObjectInMap(innerMap, innerKey, obj);
mapValues = addCheckedObjectInMap(mapValues, key, innerMap);
return mapValues;
voidputClassToMap(String extensionId, String key, Class className)
put Class To Map
Map<String, List<Class<?>>> map;
if (!extensionClassMap.containsKey(extensionId)) {
    map = new HashMap<String, List<Class<?>>>();
    extensionClassMap.put(extensionId, map);
} else {
    map = extensionClassMap.get(extensionId);
List<Class<?>> classList;
...
voidputData(Map data, String name, Object value)
put Data
String[] names = name.split("[.]");
Map currentMap = data;
for (int i = 0; i < names.length; i++) {
    if (i < (names.length - 1)) {
        Map cmap = (Map) currentMap.get(names[i]);
        if (cmap == null) {
            cmap = new HashMap();
            currentMap.put(names[i], cmap);
...
voidputDataInToMap(String className, String MethodName)
put Data In To Map
mapModuleName.clear();
mapModuleName.put("className", className);
mapModuleName.put("methodName", MethodName);
voidputDeepValue(Map map, String keyPath, T v)
put Deep Value
HashMap subMap = (HashMap) map;
String[] propertyPath = keyPath.toString().split("\\.");
int j = 0;
for (; j < propertyPath.length - 1; j++) {
    String property = propertyPath[j];
    Object value = subMap.get(property);
    if ((value == null) || !(value instanceof Map)) {
        value = new HashMap<>();
...
voidputIfAbsent(final Map from, final Map to)
put If Absent
for (Map.Entry<K, V> entry : from.entrySet()) {
    to.putIfAbsent(entry.getKey(), entry.getValue());
voidputIfAbsent(Map from, Map to)
put If Absent
if (from == null || to == null) {
    return;
for (Map.Entry<K, V> entry : from.entrySet()) {
    if (!to.containsKey(entry.getKey())) {
        to.put(entry.getKey(), entry.getValue());
VputIfAbsent(Map map, K key, V value)
Backwards compatible Map#putIfAbsent to support < Android API 24.
V val = map.get(key);
if (val == null) {
    val = map.put(key, value);
return val;