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

voidputIfNotNull(Map map, K key, V value)
put If Not Null
if (map != null && key != null && value != null)
    map.put(key, value);
voidputIfNotNull(Map> params, String key, T value)
put value in map only if not null
if (value != null) {
    params.put(key, Collections.singleton(String.valueOf(value)));
voidputIfNotNullAndTrue(Map map, String key, Boolean boolValue)
Puts a boolean value into a map if the value is not null.
if (Boolean.TRUE.equals(boolValue)) {
    map.put(key, 0);
voidputIfNull(Map map, Object key, Object defaultValue)
put If Null
if (key == null)
    throw new IllegalArgumentException("key must be not null");
if (map == null)
    throw new IllegalArgumentException("map must be not null");
if (map.get(key) == null) {
    map.put(key, defaultValue);
voidputIfSet(Map config, String key, Object... values)
Puts this property in the config if it has been set in any of these values.
for (Object value : values) {
    if (value != null) {
        config.put(key, value.toString());
        return;
voidputIntoMap(Map m, T[] keys, S[] values)
put Into Map
if (keys.length != values.length)
    System.err.println("GAUtils.putIntoMap: Error: keys.length != values.length");
for (int i = 0; i < keys.length; i++)
    m.put(keys[i], values[i]);
HashMapputIntoMap(String key, Object value)
If the value is equal to {skip} then it will be skipped from adding
if (!value.equals("{skip}")) {
    map.put(key, value);
return map;
voidputItem(Map map, Object key, Object value)
put Item
((Map) map).put(key, value);
voidputKV(Map map, String k, Object v)
put KV
map.put(k, v);
voidputLong(Map properties, String key, long value)
put Long
properties.put(key, String.valueOf(value));