@Test public void testToImmutableList_Parallel() { List<Integer> vals = Arrays.asList(1, 3, 4, 5, 8, 9, 3, 989); ImmutableList<Integer> res = vals.parallelStream().collect(toImmutableList()); assertEquals("[1, 3, 4, 5, 8, 9, 3, 989]", res.toString()); }
public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new; BiConsumer<ImmutableList.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }
Gullectors { public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new; BiConsumer<ImmutableList.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); } }
Gullectors { public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new; BiConsumer<ImmutableList.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }  }
Gullectors { public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new; BiConsumer<ImmutableList.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }  static Collector<T, ?, ImmutableList<T>> toImmutableList(); static Collector<T, ?, ImmutableSet<T>> toImmutableSet(); static Collector<T, ?, ImmutableSortedSet<T>> toNaturalImmutableSortedSet(); static Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
			Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper); }
Gullectors { public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { Supplier<ImmutableList.Builder<T>> supplier = ImmutableList.Builder::new; BiConsumer<ImmutableList.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableList.Builder<T>, ImmutableList<T>> finisher = ImmutableList.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }  static Collector<T, ?, ImmutableList<T>> toImmutableList(); static Collector<T, ?, ImmutableSet<T>> toImmutableSet(); static Collector<T, ?, ImmutableSortedSet<T>> toNaturalImmutableSortedSet(); static Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
			Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper);  }