Uses of Interface
java.util.stream.Collector

Packages that use Collector
Package
Description
Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.
  • Uses of Collector in java.util.stream

    Methods in java.util.stream that return Collector
    Modifier and Type
    Method
    Description
    static <T> Collector<T,?,Double>
    Collectors.averagingDouble(ToDoubleFunction<? super T> mapper)
    Returns a Collector that produces the arithmetic mean of a double-valued function applied to the input elements.
    static <T> Collector<T,?,Double>
    Collectors.averagingInt(ToIntFunction<? super T> mapper)
    Returns a Collector that produces the arithmetic mean of an integer-valued function applied to the input elements.
    static <T> Collector<T,?,Double>
    Collectors.averagingLong(ToLongFunction<? super T> mapper)
    Returns a Collector that produces the arithmetic mean of a long-valued function applied to the input elements.
    static <T, A, R, RR> Collector<T,A,RR>
    Collectors.collectingAndThen(Collector<T,A,R> downstream, Function<R,RR> finisher)
    Adapts a Collector to perform an additional finishing transformation.
    static <T> Collector<T,?,Long>
    Collectors.counting()
    Returns a Collector accepting elements of type T that counts the number of input elements.
    static <T, A, R> Collector<T,?,R>
    Collectors.filtering(Predicate<? super T> predicate, Collector<? super T,A,R> downstream)
    Adapts a Collector to one accepting elements of the same type T by applying the predicate to each input element and only accumulating if the predicate returns true.
    static <T, U, A, R> Collector<T,?,R>
    Collectors.flatMapping(Function<? super T,? extends Stream<? extends U>> mapper, Collector<? super U,A,R> downstream)
    Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a flat mapping function to each input element before accumulation.
    static <T, K> Collector<T,?,Map<K,List<T>>>
    Collectors.groupingBy(Function<? super T,? extends K> classifier)
    Returns a Collector implementing a "group by" operation on input elements of type T, grouping elements according to a classification function, and returning the results in a Map.
    static <T, K, D, A, M extends Map<K, D>>
    Collector<T,?,M>
    Collectors.groupingBy(Function<? super T,? extends K> classifier, Supplier<M> mapFactory, Collector<? super T,A,D> downstream)
    Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K, A, D> Collector<T,?,Map<K,D>>
    Collectors.groupingBy(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream)
    Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K> Collector<T,?,ConcurrentMap<K,List<T>>>
    Collectors.groupingByConcurrent(Function<? super T,? extends K> classifier)
    Returns a concurrent Collector implementing a "group by" operation on input elements of type T, grouping elements according to a classification function.
    static <T, K, A, D, M extends ConcurrentMap<K, D>>
    Collector<T,?,M>
    Collectors.groupingByConcurrent(Function<? super T,? extends K> classifier, Supplier<M> mapFactory, Collector<? super T,A,D> downstream)
    Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K, A, D> Collector<T,?,ConcurrentMap<K,D>>
    Collectors.groupingByConcurrent(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream)
    Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    Collectors.joining()
    Returns a Collector that concatenates the input elements into a String, in encounter order.
    Collectors.joining(CharSequence delimiter)
    Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.
    Collectors.joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
    Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.
    static <T, U, A, R> Collector<T,?,R>
    Collectors.mapping(Function<? super T,? extends U> mapper, Collector<? super U,A,R> downstream)
    Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a mapping function to each input element before accumulation.
    static <T> Collector<T,?,Optional<T>>
    Collectors.maxBy(Comparator<? super T> comparator)
    Returns a Collector that produces the maximal element according to a given Comparator, described as an Optional<T>.
    static <T> Collector<T,?,Optional<T>>
    Collectors.minBy(Comparator<? super T> comparator)
    Returns a Collector that produces the minimal element according to a given Comparator, described as an Optional<T>.
    static <T, A, R> Collector<T,A,R>
    Collector.of(Supplier<A> supplier, BiConsumer<A,T> accumulator, BinaryOperator<A> combiner, Function<A,R> finisher, Collector.Characteristics... characteristics)
    Returns a new Collector described by the given supplier, accumulator, combiner, and finisher functions.
    static <T, R> Collector<T,R,R>
    Collector.of(Supplier<R> supplier, BiConsumer<R,T> accumulator, BinaryOperator<R> combiner, Collector.Characteristics... characteristics)
    Returns a new Collector described by the given supplier, accumulator, and combiner functions.
    static <T> Collector<T,?,Map<Boolean,List<T>>>
    Collectors.partitioningBy(Predicate<? super T> predicate)
    Returns a Collector which partitions the input elements according to a Predicate, and organizes them into a Map<Boolean, List<T>>.
    static <T, D, A> Collector<T,?,Map<Boolean,D>>
    Collectors.partitioningBy(Predicate<? super T> predicate, Collector<? super T,A,D> downstream)
    Returns a Collector which partitions the input elements according to a Predicate, reduces the values in each partition according to another Collector, and organizes them into a Map<Boolean, D> whose values are the result of the downstream reduction.
    static <T> Collector<T,?,Optional<T>>
    Collectors.reducing(BinaryOperator<T> op)
    Returns a Collector which performs a reduction of its input elements under a specified BinaryOperator.
    static <T> Collector<T,?,T>
    Collectors.reducing(T identity, BinaryOperator<T> op)
    Returns a Collector which performs a reduction of its input elements under a specified BinaryOperator using the provided identity.
    static <T, U> Collector<T,?,U>
    Collectors.reducing(U identity, Function<? super T,? extends U> mapper, BinaryOperator<U> op)
    Returns a Collector which performs a reduction of its input elements under a specified mapping function and BinaryOperator.
    Collectors.summarizingDouble(ToDoubleFunction<? super T> mapper)
    Returns a Collector which applies an double-producing mapping function to each input element, and returns summary statistics for the resulting values.
    Collectors.summarizingInt(ToIntFunction<? super T> mapper)
    Returns a Collector which applies an int-producing mapping function to each input element, and returns summary statistics for the resulting values.
    Collectors.summarizingLong(ToLongFunction<? super T> mapper)
    Returns a Collector which applies an long-producing mapping function to each input element, and returns summary statistics for the resulting values.
    static <T> Collector<T,?,Double>
    Collectors.summingDouble(ToDoubleFunction<? super T> mapper)
    Returns a Collector that produces the sum of a double-valued function applied to the input elements.
    static <T> Collector<T,?,Integer>
    Collectors.summingInt(ToIntFunction<? super T> mapper)
    Returns a Collector that produces the sum of a integer-valued function applied to the input elements.
    static <T> Collector<T,?,Long>
    Collectors.summingLong(ToLongFunction<? super T> mapper)
    Returns a Collector that produces the sum of a long-valued function applied to the input elements.
    static <T, R1, R2, R>
    Collector<T,?,R>
    Collectors.teeing(Collector<? super T,?,R1> downstream1, Collector<? super T,?,R2> downstream2, BiFunction<? super R1,? super R2,R> merger)
    Returns a Collector that is a composite of two downstream collectors.
    static <T, C extends Collection<T>>
    Collector<T,?,C>
    Collectors.toCollection(Supplier<C> collectionFactory)
    Returns a Collector that accumulates the input elements into a new Collection, in encounter order.
    static <T, K, U> Collector<T,?,ConcurrentMap<K,U>>
    Collectors.toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
    Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T, K, U> Collector<T,?,ConcurrentMap<K,U>>
    Collectors.toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction)
    Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T, K, U, M extends ConcurrentMap<K, U>>
    Collector<T,?,M>
    Collectors.toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory)
    Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T> Collector<T,?,List<T>>
    Collectors.toList()
    Returns a Collector that accumulates the input elements into a new List.
    static <T, K, U> Collector<T,?,Map<K,U>>
    Collectors.toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
    Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T, K, U> Collector<T,?,Map<K,U>>
    Collectors.toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction)
    Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T, K, U, M extends Map<K, U>>
    Collector<T,?,M>
    Collectors.toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory)
    Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T> Collector<T,?,Set<T>>
    Collectors.toSet()
    Returns a Collector that accumulates the input elements into a new Set.
    static <T> Collector<T,?,List<T>>
    Collectors.toUnmodifiableList()
    Returns a Collector that accumulates the input elements into an unmodifiable List in encounter order.
    static <T, K, U> Collector<T,?,Map<K,U>>
    Collectors.toUnmodifiableMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
    Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T, K, U> Collector<T,?,Map<K,U>>
    Collectors.toUnmodifiableMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction)
    Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.
    static <T> Collector<T,?,Set<T>>
    Collectors.toUnmodifiableSet()
    Returns a Collector that accumulates the input elements into an unmodifiable Set.
    Methods in java.util.stream with parameters of type Collector
    Modifier and Type
    Method
    Description
    <R, A> R
    Stream.collect(Collector<? super T,A,R> collector)
    Performs a mutable reduction operation on the elements of this stream using a Collector.
    static <T, A, R, RR> Collector<T,A,RR>
    Collectors.collectingAndThen(Collector<T,A,R> downstream, Function<R,RR> finisher)
    Adapts a Collector to perform an additional finishing transformation.
    static <T, A, R> Collector<T,?,R>
    Collectors.filtering(Predicate<? super T> predicate, Collector<? super T,A,R> downstream)
    Adapts a Collector to one accepting elements of the same type T by applying the predicate to each input element and only accumulating if the predicate returns true.
    static <T, U, A, R> Collector<T,?,R>
    Collectors.flatMapping(Function<? super T,? extends Stream<? extends U>> mapper, Collector<? super U,A,R> downstream)
    Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a flat mapping function to each input element before accumulation.
    static <T, K, D, A, M extends Map<K, D>>
    Collector<T,?,M>
    Collectors.groupingBy(Function<? super T,? extends K> classifier, Supplier<M> mapFactory, Collector<? super T,A,D> downstream)
    Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K, A, D> Collector<T,?,Map<K,D>>
    Collectors.groupingBy(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream)
    Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K, A, D, M extends ConcurrentMap<K, D>>
    Collector<T,?,M>
    Collectors.groupingByConcurrent(Function<? super T,? extends K> classifier, Supplier<M> mapFactory, Collector<? super T,A,D> downstream)
    Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, K, A, D> Collector<T,?,ConcurrentMap<K,D>>
    Collectors.groupingByConcurrent(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream)
    Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.
    static <T, U, A, R> Collector<T,?,R>
    Collectors.mapping(Function<? super T,? extends U> mapper, Collector<? super U,A,R> downstream)
    Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a mapping function to each input element before accumulation.
    static <T, D, A> Collector<T,?,Map<Boolean,D>>
    Collectors.partitioningBy(Predicate<? super T> predicate, Collector<? super T,A,D> downstream)
    Returns a Collector which partitions the input elements according to a Predicate, reduces the values in each partition according to another Collector, and organizes them into a Map<Boolean, D> whose values are the result of the downstream reduction.
    static <T, R1, R2, R>
    Collector<T,?,R>
    Collectors.teeing(Collector<? super T,?,R1> downstream1, Collector<? super T,?,R2> downstream2, BiFunction<? super R1,? super R2,R> merger)
    Returns a Collector that is a composite of two downstream collectors.