public static String summarizeCollection(Object obj) {
    if (obj instanceof Collection) {
      return String.format(
          "%s{%d entries}", obj.getClass().getSimpleName(), ((Collection<?>) obj).size());
    } else if (obj instanceof Map) {
      return String.format("Map{%d entries}", ((Map<?, ?>) obj).size());
    }
    return Objects.toString(obj);
  }
@Test
  public void summarizeCollection() {
    Set<Integer> set = Sets.newHashSet(1, 2);
    assertEquals("HashSet{2 entries}", CommonUtils.summarizeCollection(set));

    Map<Integer, Long> map = ImmutableMap.of(0, 3L, 1, 1L);
    assertEquals("Map{2 entries}", CommonUtils.summarizeCollection(map));

    TestClassA a = new TestClassA();
    assertEquals(a.toString(), CommonUtils.summarizeCollection(a));
    assertEquals("null", CommonUtils.summarizeCollection(null));
  }