@Test public void testToImmutableSet_Parallel() { List<Integer> vals = Arrays.asList(5, 1, 22, 4, 8, 9, 3, 3, 989); ImmutableSet<Integer> res = vals.parallelStream().collect(toImmutableSet()); assertEquals("[5, 1, 22, 4, 8, 9, 3, 989]", res.toString()); }
public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() { Supplier<ImmutableSet.Builder<T>> supplier = ImmutableSet.Builder::new; BiConsumer<ImmutableSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSet.Builder<T>, ImmutableSet<T>> finisher = ImmutableSet.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }
Gullectors { public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() { Supplier<ImmutableSet.Builder<T>> supplier = ImmutableSet.Builder::new; BiConsumer<ImmutableSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSet.Builder<T>, ImmutableSet<T>> finisher = ImmutableSet.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); } }
Gullectors { public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() { Supplier<ImmutableSet.Builder<T>> supplier = ImmutableSet.Builder::new; BiConsumer<ImmutableSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSet.Builder<T>, ImmutableSet<T>> finisher = ImmutableSet.Builder::build; return Collector.of(supplier, accumulator, combiner, finisher); }  }
Gullectors { public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() { Supplier<ImmutableSet.Builder<T>> supplier = ImmutableSet.Builder::new; BiConsumer<ImmutableSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSet.Builder<T>, ImmutableSet<T>> finisher = ImmutableSet.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, ?, ImmutableSet<T>> toImmutableSet() { Supplier<ImmutableSet.Builder<T>> supplier = ImmutableSet.Builder::new; BiConsumer<ImmutableSet.Builder<T>, T> accumulator = (b, v) -> b.add(v); BinaryOperator<ImmutableSet.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); Function<ImmutableSet.Builder<T>, ImmutableSet<T>> finisher = ImmutableSet.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);  }