Skip to content

Commit 9ab34d8

Browse files
committed
Further refactoring of PageableExecutionUtils.
Removing `isSubsequentPage`. It is another name for !isFirstPage suggesting a different meaning which isn't there. Extracting `if (isFirstPage(pageable)) {`, further structuring the decision tree. See #3103 Original pull request #3113
1 parent 47109d4 commit 9ab34d8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/main/java/org/springframework/data/support/PageableExecutionUtils.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ public static <T> Page<T> getPage(List<T> content, Pageable pageable, LongSuppli
5959
return new PageImpl<>(content, pageable, content.size());
6060
}
6161

62-
if (isFirstPage(pageable) && isPartialPage(content, pageable)) {
63-
return new PageImpl<>(content, pageable, content.size());
64-
}
62+
if (isPartialPage(content, pageable)) {
6563

66-
if (isSubsequentPage(pageable) && !content.isEmpty() && isPartialPage(content, pageable)) {
67-
return new PageImpl<>(content, pageable, pageable.getOffset() + content.size());
64+
if (isFirstPage(pageable)) {
65+
return new PageImpl<>(content, pageable, content.size());
66+
} else if ( !content.isEmpty()) {
67+
return new PageImpl<>(content, pageable, pageable.getOffset() + content.size());
68+
}
6869
}
6970

7071
return new PageImpl<>(content, pageable, totalSupplier.getAsLong());
@@ -78,7 +79,4 @@ private static boolean isFirstPage(Pageable pageable) {
7879
return pageable.getOffset() == 0;
7980
}
8081

81-
private static boolean isSubsequentPage(Pageable pageable) {
82-
return !isFirstPage(pageable);
83-
}
8482
}

0 commit comments

Comments
 (0)