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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user