-
Notifications
You must be signed in to change notification settings - Fork 678
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
base: main
Are you sure you want to change the base?
Conversation
zorglube
commented
Oct 25, 2021
•
edited
Loading
edited
- You have read the Spring Data contribution guidelines.
- You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
- You submit test cases (unit or integration tests) that back your changes.
- You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
@zorglube Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
c65f5b1
to
8a74215
Compare
…ing-data-commons.git into add-page-collectors
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
@zorglube Thank you for signing the Contributor License Agreement! |
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
Signed-off-by: Zorglube <[email protected]>
Is there any existing ticket that describes, what issue this proposal is trying to solve? If not, would you mind to elaborate? |
As fa as I know their is no ticket related to this PR. The problem I tried to handle is just a small writing 'issue'. import static java.utils.Objects.toList;
class Something {
private final Predicate<T> filter;
private final Comparator<T> order;
public Page getProcessedPage(Pageable pageable){
List<T> items = repo.getPage(pageable).stream().map(process).filter(filter).sort(order).collect(toList());
Page<T> page = new PageImpl(items, pageable, items.size());
return page;
}
} My purpose is to make this possible with this writing : import static org.springframework.data.util.PageCollectors.toFilteredSortedPage;
class Something {
private final Predicate<T> filter;
private final Comparator<T> order;
public Page getProcessedPage(Pageable pageable){
return repo.getPage(pageable).stream().collect(toFilteredSortedPage(pageable, filter, order));
}
} |
You can apply processing to elements of a The code you show effective produces broken |
I forgotted another use cas I had : import static org.springframework.data.util.PageCollectors.toFilteredSortedPage;
class Something {
private final Predicate<T> filter;
private final Comparator<T> order;
public Page getProcessedPage(Pageable pageable) {
List<T> list_1 = repo.getSomeData();
List<T> list_2 = repo/service/watever.getSomeData();
return list_1.stream().map/filter/sort( ... `imply list_2` ... ).collect(toFilteredSortedPage(pageable, filter, order));
}
} |
Yes I'm aware of the
Can you wait a few, I'll dig to find my old use case, as you ca see it was four months ago. |
Sure thing. Be advised thought that we consider everything |
Yes I understand ;-) |
Hello @odrotbohm , You were right, the use case that made me write this code, was the result of a bad design choices. As I said it was something like : import static org.springframework.data.util.PageCollectors.toFilteredSortedPage;
class Something {
private final Predicate<T> filter;
private final Comparator<T> order;
public Page<T> getProcessedPage(Pageable pageable) {
List<T> list_1 = repo.getSomeData();
...
List<T> list_2 = repo/service/watever.getSomeData();
...
return list_1.stream().map/filter/sort( ... `imply list_2` ... ).collect(toFilteredSortedPage(pageable, filter, order));
}
} Thing that could have been written like : class Something {
private final Predicate<T> filter;
private final Comparator<T> order;
public Page<T> getProcessedPage(Pageable pageable) {
...
return repo.getSomeDataPage(pageable);
}
} However, I still think there's a use case for this kind of code. You tell me. BR, |
c08d207
to
2a1a8f3
Compare
fe5e80e
to
98f20a4
Compare
0122d1b
to
5070a0f
Compare