@Test public void testToList() { List<Integer> expected = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); List<Integer> list = Stream.range(0, 10) .collect(Collectors.<Integer>toList()); assertThat(list, is(expected)); }
@NotNull public static <T> Collector<T, ?, List<T>> toList() { return new CollectorsImpl<T, List<T>, List<T>>( new Supplier<List<T>>() { @NotNull @Override public List<T> get() { return new ArrayList<T>(); } }, new BiConsumer<List<T>, T>() { @Override public void accept(@NotNull List<T> t, T u) { t.add(u); } } ); }
Collectors { @NotNull public static <T> Collector<T, ?, List<T>> toList() { return new CollectorsImpl<T, List<T>, List<T>>( new Supplier<List<T>>() { @NotNull @Override public List<T> get() { return new ArrayList<T>(); } }, new BiConsumer<List<T>, T>() { @Override public void accept(@NotNull List<T> t, T u) { t.add(u); } } ); } }
Collectors { @NotNull public static <T> Collector<T, ?, List<T>> toList() { return new CollectorsImpl<T, List<T>, List<T>>( new Supplier<List<T>>() { @NotNull @Override public List<T> get() { return new ArrayList<T>(); } }, new BiConsumer<List<T>, T>() { @Override public void accept(@NotNull List<T> t, T u) { t.add(u); } } ); } private  Collectors(); }
Collectors { @NotNull public static <T> Collector<T, ?, List<T>> toList() { return new CollectorsImpl<T, List<T>, List<T>>( new Supplier<List<T>>() { @NotNull @Override public List<T> get() { return new ArrayList<T>(); } }, new BiConsumer<List<T>, T>() { @Override public void accept(@NotNull List<T> t, T u) { t.add(u); } } ); } private  Collectors(); @NotNull static Collector<T, ?, R> toCollection(
            @NotNull Supplier<R> collectionSupplier); @NotNull static Collector<T, ?, List<T>> toList(); @NotNull static Collector<T, ?, List<T>> toUnmodifiableList(); @NotNull static Collector<T, ?, Set<T>> toSet(); @NotNull static Collector<T, ?, Set<T>> toUnmodifiableSet(); @NotNull static Collector<T, ?, Map<K, T>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper); @NotNull static Collector<T, ?, Map<K, V>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper); @NotNull static Collector<T, ?, M> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final Supplier<M> mapFactory); @NotNull static Collector<T, ?, Map<K, V>> toUnmodifiableMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper); @NotNull static Collector<T, ?, Map<K, V>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction); @NotNull static Collector<T, ?, M> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction,
            @NotNull final Supplier<M> mapFactory); @NotNull static Collector<T, ?, Map<K, V>> toUnmodifiableMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction); @NotNull static Collector<CharSequence, ?, String> joining(); @NotNull static Collector<CharSequence, ?, String> joining(@NotNull CharSequence delimiter); @NotNull static Collector<CharSequence, ?, String> joining(
            @NotNull CharSequence delimiter,
            @NotNull CharSequence prefix,
            @NotNull CharSequence suffix); @NotNull static Collector<CharSequence, ?, String> joining(
            @NotNull final CharSequence delimiter,
            @NotNull final CharSequence prefix,
            @NotNull final CharSequence suffix,
            @NotNull final String emptyValue); @Deprecated @NotNull static Collector<T, ?, Double> averaging(@NotNull final Function<? super T, Double> mapper); @NotNull static Collector<T, ?, Double> averagingInt(@NotNull final ToIntFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> averagingLong(@NotNull final ToLongFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> averagingDouble(@NotNull final ToDoubleFunction<? super T> mapper); @NotNull static Collector<T, ?, Integer> summingInt(@NotNull final ToIntFunction<? super T> mapper); @NotNull static Collector<T, ?, Long> summingLong(@NotNull final ToLongFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> summingDouble(@NotNull final ToDoubleFunction<? super T> mapper); @NotNull static Collector<T, ?, Long> counting(); @NotNull static Collector<T, ?, T> reducing(@Nullable  final T identity,
                                                  @NotNull final BinaryOperator<T> op); @NotNull static Collector<T, ?, R> reducing(
            @Nullable  final R identity,
            @NotNull final Function<? super T, ? extends R> mapper,
            @NotNull final BinaryOperator<R> op); @NotNull static Collector<T, ?, R> filtering(
            @NotNull final Predicate<? super T> predicate,
            @NotNull final Collector<? super T, A, R> downstream); @NotNull static Collector<T, ?, R> mapping(
            @NotNull final Function<? super T, ? extends U> mapper,
            @NotNull final Collector<? super U, A, R> downstream); @NotNull static Collector<T, ?, R> flatMapping(
            @NotNull final Function<? super T, ? extends Stream<? extends U>> mapper,
            @NotNull final Collector<? super U, A, R> downstream); @NotNull static Collector<T, A, OR> collectingAndThen(
            @NotNull Collector<T, A, IR> c,
            @NotNull Function<IR, OR> finisher); @NotNull static Collector<T, ?, Map<K, List<T>>> groupingBy(
            @NotNull Function<? super T, ? extends K> classifier); @NotNull static Collector<T, ?, Map<K, D>> groupingBy(
            @NotNull Function<? super T, ? extends K> classifier,
            @NotNull Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, M> groupingBy(
            @NotNull final Function<? super T, ? extends K> classifier,
            @NotNull final Supplier<M> mapFactory,
            @NotNull final Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, Map<Boolean, List<T>>> partitioningBy(
            @NotNull Predicate<? super T> predicate); @NotNull static Collector<T, ?, Map<Boolean, D>> partitioningBy(
            @NotNull final Predicate<? super T> predicate,
            @NotNull final Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, R> teeing(
            @NotNull final Collector<? super T, ?, R1> downstream1,
            @NotNull final Collector<? super T, ?, R2> downstream2,
            @NotNull final BiFunction<? super R1, ? super R2, R> merger); }
Collectors { @NotNull public static <T> Collector<T, ?, List<T>> toList() { return new CollectorsImpl<T, List<T>, List<T>>( new Supplier<List<T>>() { @NotNull @Override public List<T> get() { return new ArrayList<T>(); } }, new BiConsumer<List<T>, T>() { @Override public void accept(@NotNull List<T> t, T u) { t.add(u); } } ); } private  Collectors(); @NotNull static Collector<T, ?, R> toCollection(
            @NotNull Supplier<R> collectionSupplier); @NotNull static Collector<T, ?, List<T>> toList(); @NotNull static Collector<T, ?, List<T>> toUnmodifiableList(); @NotNull static Collector<T, ?, Set<T>> toSet(); @NotNull static Collector<T, ?, Set<T>> toUnmodifiableSet(); @NotNull static Collector<T, ?, Map<K, T>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper); @NotNull static Collector<T, ?, Map<K, V>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper); @NotNull static Collector<T, ?, M> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final Supplier<M> mapFactory); @NotNull static Collector<T, ?, Map<K, V>> toUnmodifiableMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper); @NotNull static Collector<T, ?, Map<K, V>> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction); @NotNull static Collector<T, ?, M> toMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction,
            @NotNull final Supplier<M> mapFactory); @NotNull static Collector<T, ?, Map<K, V>> toUnmodifiableMap(
            @NotNull final Function<? super T, ? extends K> keyMapper,
            @NotNull final Function<? super T, ? extends V> valueMapper,
            @NotNull final BinaryOperator<V> mergeFunction); @NotNull static Collector<CharSequence, ?, String> joining(); @NotNull static Collector<CharSequence, ?, String> joining(@NotNull CharSequence delimiter); @NotNull static Collector<CharSequence, ?, String> joining(
            @NotNull CharSequence delimiter,
            @NotNull CharSequence prefix,
            @NotNull CharSequence suffix); @NotNull static Collector<CharSequence, ?, String> joining(
            @NotNull final CharSequence delimiter,
            @NotNull final CharSequence prefix,
            @NotNull final CharSequence suffix,
            @NotNull final String emptyValue); @Deprecated @NotNull static Collector<T, ?, Double> averaging(@NotNull final Function<? super T, Double> mapper); @NotNull static Collector<T, ?, Double> averagingInt(@NotNull final ToIntFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> averagingLong(@NotNull final ToLongFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> averagingDouble(@NotNull final ToDoubleFunction<? super T> mapper); @NotNull static Collector<T, ?, Integer> summingInt(@NotNull final ToIntFunction<? super T> mapper); @NotNull static Collector<T, ?, Long> summingLong(@NotNull final ToLongFunction<? super T> mapper); @NotNull static Collector<T, ?, Double> summingDouble(@NotNull final ToDoubleFunction<? super T> mapper); @NotNull static Collector<T, ?, Long> counting(); @NotNull static Collector<T, ?, T> reducing(@Nullable  final T identity,
                                                  @NotNull final BinaryOperator<T> op); @NotNull static Collector<T, ?, R> reducing(
            @Nullable  final R identity,
            @NotNull final Function<? super T, ? extends R> mapper,
            @NotNull final BinaryOperator<R> op); @NotNull static Collector<T, ?, R> filtering(
            @NotNull final Predicate<? super T> predicate,
            @NotNull final Collector<? super T, A, R> downstream); @NotNull static Collector<T, ?, R> mapping(
            @NotNull final Function<? super T, ? extends U> mapper,
            @NotNull final Collector<? super U, A, R> downstream); @NotNull static Collector<T, ?, R> flatMapping(
            @NotNull final Function<? super T, ? extends Stream<? extends U>> mapper,
            @NotNull final Collector<? super U, A, R> downstream); @NotNull static Collector<T, A, OR> collectingAndThen(
            @NotNull Collector<T, A, IR> c,
            @NotNull Function<IR, OR> finisher); @NotNull static Collector<T, ?, Map<K, List<T>>> groupingBy(
            @NotNull Function<? super T, ? extends K> classifier); @NotNull static Collector<T, ?, Map<K, D>> groupingBy(
            @NotNull Function<? super T, ? extends K> classifier,
            @NotNull Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, M> groupingBy(
            @NotNull final Function<? super T, ? extends K> classifier,
            @NotNull final Supplier<M> mapFactory,
            @NotNull final Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, Map<Boolean, List<T>>> partitioningBy(
            @NotNull Predicate<? super T> predicate); @NotNull static Collector<T, ?, Map<Boolean, D>> partitioningBy(
            @NotNull final Predicate<? super T> predicate,
            @NotNull final Collector<? super T, A, D> downstream); @NotNull static Collector<T, ?, R> teeing(
            @NotNull final Collector<? super T, ?, R1> downstream1,
            @NotNull final Collector<? super T, ?, R2> downstream2,
            @NotNull final BiFunction<? super R1, ? super R2, R> merger);  }