-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add boolean Page.hasNextPage() #506
Changes from all commits
5a1fd27
2395cc3
bf078f6
adadd9f
1951072
ed7bec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,14 @@ public interface Slice<T> extends Streamable<T> { | |
*/ | ||
int numberOfElements(); | ||
|
||
/** | ||
* Returns {@code true} if it is known that there are more results or that it is | ||
* necessary to request a next page to determine whether there are more results, so that | ||
* {@link #nextPageRequest()} will definitely not return {@code null}. | ||
* @return {@code false} if this is the last page of results. | ||
*/ | ||
boolean hasNext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same point here. Include the UnsupportedOperationException if the database does not know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No -that wrecks the whole pattern. The point is that if the provider does not know if there is going to be a next page, then we want the user to request it to find out and the user should be able to do that without having to experience exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @otaviojava I think the idea here is that if you have a full last page of results you might not know that it is the last page. What @njr-11 is trying to permit here is that there be an "empty last page". Which I think is fine and correct. Providers can in principle use a "fancy" implementation that avoids this, but I don't think we should mandate such fanciness. |
||
|
||
/** | ||
* Returns the {@link PageRequest page request} for which this | ||
* slice was obtained. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using false to both makes it unclear if it is empty or the database does not know the previous page.
Are we sure to proceed this way?
I mean, if I receive false I need to check anyway...
Maybe an UnsupportedOperationException when it does not know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otavio, are you sure you are reading this correctly? When the value is
false
is when you should never try to request the page because it is known to not exist. An empty page has no cursors and therefore cannot have a previous. In the other case it is stated there is no previous page. If you getfalse
and then ask forpreviousPageableRequest
anyways, you can expect to get an exception from the latter. There is no point in trying.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my bad. Thank you for clarifying it.