|
|
@ -222,7 +222,7 @@ public final class Collectors {
|
|
|
|
* {@code Collection}, in encounter order
|
|
|
|
* {@code Collection}, in encounter order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, C extends Collection<T>>
|
|
|
|
public static <T, C extends Collection<T>>
|
|
|
|
Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) {
|
|
|
|
Collector<T, C, C> toCollection(Supplier<C> collectionFactory) {
|
|
|
|
return new CollectorImpl<>(collectionFactory, Collection::add,
|
|
|
|
return new CollectorImpl<>(collectionFactory, Collection::add,
|
|
|
|
(r1, r2) -> { r1.addAll(r2); return r1; },
|
|
|
|
(r1, r2) -> { r1.addAll(r2); return r1; },
|
|
|
|
CH_ID);
|
|
|
|
CH_ID);
|
|
|
@ -239,7 +239,7 @@ public final class Collectors {
|
|
|
|
* {@code List}, in encounter order
|
|
|
|
* {@code List}, in encounter order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, List<T>> toList() {
|
|
|
|
Collector<T, ArrayList<Object>, List<T>> toList() {
|
|
|
|
return new CollectorImpl<>(ArrayList::new, List::add,
|
|
|
|
return new CollectorImpl<>(ArrayList::new, List::add,
|
|
|
|
(left, right) -> { left.addAll(right); return left; },
|
|
|
|
(left, right) -> { left.addAll(right); return left; },
|
|
|
|
CH_ID);
|
|
|
|
CH_ID);
|
|
|
@ -257,7 +257,7 @@ public final class Collectors {
|
|
|
|
* @since 10
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, List<T>> toUnmodifiableList() {
|
|
|
|
Collector<T, ArrayList<Object>, List<T>> toUnmodifiableList() {
|
|
|
|
return new CollectorImpl<>(ArrayList::new, List::add,
|
|
|
|
return new CollectorImpl<>(ArrayList::new, List::add,
|
|
|
|
(left, right) -> { left.addAll(right); return left; },
|
|
|
|
(left, right) -> { left.addAll(right); return left; },
|
|
|
|
list -> {
|
|
|
|
list -> {
|
|
|
@ -286,7 +286,7 @@ public final class Collectors {
|
|
|
|
* {@code Set}
|
|
|
|
* {@code Set}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, Set<T>> toSet() {
|
|
|
|
Collector<T, HashSet<Object>, Set<T>> toSet() {
|
|
|
|
return new CollectorImpl<>(HashSet::new, Set::add,
|
|
|
|
return new CollectorImpl<>(HashSet::new, Set::add,
|
|
|
|
(left, right) -> {
|
|
|
|
(left, right) -> {
|
|
|
|
if (left.size() < right.size()) {
|
|
|
|
if (left.size() < right.size()) {
|
|
|
@ -315,7 +315,7 @@ public final class Collectors {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, Set<T>> toUnmodifiableSet() {
|
|
|
|
Collector<T, HashSet<Object>, Set<T>> toUnmodifiableSet() {
|
|
|
|
return new CollectorImpl<>(HashSet::new, Set::add,
|
|
|
|
return new CollectorImpl<>(HashSet::new, Set::add,
|
|
|
|
(left, right) -> {
|
|
|
|
(left, right) -> {
|
|
|
|
if (left.size() < right.size()) {
|
|
|
|
if (left.size() < right.size()) {
|
|
|
@ -335,7 +335,7 @@ public final class Collectors {
|
|
|
|
* @return a {@code Collector} that concatenates the input elements into a
|
|
|
|
* @return a {@code Collector} that concatenates the input elements into a
|
|
|
|
* {@code String}, in encounter order
|
|
|
|
* {@code String}, in encounter order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static Collector<CharSequence, ?, String> joining() {
|
|
|
|
public static Collector<CharSequence, StringBuilder, String> joining() {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
StringBuilder::new, StringBuilder::append,
|
|
|
|
StringBuilder::new, StringBuilder::append,
|
|
|
|
(r1, r2) -> {
|
|
|
|
(r1, r2) -> {
|
|
|
@ -353,7 +353,7 @@ public final class Collectors {
|
|
|
|
* @return A {@code Collector} which concatenates CharSequence elements,
|
|
|
|
* @return A {@code Collector} which concatenates CharSequence elements,
|
|
|
|
* separated by the specified delimiter, in encounter order
|
|
|
|
* separated by the specified delimiter, in encounter order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static Collector<CharSequence, ?, String> joining(CharSequence delimiter) {
|
|
|
|
public static Collector<CharSequence, StringJoiner, String> joining(CharSequence delimiter) {
|
|
|
|
return joining(delimiter, "", "");
|
|
|
|
return joining(delimiter, "", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -370,7 +370,7 @@ public final class Collectors {
|
|
|
|
* @return A {@code Collector} which concatenates CharSequence elements,
|
|
|
|
* @return A {@code Collector} which concatenates CharSequence elements,
|
|
|
|
* separated by the specified delimiter, in encounter order
|
|
|
|
* separated by the specified delimiter, in encounter order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static Collector<CharSequence, ?, String> joining(CharSequence delimiter,
|
|
|
|
public static Collector<CharSequence, StringJoiner, String> joining(CharSequence delimiter,
|
|
|
|
CharSequence prefix,
|
|
|
|
CharSequence prefix,
|
|
|
|
CharSequence suffix) {
|
|
|
|
CharSequence suffix) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
@ -428,7 +428,7 @@ public final class Collectors {
|
|
|
|
* elements and provides the mapped results to the downstream collector
|
|
|
|
* elements and provides the mapped results to the downstream collector
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, U, A, R>
|
|
|
|
public static <T, U, A, R>
|
|
|
|
Collector<T, ?, R> mapping(Function<? super T, ? extends U> mapper,
|
|
|
|
Collector<T, A, R> mapping(Function<? super T, ? extends U> mapper,
|
|
|
|
Collector<? super U, A, R> downstream) {
|
|
|
|
Collector<? super U, A, R> downstream) {
|
|
|
|
BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
|
|
|
|
BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
@ -473,7 +473,7 @@ public final class Collectors {
|
|
|
|
* @since 9
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, U, A, R>
|
|
|
|
public static <T, U, A, R>
|
|
|
|
Collector<T, ?, R> flatMapping(Function<? super T, ? extends Stream<? extends U>> mapper,
|
|
|
|
Collector<T, A, R> flatMapping(Function<? super T, ? extends Stream<? extends U>> mapper,
|
|
|
|
Collector<? super U, A, R> downstream) {
|
|
|
|
Collector<? super U, A, R> downstream) {
|
|
|
|
BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
|
|
|
|
BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
@ -523,7 +523,7 @@ public final class Collectors {
|
|
|
|
* @since 9
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, A, R>
|
|
|
|
public static <T, A, R>
|
|
|
|
Collector<T, ?, R> filtering(Predicate<? super T> predicate,
|
|
|
|
Collector<T, A, R> filtering(Predicate<? super T> predicate,
|
|
|
|
Collector<? super T, A, R> downstream) {
|
|
|
|
Collector<? super T, A, R> downstream) {
|
|
|
|
BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
|
|
|
|
BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
|
return new CollectorImpl<>(downstream.supplier(),
|
|
|
@ -588,7 +588,7 @@ public final class Collectors {
|
|
|
|
* @param <T> the type of the input elements
|
|
|
|
* @param <T> the type of the input elements
|
|
|
|
* @return a {@code Collector} that counts the input elements
|
|
|
|
* @return a {@code Collector} that counts the input elements
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Long>
|
|
|
|
public static <T> Collector<T, long[], Long>
|
|
|
|
counting() {
|
|
|
|
counting() {
|
|
|
|
return summingLong(e -> 1L);
|
|
|
|
return summingLong(e -> 1L);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -640,7 +640,7 @@ public final class Collectors {
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Integer>
|
|
|
|
public static <T> Collector<T, int[], Integer>
|
|
|
|
summingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
summingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
() -> new int[1],
|
|
|
|
() -> new int[1],
|
|
|
@ -658,7 +658,7 @@ public final class Collectors {
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Long>
|
|
|
|
public static <T> Collector<T, long[], Long>
|
|
|
|
summingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
summingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
() -> new long[1],
|
|
|
|
() -> new long[1],
|
|
|
@ -683,7 +683,7 @@ public final class Collectors {
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @param mapper a function extracting the property to be summed
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
* @return a {@code Collector} that produces the sum of a derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Double>
|
|
|
|
public static <T> Collector<T, double[], Double>
|
|
|
|
summingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
summingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* In the arrays allocated for the collect operation, index 0
|
|
|
|
* In the arrays allocated for the collect operation, index 0
|
|
|
@ -751,7 +751,7 @@ public final class Collectors {
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* derived property
|
|
|
|
* derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Double>
|
|
|
|
public static <T> Collector<T, long[], Double>
|
|
|
|
averagingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
averagingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
() -> new long[2],
|
|
|
|
() -> new long[2],
|
|
|
@ -770,7 +770,7 @@ public final class Collectors {
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* derived property
|
|
|
|
* derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Double>
|
|
|
|
public static <T> Collector<T, long[], Double>
|
|
|
|
averagingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
averagingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
() -> new long[2],
|
|
|
|
() -> new long[2],
|
|
|
@ -802,7 +802,7 @@ public final class Collectors {
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* @return a {@code Collector} that produces the arithmetic mean of a
|
|
|
|
* derived property
|
|
|
|
* derived property
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, Double>
|
|
|
|
public static <T> Collector<T, double[], Double>
|
|
|
|
averagingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
averagingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* In the arrays allocated for the collect operation, index 0
|
|
|
|
* In the arrays allocated for the collect operation, index 0
|
|
|
@ -844,7 +844,7 @@ public final class Collectors {
|
|
|
|
* @see #reducing(BinaryOperator)
|
|
|
|
* @see #reducing(BinaryOperator)
|
|
|
|
* @see #reducing(Object, Function, BinaryOperator)
|
|
|
|
* @see #reducing(Object, Function, BinaryOperator)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T> Collector<T, ?, T>
|
|
|
|
public static <T> Collector<T, T[], T>
|
|
|
|
reducing(T identity, BinaryOperator<T> op) {
|
|
|
|
reducing(T identity, BinaryOperator<T> op) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
boxSupplier(identity),
|
|
|
|
boxSupplier(identity),
|
|
|
@ -904,9 +904,8 @@ public final class Collectors {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
OptionalBox::new, OptionalBox::accept,
|
|
|
|
OptionalBox::new, Consumer<T>::accept,
|
|
|
|
(a, b) -> {
|
|
|
|
(a, b) -> {
|
|
|
|
if (b.present) a.accept(b.value);
|
|
|
|
if (b.present) a.accept(b.value);
|
|
|
|
return a;
|
|
|
|
return a;
|
|
|
@ -952,7 +951,7 @@ public final class Collectors {
|
|
|
|
* @see #reducing(BinaryOperator)
|
|
|
|
* @see #reducing(BinaryOperator)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, U>
|
|
|
|
public static <T, U>
|
|
|
|
Collector<T, ?, U> reducing(U identity,
|
|
|
|
Collector<T, U[], U> reducing(U identity,
|
|
|
|
Function<? super T, ? extends U> mapper,
|
|
|
|
Function<? super T, ? extends U> mapper,
|
|
|
|
BinaryOperator<U> op) {
|
|
|
|
BinaryOperator<U> op) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
@ -999,7 +998,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingBy(Function, Supplier, Collector)
|
|
|
|
* @see #groupingBy(Function, Supplier, Collector)
|
|
|
|
* @see #groupingByConcurrent(Function)
|
|
|
|
* @see #groupingByConcurrent(Function)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K> Collector<T, ?, Map<K, List<T>>>
|
|
|
|
public static <T, K> Collector<T, Map<K,ArrayList<Object>>, Map<K, List<T>>>
|
|
|
|
groupingBy(Function<? super T, ? extends K> classifier) {
|
|
|
|
groupingBy(Function<? super T, ? extends K> classifier) {
|
|
|
|
return groupingBy(classifier, toList());
|
|
|
|
return groupingBy(classifier, toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1049,7 +1048,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingByConcurrent(Function, Collector)
|
|
|
|
* @see #groupingByConcurrent(Function, Collector)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, A, D>
|
|
|
|
public static <T, K, A, D>
|
|
|
|
Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<T, Map<K,A>, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
return groupingBy(classifier, HashMap::new, downstream);
|
|
|
|
return groupingBy(classifier, HashMap::new, downstream);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1102,7 +1101,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, D, A, M extends Map<K, D>>
|
|
|
|
public static <T, K, D, A, M extends Map<K, D>>
|
|
|
|
Collector<T, ?, M> groupingBy(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<T, Map<K,A>, M> groupingBy(Function<? super T, ? extends K> classifier,
|
|
|
|
Supplier<M> mapFactory,
|
|
|
|
Supplier<M> mapFactory,
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Supplier<A> downstreamSupplier = downstream.supplier();
|
|
|
|
Supplier<A> downstreamSupplier = downstream.supplier();
|
|
|
@ -1166,7 +1165,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K>
|
|
|
|
public static <T, K>
|
|
|
|
Collector<T, ?, ConcurrentMap<K, List<T>>>
|
|
|
|
Collector<T, ConcurrentMap<K,ArrayList<Object>>, ConcurrentMap<K, List<T>>>
|
|
|
|
groupingByConcurrent(Function<? super T, ? extends K> classifier) {
|
|
|
|
groupingByConcurrent(Function<? super T, ? extends K> classifier) {
|
|
|
|
return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList());
|
|
|
|
return groupingByConcurrent(classifier, ConcurrentHashMap::new, toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1212,7 +1211,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
* @see #groupingByConcurrent(Function, Supplier, Collector)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, A, D>
|
|
|
|
public static <T, K, A, D>
|
|
|
|
Collector<T, ?, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<T, ConcurrentMap<K,A>, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream);
|
|
|
|
return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1260,7 +1259,7 @@ public final class Collectors {
|
|
|
|
* @see #groupingBy(Function, Supplier, Collector)
|
|
|
|
* @see #groupingBy(Function, Supplier, Collector)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, A, D, M extends ConcurrentMap<K, D>>
|
|
|
|
public static <T, K, A, D, M extends ConcurrentMap<K, D>>
|
|
|
|
Collector<T, ?, M> groupingByConcurrent(Function<? super T, ? extends K> classifier,
|
|
|
|
Collector<T, ConcurrentMap<K,A>, M> groupingByConcurrent(Function<? super T, ? extends K> classifier,
|
|
|
|
Supplier<M> mapFactory,
|
|
|
|
Supplier<M> mapFactory,
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Collector<? super T, A, D> downstream) {
|
|
|
|
Supplier<A> downstreamSupplier = downstream.supplier();
|
|
|
|
Supplier<A> downstreamSupplier = downstream.supplier();
|
|
|
@ -1438,7 +1437,7 @@ public final class Collectors {
|
|
|
|
* @see #toConcurrentMap(Function, Function)
|
|
|
|
* @see #toConcurrentMap(Function, Function)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, U>
|
|
|
|
public static <T, K, U>
|
|
|
|
Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, Map<K,U>, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
return new CollectorImpl<>(HashMap::new,
|
|
|
|
return new CollectorImpl<>(HashMap::new,
|
|
|
|
uniqKeysMapAccumulator(keyMapper, valueMapper),
|
|
|
|
uniqKeysMapAccumulator(keyMapper, valueMapper),
|
|
|
@ -1476,7 +1475,7 @@ public final class Collectors {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
public static <T, K, U>
|
|
|
|
public static <T, K, U>
|
|
|
|
Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, Map<K,U>, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
Objects.requireNonNull(keyMapper, "keyMapper");
|
|
|
|
Objects.requireNonNull(keyMapper, "keyMapper");
|
|
|
|
Objects.requireNonNull(valueMapper, "valueMapper");
|
|
|
|
Objects.requireNonNull(valueMapper, "valueMapper");
|
|
|
@ -1542,7 +1541,7 @@ public final class Collectors {
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator)
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, U>
|
|
|
|
public static <T, K, U>
|
|
|
|
Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, Map<K,U>, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
BinaryOperator<U> mergeFunction) {
|
|
|
|
BinaryOperator<U> mergeFunction) {
|
|
|
|
return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new);
|
|
|
|
return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new);
|
|
|
@ -1582,7 +1581,7 @@ public final class Collectors {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
public static <T, K, U>
|
|
|
|
public static <T, K, U>
|
|
|
|
Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, Map<K,U>, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
BinaryOperator<U> mergeFunction) {
|
|
|
|
BinaryOperator<U> mergeFunction) {
|
|
|
|
Objects.requireNonNull(keyMapper, "keyMapper");
|
|
|
|
Objects.requireNonNull(keyMapper, "keyMapper");
|
|
|
@ -1634,7 +1633,7 @@ public final class Collectors {
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, U, M extends Map<K, U>>
|
|
|
|
public static <T, K, U, M extends Map<K, U>>
|
|
|
|
Collector<T, ?, M> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, M, M> toMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
BinaryOperator<U> mergeFunction,
|
|
|
|
BinaryOperator<U> mergeFunction,
|
|
|
|
Supplier<M> mapFactory) {
|
|
|
|
Supplier<M> mapFactory) {
|
|
|
@ -1697,7 +1696,7 @@ public final class Collectors {
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
* @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, U>
|
|
|
|
public static <T, K, U>
|
|
|
|
Collector<T, ?, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, Map<K,U>, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
Function<? super T, ? extends U> valueMapper) {
|
|
|
|
return new CollectorImpl<>(ConcurrentHashMap::new,
|
|
|
|
return new CollectorImpl<>(ConcurrentHashMap::new,
|
|
|
|
uniqKeysMapAccumulator(keyMapper, valueMapper),
|
|
|
|
uniqKeysMapAccumulator(keyMapper, valueMapper),
|
|
|
@ -1798,7 +1797,7 @@ public final class Collectors {
|
|
|
|
* @see #toMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
* @see #toMap(Function, Function, BinaryOperator, Supplier)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T, K, U, M extends ConcurrentMap<K, U>>
|
|
|
|
public static <T, K, U, M extends ConcurrentMap<K, U>>
|
|
|
|
Collector<T, ?, M> toConcurrentMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Collector<T, M, M> toConcurrentMap(Function<? super T, ? extends K> keyMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
Function<? super T, ? extends U> valueMapper,
|
|
|
|
BinaryOperator<U> mergeFunction,
|
|
|
|
BinaryOperator<U> mergeFunction,
|
|
|
|
Supplier<M> mapFactory) {
|
|
|
|
Supplier<M> mapFactory) {
|
|
|
@ -1821,7 +1820,7 @@ public final class Collectors {
|
|
|
|
* @see #summarizingLong(ToLongFunction)
|
|
|
|
* @see #summarizingLong(ToLongFunction)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, IntSummaryStatistics> summarizingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
Collector<T, IntSummaryStatistics, IntSummaryStatistics> summarizingInt(ToIntFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
IntSummaryStatistics::new,
|
|
|
|
IntSummaryStatistics::new,
|
|
|
|
(r, t) -> r.accept(mapper.applyAsInt(t)),
|
|
|
|
(r, t) -> r.accept(mapper.applyAsInt(t)),
|
|
|
@ -1844,7 +1843,7 @@ public final class Collectors {
|
|
|
|
* @see #summarizingInt(ToIntFunction)
|
|
|
|
* @see #summarizingInt(ToIntFunction)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, LongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
Collector<T, LongSummaryStatistics, LongSummaryStatistics> summarizingLong(ToLongFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
LongSummaryStatistics::new,
|
|
|
|
LongSummaryStatistics::new,
|
|
|
|
(r, t) -> r.accept(mapper.applyAsLong(t)),
|
|
|
|
(r, t) -> r.accept(mapper.applyAsLong(t)),
|
|
|
@ -1867,7 +1866,7 @@ public final class Collectors {
|
|
|
|
* @see #summarizingInt(ToIntFunction)
|
|
|
|
* @see #summarizingInt(ToIntFunction)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static <T>
|
|
|
|
public static <T>
|
|
|
|
Collector<T, ?, DoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
Collector<T, DoubleSummaryStatistics, DoubleSummaryStatistics> summarizingDouble(ToDoubleFunction<? super T> mapper) {
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
return new CollectorImpl<>(
|
|
|
|
DoubleSummaryStatistics::new,
|
|
|
|
DoubleSummaryStatistics::new,
|
|
|
|
(r, t) -> r.accept(mapper.applyAsDouble(t)),
|
|
|
|
(r, t) -> r.accept(mapper.applyAsDouble(t)),
|
|
|
|