Streams { public static <T> Stream<T> collapse(Stream<T> src) { return StreamSupport.stream(new CollapseSpliterator(src.spliterator()), false); } private  Streams(); static Stream<T> collapse(Stream<T> src);  }
@Test public void collapse() { final List<String> src = Arrays.asList("a", "a", "b", "bb", "c", "c", "a"); final Stream<String> collapsed = Streams.collapse(src.stream()).parallel(); final List<String> expected = Arrays.asList("a", "b", "bb", "c", "a"); final Object[] actuals = collapsed.toArray(); Assert.assertArrayEquals(expected.toArray(), actuals); }