SafeIterableMap implements Iterable<Map.Entry<K, V>> { @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("["); Iterator<Map.Entry<K, V>> iterator = iterator(); while (iterator.hasNext()) { builder.append(iterator.next().toString()); if (iterator.hasNext()) { builder.append(", "); } } builder.append("]"); return builder.toString(); }  V putIfAbsent(@NonNull K key, @NonNull V v); V remove(@NonNull K key); int size(); @NonNull @Override Iterator<Map.Entry<K, V>> iterator(); Iterator<Map.Entry<K, V>> descendingIterator(); IteratorWithAdditions iteratorWithAdditions(); Map.Entry<K, V> eldest(); Map.Entry<K, V> newest(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testToString() { SafeIterableMap<Integer, String> map = from(1, 2, 3, 4).to("a", "b", "c", "d"); assertThat(map.toString(), is("[1=a, 2=b, 3=c, 4=d]")); }
@Test public void testEmptyToString() { SafeIterableMap<Integer, Boolean> map = mapOf(); assertThat(map.toString(), is("[]")); }
@Test public void testOneElementToString() { SafeIterableMap<Integer, Boolean> map = mapOf(1); assertThat(map.toString(), is("[1=true]")); }