@Test public void testCollectionToString() { List<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); list.add(3); String result = Strings.toString(list); String expected = "[1, 2, 3]"; assertThat(result, is(expected)); }
private static String collectionToString(Collection collection) { StringBuilder builder = new StringBuilder("["); int count = 0; for (Object element : collection) { if (builder.length() > LOG_CONTENT_MAX_LENGTH) { return builder.append("] (" + count + ":" + collection.size() + ")").toString(); } if (count > 0) { builder.append(", "); } count++; if (element == null) { builder.append("null"); } else { Class elementClass = element.getClass(); if (elementClass.isArray() && elementClass.getComponentType() == Object.class) { Object[] arrayElement = (Object[]) element; arrayToString(arrayElement, builder, new HashSet<Object[]>()); } else { builder.append(toString(element)); } } } return builder.append(']').toString(); }
Strings { private static String collectionToString(Collection collection) { StringBuilder builder = new StringBuilder("["); int count = 0; for (Object element : collection) { if (builder.length() > LOG_CONTENT_MAX_LENGTH) { return builder.append("] (" + count + ":" + collection.size() + ")").toString(); } if (count > 0) { builder.append(", "); } count++; if (element == null) { builder.append("null"); } else { Class elementClass = element.getClass(); if (elementClass.isArray() && elementClass.getComponentType() == Object.class) { Object[] arrayElement = (Object[]) element; arrayToString(arrayElement, builder, new HashSet<Object[]>()); } else { builder.append(toString(element)); } } } return builder.append(']').toString(); } }
Strings { private static String collectionToString(Collection collection) { StringBuilder builder = new StringBuilder("["); int count = 0; for (Object element : collection) { if (builder.length() > LOG_CONTENT_MAX_LENGTH) { return builder.append("] (" + count + ":" + collection.size() + ")").toString(); } if (count > 0) { builder.append(", "); } count++; if (element == null) { builder.append("null"); } else { Class elementClass = element.getClass(); if (elementClass.isArray() && elementClass.getComponentType() == Object.class) { Object[] arrayElement = (Object[]) element; arrayToString(arrayElement, builder, new HashSet<Object[]>()); } else { builder.append(toString(element)); } } } return builder.append(']').toString(); } private  Strings(); }
Strings { private static String collectionToString(Collection collection) { StringBuilder builder = new StringBuilder("["); int count = 0; for (Object element : collection) { if (builder.length() > LOG_CONTENT_MAX_LENGTH) { return builder.append("] (" + count + ":" + collection.size() + ")").toString(); } if (count > 0) { builder.append(", "); } count++; if (element == null) { builder.append("null"); } else { Class elementClass = element.getClass(); if (elementClass.isArray() && elementClass.getComponentType() == Object.class) { Object[] arrayElement = (Object[]) element; arrayToString(arrayElement, builder, new HashSet<Object[]>()); } else { builder.append(toString(element)); } } } return builder.append(']').toString(); } private  Strings();  }
Strings { private static String collectionToString(Collection collection) { StringBuilder builder = new StringBuilder("["); int count = 0; for (Object element : collection) { if (builder.length() > LOG_CONTENT_MAX_LENGTH) { return builder.append("] (" + count + ":" + collection.size() + ")").toString(); } if (count > 0) { builder.append(", "); } count++; if (element == null) { builder.append("null"); } else { Class elementClass = element.getClass(); if (elementClass.isArray() && elementClass.getComponentType() == Object.class) { Object[] arrayElement = (Object[]) element; arrayToString(arrayElement, builder, new HashSet<Object[]>()); } else { builder.append(toString(element)); } } } return builder.append(']').toString(); } private  Strings();   }