0

So my question is simple, I am getting a Slice<Object> from database using pageable.

Then I need to filter it based on some parameters(fe. status), so as usual I'm doing something like this:

slice.getContent().stream().filter(o -> o.getStatus().equals(status)).collect(Collectors.toList())

But I still need to return the Slice<Object>. How can I correctly convert the result of filtering into Slice<Object>?

I know about the SliceImpl<>, which requires 3 arguments List<T> content, Pageable pageable, boolean hasNext but how do I correctly determine the pageable and the hasNext of my filtered list? Is there a quick and easy way that I don't know of?

developer1
  • 73
  • 1
  • 6
  • You can use `Unpaged` instance for Pageable argument, and for `hasNext` you can use any of true/false if you don't need it in your next steps – Nikolai Shevchenko May 13 '21 at 13:12
  • Why do you need to filter the contents in memory? Of course there's no way to determine `hasNext`, the final page might contain all the wrong statuses, for example. – crizzis May 13 '21 at 21:06

0 Answers0