Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PageCollectors into Util #2490

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Factorized, use Stream.
Signed-off-by: Zorglube <[email protected]>
  • Loading branch information
zorglube committed Oct 26, 2021
commit 89f53fcf63a2f34a5f2dfbfa7e0c5498c3e6b8bb
26 changes: 6 additions & 20 deletions src/main/java/org/springframework/data/util/PageCollectors.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.springframework.data.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -86,10 +87,7 @@ public BiConsumer<List<T>, T> accumulator() {

@Override
public BinaryOperator<List<T>> combiner() {
return (left, right) -> {
left.addAll(right);
return left;
};
return (left, right) -> Stream.of(left, right).flatMap(Collection::stream).collect(Collectors.toList());
}

@Override
Expand Down Expand Up @@ -135,10 +133,7 @@ public BiConsumer<List<T>, T> accumulator() {

@Override
public BinaryOperator<List<T>> combiner() {
return (left, right) -> {
left.addAll(right);
return left;
};
return (left, right) -> Stream.of(left, right).flatMap(Collection::stream).collect(Collectors.toList());
}

@Override
Expand Down Expand Up @@ -193,10 +188,7 @@ public BiConsumer<List<T>, T> accumulator() {

@Override
public BinaryOperator<List<T>> combiner() {
return (left, right) -> {
left.addAll(right);
return left;
};
return (left, right) -> Stream.of(left, right).flatMap(Collection::stream).collect(Collectors.toList());
}

@Override
Expand Down Expand Up @@ -255,10 +247,7 @@ public BiConsumer<List<T>, T> accumulator() {

@Override
public BinaryOperator<List<T>> combiner() {
return (left, right) -> {
left.addAll(right);
return left;
};
return (left, right) -> Stream.of(left, right).flatMap(Collection::stream).collect(Collectors.toList());
}

@Override
Expand Down Expand Up @@ -319,10 +308,7 @@ public BiConsumer<List<T>, T> accumulator() {

@Override
public BinaryOperator<List<T>> combiner() {
return (left, right) -> {
left.addAll(right);
return left;
};
return (left, right) -> Stream.of(left, right).flatMap(Collection::stream).collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.springframework.data.domain.Page;

/**
* Test methods for {@link PageCollectors}s.
* Test methods for {@link PageCollectors}.
*
* @author Bertrand Moreau
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.springframework.data.domain.Pageable;

/**
* Test methods for {@link PageCollectors}s.
* Test methods for {@link PageCollectors}.
*
* @author Bertrand Moreau
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.springframework.data.domain.Pageable;

/**
* Test methods for {@link PageCollectors}s.
* Test methods for {@link PageCollectors}.
*
* @author Bertrand Moreau
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.springframework.data.domain.Pageable;

/**
* Test methods for {@link PageCollectors}s.
* Test methods for {@link PageCollectors}.
*
* @author Bertrand Moreau
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.data.domain.Pageable;

/**
* Test methods for {@link PageCollectors}s.
* Test methods for {@link PageCollectors}.
*
* @author Bertrand Moreau
*/
Expand Down