Here you can find the source of putAsStringIfNotNull(Map
public static void putAsStringIfNotNull(Map<String, Object> properties, String key, Object value)
//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); } }