Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Delegate to run {@link ScrollPosition scroll queries} and create result {@link Window}.
*
* @author Mark Paluch
* @author Yanming Zhou
* @since 3.1
*/
public class ScrollDelegate<T> {
Expand Down Expand Up @@ -80,17 +81,17 @@ private static <T> Window<T> createWindow(Sort sort, int limit, Direction direct
JpaEntityInformation<T, ?> entity, List<T> result) {

KeysetScrollDelegate delegate = KeysetScrollDelegate.of(direction);
List<T> resultsToUse = delegate.postProcessResults(result);
List<T> resultsToUse = delegate.getResultWindow(delegate.postProcessResults(result), limit);

IntFunction<ScrollPosition> positionFunction = value -> {

T object = result.get(value);
T object = resultsToUse.get(value);
Map<String, Object> keys = entity.getKeyset(sort.stream().map(Order::getProperty).toList(), object);

return ScrollPosition.forward(keys);
return ScrollPosition.of(keys, direction);
};

return Window.from(delegate.getResultWindow(resultsToUse, limit), positionFunction, hasMoreElements(result, limit));
return Window.from(resultsToUse, positionFunction, hasMoreElements(result, limit));
}

private static <T> Window<T> createWindow(List<T> result, int limit,
Expand Down