Top Description Methods
jakarta.data.page

public Interface Page<T>

extends Iterable<T>
Known Direct Subinterfaces
jakarta.data.page.CursoredPage
Known Direct Implementers
jakarta.data.page.impl.PageRecord
Type Parameters
<T>
the type of elements in this page.
Imports
java.util.List, .NoSuchElementException, java.util.stream.Stream, .StreamSupport

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 TypeMethod and Description
public List<T>

Returns:

the page content as a List; will never be null.
content
()

Returns the page content as a List.

public boolean

Returns:

whether the Page has content at all.
hasContent
()

Returns whether the Page has content at all.

public boolean

Returns:

false if this is the last page of results.
hasNext
()

Returns 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 nextPageRequest() will definitely not return null.

public boolean

Returns:

false if this is the first page of results.
hasPrevious
()

Returns true 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 that previousPageRequest() will not return null.

public boolean

Returns:

true if totals are available.
hasTotals
()

Returns true if the pageRequest() specified that the total number of elements should be retrieved from the database, and that it is therefore safe to call totalElements() or totalPages().

public PageRequest

Returns:

a request for the next page.
nextPageRequest
()

Returns a request for the next page if hasNext() indicates there might be a next page.

public int

Returns:

the number of elements on this Page.
numberOfElements
()

Returns the number of elements on this Page, which must be no larger than the maximum size of the page request.

public PageRequest

Returns:

the request for the current page; will never be null.
pageRequest
()

Returns the page request for which this page was obtained.

public PageRequest

Returns:

a request for the previous page.
previousPageRequest
()

Returns a request for the previous page, if hasPrevious() indicates there might be a previous page.

public default Stream<T>

Returns:

a stream of results.
stream
()

Returns a sequential stream of results, which follow the order of the sort criteria, if any were specified.

public long

Returns:

the total number of elements across all pages.
totalElements
()

Returns the total number of elements across all pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

public long

Returns:

the total number of pages.
totalPages
()

Returns the total number of pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Inherited from java.lang.Iterable:
forEachiteratorspliterator

Method Detail

contentback to summary
public List<T> content()

Returns the page content as a List. 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:List<T>

the page content as a List; will never be null.

hasContentback to summary
public boolean hasContent()

Returns whether the Page has content at all.

Returns:boolean

whether the Page has content at all.

hasNextback to summary
public boolean hasNext()

Returns 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 nextPageRequest() will definitely not return null.

Returns:boolean

false if this is the last page of results.

hasPreviousback to summary
public boolean hasPrevious()

Returns true 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 that previousPageRequest() will not return null.

Returns:boolean

false if this is the first page of results.

hasTotalsback to summary
public boolean hasTotals()

Returns true if the pageRequest() specified that the total number of elements should be retrieved from the database, and that it is therefore safe to call totalElements() or totalPages().

Returns:boolean

true if totals are available.

nextPageRequestback to summary
public PageRequest nextPageRequest()

Returns a request for the next page if hasNext() indicates there might be a next page.

Returns:PageRequest

a request for the next page.

Exceptions
NoSuchElementException:
if it is known that there is no next page. To avoid this exception, check for a true result of hasNext() before invoking this method.
numberOfElementsback to summary
public int numberOfElements()

Returns the number of elements on this Page, which must be no larger than the maximum size 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:int

the number of elements on this Page.

pageRequestback to summary
public PageRequest pageRequest()

Returns the page request for which this page was obtained.

Returns:PageRequest

the request for the current page; will never be null.

previousPageRequestback to summary
public PageRequest previousPageRequest()

Returns a request for the previous page, if hasPrevious() indicates there might be a previous page.

Returns:PageRequest

a request for the previous page.

Exceptions
NoSuchElementException:
if it is known that there is no previous page. To avoid this exception, check for a true result of hasPrevious() before invoking this method.
streamback to summary
public default Stream<T> stream()

Returns a sequential stream of results, which follow the order of the sort criteria, if any were specified.

Returns:Stream<T>

a stream of results.

totalElementsback to summary
public long totalElements()

Returns the total number of elements across all pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Returns:long

the total number of elements across all pages.

Exceptions
IllegalStateException:
if the total was not retrieved from the database.
totalPagesback to summary
public long totalPages()

Returns the total number of pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Returns:long

the total number of pages.

Exceptions
IllegalStateException:
if the total was not retrieved from the database.