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

voidputLowerNotNull(Map m, String k, V v)
Put a lowercase version of k in the map if it is non-null
if (k != null)
    m.put(k.toLowerCase(), v);
voidputMap(Map map, Object... args)
Add entries to a Map.
int pos = 0;
Object key = null;
for (Object arg : args) {
    if ((pos & 1) != 0)
        map.put(key, arg);
    else
        key = arg;
    ++pos;
...
voidputMap(Map target, Map map)
put Map
for (Entry<K, V> entry : map.entrySet()) {
    target.put(entry.getKey().toString(), entry.getValue().toString());
booleanputMapBoolean(Map params, String key)
put Map Boolean
return params.containsKey(key) && !params.get(key).equals("");
MapputMapBooleanList(Map params, String... keys)
put Map Boolean List
Map<String, Object> resultMap = new HashMap<>();
Arrays.stream(keys).filter(key -> params.containsKey(key) && !params.get(key).equals(""))
        .forEach(key -> resultMap.put(change(key), params.get(key)));
return resultMap;
voidputMapByPair(String pair, Map m)
put Map By Pair
if (null == pair || "".equals(pair)) {
    return;
int indexOf = pair.indexOf("=");
if (-1 != indexOf) {
    String k = pair.substring(0, indexOf);
    String v = pair.substring(indexOf + 1, pair.length());
    if (null != k && !"".equals(k)) {
...
voidputMapEntry(Map map, String name, String value)
Put name and value pair in map.
String[] newValues = null;
String[] oldValues = map.get(name);
if (oldValues == null) {
    newValues = new String[1];
    newValues[0] = value;
} else {
    newValues = new String[oldValues.length + 1];
    System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
...
booleanputMapNotNullKey(Map map, K key, V value)
add key-value pair to map, key need not null
if (map == null || key == null) {
    return false;
map.put(key, value);
return true;
voidputMapValue(String path, Object value, Map map)
put Map Value
if (path == null || path.trim().isEmpty()) {
    return;
String[] split = path.split("\\.");
Map<String, Object> targetMap = map;
for (int i = 0; i < split.length - 1; i++) {
    String key = split[i];
    Object intermediateMap = (Map<String, Object>) targetMap.get(key);
...
MapputModifiedAttribute(Map aMap, String name, Object value)
put Modified Attribute
if (aMap == null) {
    aMap = new HashMap();
aMap.put(name, value);
return aMap;