Java Map Put putAsStringIfNotNull(Map properties, String key, Object value)

Here you can find the source of putAsStringIfNotNull(Map properties, String key, Object value)

Description

put As String If Not Null

License

Apache License

Declaration

public static void putAsStringIfNotNull(Map<String, Object> properties, String key, Object value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;

public class Main {
    public static void putAsStringIfNotNull(Map<String, Object> properties, String key, Object value) {
        if (value == null)
            return;
        properties.put(key, toString(value));
    }/* w ww  .  jav a  2s. c  o  m*/

    private static String toString(Object object) {
        if (object == null)
            return null;
        return String.valueOf(object);
    }
}

Related

  1. putAllNonNullValues(Map source, Map target)
  2. putAllObjects(Map targetMap, Map sourceMap)
  3. putAllRecursively(Map destination, Map source)
  4. putAllTransposed( Map> source_key_valueSet, Map output_value_key)
  5. putAsCollection(K key, V value, Map map)
  6. putAt(LinkedHashMap map, K key, V value, int pos)
  7. putBoolean(Map properties, Object key, boolean value)
  8. putByFullKey(Map map, String key, Object value)
  9. putCheckedObjectInInnerMap(Map> mapValues, A key, K innerKey, V obj)