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
This commit is contained in:
Jens Schauder
2024-07-01 12:57:57 +02:00
parent 47109d4bb1
commit 9ab34d8672

View File

@@ -59,12 +59,13 @@ public abstract class PageableExecutionUtils {
return new PageImpl<>(content, pageable, content.size());
}
if (isFirstPage(pageable) && isPartialPage(content, pageable)) {
return new PageImpl<>(content, pageable, content.size());
}
if (isPartialPage(content, pageable)) {
if (isSubsequentPage(pageable) && !content.isEmpty() && isPartialPage(content, pageable)) {
return new PageImpl<>(content, pageable, pageable.getOffset() + content.size());
if (isFirstPage(pageable)) {
return new PageImpl<>(content, pageable, content.size());
} else if ( !content.isEmpty()) {
return new PageImpl<>(content, pageable, pageable.getOffset() + content.size());
}
}
return new PageImpl<>(content, pageable, totalSupplier.getAsLong());
@@ -78,7 +79,4 @@ public abstract class PageableExecutionUtils {
return pageable.getOffset() == 0;
}
private static boolean isSubsequentPage(Pageable pageable) {
return !isFirstPage(pageable);
}
}