ListUtils { public static <T> Collector<T, ?, List<T>> joining(Supplier<? extends T> separator) { return joining(() -> null, separator, () -> null); } private  ListUtils(); static int firstIndexOf(List<? extends T> list, Predicate<? super T> predicate); static boolean addIfNotPresent(List<? super T> list, T element); static boolean addIfNotPresent(List<? super T> list, int index, T element); static Collector<T, ?, ImmutableList<T>> toImmutableList(); static Collector<T, ?, List<T>> joining(Supplier<? extends T> separator); static Collector<T, ?, List<T>> joining(Supplier<? extends T> prefix,
                                                     Supplier<? extends T> separator,
                                                     Supplier<? extends T> suffix); static Replacement<T> replaceIn(List<T> list);  }
@Test public void testJoiningNoSeparatorsNoBookends() { List<String> list = Arrays.asList(foo, bar); List<String> result = list.stream().collect(joining(nullSupplier, nullSupplier, nullSupplier)); assertEquals(list, result); }
@Test public void testJoiningNoSeparatorsWithBookends() { List<String> result = Stream.of(foo, foo, foo) .collect(joining(barSupplier, nullSupplier, barSupplier)); assertEquals(Arrays.asList(bar, foo, foo, foo, bar), result); }
@Test public void testJoining1NoBookends() { assertEquals( Collections.singletonList(foo), Stream.of(foo).collect(joining(barSupplier)) ); }
@Test public void testJoining1WithBookends() { assertEquals( Arrays.asList(bar, foo, bar), Stream.of(foo).collect(joining(barSupplier, barSupplier, barSupplier)) ); }
@Test public void testJoining2() { List<? extends String> list = Stream.of(foo, foo) .collect(joining(barSupplier)); assertEquals(Arrays.asList(foo, bar, foo), list); }
@Test public void testJoining3() { List<? extends String> list = Stream.of(foo, foo, foo) .collect(joining(barSupplier)); assertEquals(Arrays.asList(foo, bar, foo, bar, foo), list); }
@Test public void testJoining2Bookend() { List<? extends String> list = Stream.of(foo, foo) .collect(joining(barSupplier, barSupplier, barSupplier)); assertEquals(Arrays.asList(bar, foo, bar, foo, bar), list); }
@Test public void testJoining3Bookend() { List<? extends String> list = Stream.of(foo, foo, foo) .collect(joining(barSupplier, barSupplier, barSupplier)); assertEquals(Arrays.asList(bar, foo, bar, foo, bar, foo, bar), list); }