Here you can find the source of map(Map map)
public static Map<String, String> map(Map map)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { public static Map<String, String> map(Map map) { if (map == null) { return null; }/*from w w w . j a va2 s. c o m*/ Map<String, String> result = new HashMap<String, String>(); if (map.isEmpty()) { return result; } Set<Entry<String, Object>> entrySet = map.entrySet(); Iterator<Entry<String, Object>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Entry<String, Object> next = iterator.next(); String key = next.getKey(); Object value = next.getValue(); if (value == null) { result.put(key, null); } else { result.put(key, value + ""); } } return result; } public static boolean isEmpty(Object obj) { if (obj == null) { return true; } if ("".equals(obj)) { return true; } return false; } public static <K, V> Map<K, V> put(Map<K, V> map, K key, V value) { V valueOld = map.get(key); if (valueOld == null) { map.put(key, value); } return map; } }