### Question:
ObjectTruncater { private static Collection<Object> truncArray(int size, Supplier<Stream<Object>> valueStreamSupplier, int currentDepth, int maxStringLength, int maxArrayLength, int maxDepth) { if (size > maxArrayLength) { int maxOverLimit = maxArrayLength / 10; int overLimit = size - maxArrayLength; if (overLimit > maxOverLimit) { int halfMax = halfSize(maxArrayLength); return Stream.concat( valueStreamSupplier.get().limit(halfMax) .map(v -> trunc(v, currentDepth + 1, maxStringLength, maxArrayLength, maxDepth)), Stream.concat( Stream.of("skipped " + overLimit + " lines"), valueStreamSupplier.get().skip(halfMax + (long) overLimit) .map(v -> trunc(v, currentDepth + 1, maxStringLength, maxArrayLength, maxDepth)))) .collect(Collectors.toList()); } } return valueStreamSupplier.get() .map(v -> trunc(v, currentDepth + 1, maxStringLength, maxArrayLength, maxDepth)) .collect(Collectors.toList()); } private  ObjectTruncater(); static Map<String, Object> truncateMap(Map<String, Object> value, int maxStringLength, int maxArrayLength, int maxDepth); static Object truncate(Object value, int maxStringLength, int maxArrayLength, int maxDepth);  }### Answer:
@Test public void testTruncArray() { List<Integer> value = Arrays.asList(1, 2, 3, 4, 5); int maxStringLength = 3; int maxArrayLength = 2; int maxDepth = 2; Object result = ObjectTruncater.truncate(value, maxStringLength, maxArrayLength, maxDepth); assertEquals(Arrays.asList(1, "skipped 3 lines", 5), result); }