- Type Parameters:
T
- the type of elements in this page.
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
CursoredPage<T>
- All Known Implementing Classes:
CursoredPageRecord
,PageRecord
A page contains the data that is retrieved to satisfy a given page request.
An instance of Page
is obtained by supplying a PageRequest
as
an argument of a repository method. For example,
@Find Page<Vehicle> search(@By("make") String make, @By("model") String model, @By("year") int designYear, PageRequest pageRequest, Order<Vehicle> order);
If PageRequest.requestTotal()
is enabled, the Page
also
contains information about the total number of pages
and the total number of elements that can be
retrieved by the query.
-
Method Summary
Modifier and TypeMethodDescriptioncontent()
Returns the page content as aList
.boolean
Returns whether thePage
has content at all.boolean
hasNext()
Returnstrue
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 thatnextPageRequest()
will definitely not returnnull
.boolean
Returnstrue
if it is known that there are previous results or that it is necessary to request the previous page to determine whether there are previous results, so thatpreviousPageRequest()
will not returnnull
.boolean
Returnstrue
if thepageRequest()
specified that the total number of elements should be retrieved from the database, and that it is therefore safe to calltotalElements()
ortotalPages()
.Returns a request for the next page ifhasNext()
indicates there might be a next page.int
Returns the number of elements on thisPage
, which must be no larger than the maximumsize
of the page request.Returns the page request for which this page was obtained.Returns a request for the previous page, ifhasPrevious()
indicates there might be a previous page.stream()
Returns a sequential stream of results, which follow the order of the sort criteria, if any were specified.long
Returns the total number of elements across all pages of query results, if thepageRequest()
specified that the total should be retrieved from the database.long
Returns the total number of pages of query results, if thepageRequest()
specified that the total should be retrieved from the database.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
content
Returns the page content as aList
. The list is sorted according to the combined sort criteria of the repository method and the sort criteria of the page request that is supplied to the repository method, sorting first by the sort criteria of the repository method, and then by the sort criteria of the page request.- Returns:
- the page content as a
List
; will never benull
.
-
hasContent
boolean hasContent()Returns whether thePage
has content at all.- Returns:
- whether the
Page
has content at all.
-
stream
Returns a sequential stream of results, which follow the order of the sort criteria, if any were specified.- Returns:
- a stream of results.
-
numberOfElements
int numberOfElements()Returns the number of elements on thisPage
, which must be no larger than the maximumsize
of the page request. If the number of elements in the page is smaller than the maximum page size, then there are no subsequent pages of data to read.- Returns:
- the number of elements on this
Page
.
-
hasNext
boolean hasNext()Returnstrue
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 thatnextPageRequest()
will definitely not returnnull
.- Returns:
false
if this is the last page of results.
-
hasPrevious
boolean hasPrevious()Returnstrue
if it is known that there are previous results or that it is necessary to request the previous page to determine whether there are previous results, so thatpreviousPageRequest()
will not returnnull
.- Returns:
false
if this is the first page of results.
-
pageRequest
PageRequest pageRequest()Returns the page request for which this page was obtained.- Returns:
- the request for the current page; will never be
null
.
-
nextPageRequest
PageRequest nextPageRequest()Returns a request for the next page ifhasNext()
indicates there might be a next page.- Returns:
- a request for the next page.
- Throws:
NoSuchElementException
- if it is known that there is no next page. To avoid this exception, check for atrue
result ofhasNext()
before invoking this method.
-
previousPageRequest
PageRequest previousPageRequest()Returns a request for the previous page, if
hasPrevious()
indicates there might be a previous page.- Returns:
- a request for the previous page.
- Throws:
NoSuchElementException
- if it is known that there is no previous page. To avoid this exception, check for atrue
result ofhasPrevious()
before invoking this method.
-
hasTotals
boolean hasTotals()Returnstrue
if thepageRequest()
specified that the total number of elements should be retrieved from the database, and that it is therefore safe to calltotalElements()
ortotalPages()
.- Returns:
true
if totals are available.
-
totalElements
long totalElements()Returns the total number of elements across all pages of query results, if thepageRequest()
specified that the total should be retrieved from the database.- Returns:
- the total number of elements across all pages.
- Throws:
IllegalStateException
- if the total was not retrieved from the database.
-
totalPages
long totalPages()Returns the total number of pages of query results, if thepageRequest()
specified that the total should be retrieved from the database.- Returns:
- the total number of pages.
- Throws:
IllegalStateException
- if the total was not retrieved from the database.
-