Skip to content

Commit

Permalink
Add example to collectingAndThen() with partitioningBy()
Browse files Browse the repository at this point in the history
  • Loading branch information
fluentfuture committed Sep 28, 2024
1 parent 18dc6e6 commit 2457130
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mug/src/main/java/com/google/mu/util/stream/BiCollectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ public static <K, V, T, R> BiCollector<K, V, R> collectingAndThen(
* Returns a {@link BiCollector} that maps the result of {@code collector} using the {@code
* finisher} BiFunction. Useful when combined with BiCollectors like {@link #partitioningBy}.
*
* <p>For example: <pre>{@code
* collectingAndThen(
* partitioningBy((time, request) -> isAllowed(time, request), toMap(), counting()),
* (allowedRequests, disallowed) -> ...)
* }</pre>
*
* @since 8.1
*/
public static <K, V, A, B, R> BiCollector<K, V, R> collectingAndThen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ M build() {
* Returns a {@link Collector} that maps the result of {@code upstream} collector using the {@code
* finisher} BiFunction. Useful when combined with collectors like {@link #partitioningBy}.
*
* <p>For example: <pre>{@code
* collectingAndThen(partitioningBy(Person::isGood), (good, evil) -> ...)
* }</pre>
*
* @since 8.1
*/
public static <T, A, B, R> Collector<T, ?, R> collectingAndThen(
Expand Down

0 comments on commit 2457130

Please sign in to comment.