private static String toStringOf(Map<?, ?> m) { return Maps.format(m); }
/** * Returns the {@code String} representation of the given map, or {@code null} if the given map is {@code null}. * * @param map the map to format. * @return the {@code String} representation of the given map. */ public static String format(Map<?, ?> map) { if (map == null) { return null; } Iterator<?> i = map.entrySet().iterator(); if (!i.hasNext()) { return "{}"; } StringBuilder buffer = new StringBuilder(); buffer.append("{"); for (;;) { Entry<?, ?> e = (Entry<?, ?>) i.next(); buffer.append(format(map, e.getKey())); buffer.append('='); buffer.append(format(map, e.getValue())); if (!i.hasNext()) { return buffer.append("}").toString(); } buffer.append(", "); } }