Top Description Fields Constructors Methods
jakarta.data.page.impl

public final Record CursoredPageRecord<T>

extends Record
implements CursoredPage<T>
Class Inheritance
All Implemented Interfaces
jakarta.data.page.CursoredPage, jakarta.data.page.Page, java.lang.Iterable
Record Components
nextPageRequest:PageRequest

Doc from jakarta.data.page.CursoredPage.nextPageRequest. A page request for the next page of results

previousPageRequest:PageRequest

Doc from jakarta.data.page.CursoredPage.previousPageRequest. A page request for the previous page of results

totalElements:long

Doc from jakarta.data.page.Page.totalElements. The total number of elements across all pages that can be requested for the query

content:List<T>

Doc from jakarta.data.page.Page.content. The page content, that is, the query results, in order

cursors:List<PageRequest.Cursor>
A list of PageRequest.Cursor instances for result, in order
pageRequest:PageRequest

Doc from jakarta.data.page.Page.pageRequest. The page request for which this page was obtained

Type Parameters
<T>
The type of elements on the page
Imports
jakarta.data.page.CursoredPage, .PageRequest, java.util.Iterator, .List, .NoSuchElementException

Record type implementing CursoredPage. This may be used to simplify implementation of a repository interface.

Field Summary

Modifier and TypeField and Description
private final List<T>
content

Record Component accessed by content().

The page content, that is, the query results, in order
private final List<PageRequest.Cursor>
cursors

Record Component accessed by cursors().

A list of PageRequest.Cursor instances for result, in order
private final PageRequest
nextPageRequest

Record Component accessed by nextPageRequest().

A page request for the next page of results
private final PageRequest
pageRequest

Record Component accessed by pageRequest().

The page request for which this page was obtained
private final PageRequest
previousPageRequest

Record Component accessed by previousPageRequest().

A page request for the previous page of results
private final long
totalElements

Record Component accessed by totalElements().

The total number of elements across all pages that can be requested for the query

Constructor Summary

AccessConstructor and Description
public
CursoredPageRecord(List<T>
The page content, that is, the query results, in order
content
,
List<PageRequest.Cursor>
A list of PageRequest.Cursor instances for result, in order
cursors
,
long
The total number of elements across all pages that can be requested for the query
totalElements
,
PageRequest
The page request for which this page was obtained
pageRequest
,
boolean
True, if this is the first page of results
firstPage
,
boolean
True, if this is the last page of results
lastPage
)

public
CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest)

Method Summary

Modifier and TypeMethod and Description
public List<T>
content()

Record Component getter of content.

Implements jakarta.data.page.Page.content.

Returns the page content as a List.

Record Component The page content, that is, the query results, in order

public PageRequest.Cursor
cursor(int
position (0 is first) of a result on the page.
index
)

Implements jakarta.data.page.CursoredPage.cursor.

Returns a Cursor for key values at the specified position.

public List<PageRequest.Cursor>
cursors()

Record Component getter of cursors.

Record Component A list of PageRequest.Cursor instances for result, in order

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public boolean
hasContent()

Implements jakarta.data.page.Page.hasContent.

Returns whether the Page has content at all.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
hasNext()

Implements jakarta.data.page.Page.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
hasPrevious()

Implements jakarta.data.page.CursoredPage.hasPrevious.

Returns true when it is possible to navigate to a previous page of results or if it is necessary to request a previous page in order to determine whether there are more previous results.

public boolean
hasTotals()

Implements jakarta.data.page.Page.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 Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public PageRequest
nextPageRequest()

Record Component getter of nextPageRequest.

Implements jakarta.data.page.CursoredPage.nextPageRequest.

Creates a request for the next page in a forward direction from the current page.

Record Component A page request for the next page of results

public int
numberOfElements()

Implements jakarta.data.page.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
pageRequest()

Record Component getter of pageRequest.

Implements jakarta.data.page.Page.pageRequest.

Returns the page request for which this page was obtained.

Record Component The page request for which this page was obtained

public PageRequest
previousPageRequest()

Record Component getter of previousPageRequest.

Implements jakarta.data.page.CursoredPage.previousPageRequest.

Creates a request for the previous page in a reverse direction from the current page.

Record Component A page request for the previous page of results

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public long
totalElements()

Record Component getter of totalElements.

Implements jakarta.data.page.Page.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.

Record Component The total number of elements across all pages that can be requested for the query

public long
totalPages()

Implements jakarta.data.page.Page.totalPages.

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

Field Detail

contentback to summary
private final List<T> content

Record Component accessed by content().

The page content, that is, the query results, in order

cursorsback to summary
private final List<PageRequest.Cursor> cursors

Record Component accessed by cursors().

A list of PageRequest.Cursor instances for result, in order

nextPageRequestback to summary
private final PageRequest nextPageRequest

Record Component accessed by nextPageRequest().

A page request for the next page of results

pageRequestback to summary
private final PageRequest pageRequest

Record Component accessed by pageRequest().

The page request for which this page was obtained

previousPageRequestback to summary
private final PageRequest previousPageRequest

Record Component accessed by previousPageRequest().

A page request for the previous page of results

totalElementsback to summary
private final long totalElements

Record Component accessed by totalElements().

The total number of elements across all pages that can be requested for the query

Constructor Detail

CursoredPageRecordback to summary
public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, boolean firstPage, boolean lastPage)
Parameters
content:List<T>

The page content, that is, the query results, in order

cursors:List<PageRequest.Cursor>

A list of PageRequest.Cursor instances for result, in order

totalElements:long

The total number of elements across all pages that can be requested for the query

pageRequest:PageRequest

The page request for which this page was obtained

firstPage:boolean

True, if this is the first page of results

lastPage:boolean

True, if this is the last page of results

CursoredPageRecordback to summary
public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest)

Method Detail

contentback to summary
public List<T> content()

Record Component getter of content.

Implements jakarta.data.page.Page.content.

Doc from jakarta.data.page.Page.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.

Record Component
The page content, that is, the query results, in order
Returns:List<T>

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

cursorback to summary
public PageRequest.Cursor cursor(int index)

Implements jakarta.data.page.CursoredPage.cursor.

Doc from jakarta.data.page.CursoredPage.cursor.

Returns a Cursor for key values at the specified position.

Parameters
index:int

position (0 is first) of a result on the page.

Returns:PageRequest.Cursor

cursor for key values at the specified position.

Annotations
@Override
cursorsback to summary
public List<PageRequest.Cursor> cursors()

Record Component getter of cursors.

Record Component
A list of PageRequest.Cursor instances for result, in order
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hasContentback to summary
public boolean hasContent()

Implements jakarta.data.page.Page.hasContent.

Doc from jakarta.data.page.Page.hasContent.

Returns whether the Page has content at all.

Returns:boolean

whether the Page has content at all.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

hasNextback to summary
public boolean hasNext()

Implements jakarta.data.page.Page.hasNext.

Doc from jakarta.data.page.Page.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.

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements jakarta.data.page.CursoredPage.hasPrevious.

Doc from jakarta.data.page.CursoredPage.hasPrevious.

Returns true when it is possible to navigate to a previous page of results or if it is necessary to request a previous page in order to determine whether there are more previous results.

Returns:boolean

false if the current page is empty or if it is known that there is not a previous page.

Annotations
@Override
hasTotalsback to summary
public boolean hasTotals()

Implements jakarta.data.page.Page.hasTotals.

Doc from jakarta.data.page.Page.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.

Annotations
@Override
iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<T>

an Iterator.

Annotations
@Override
nextPageRequestback to summary
public PageRequest nextPageRequest()

Record Component getter of nextPageRequest.

Implements jakarta.data.page.CursoredPage.nextPageRequest.

Doc from jakarta.data.page.CursoredPage.nextPageRequest.

Creates a request for the next page in a forward direction from the current page. This method computes a cursor from the last entity of the current page and includes the cursor in the pagination information so that it can be used to obtain the next page in a forward direction according to the sort criteria and relative to that entity.

Record Component
A page request for the next page of results
Returns:PageRequest

pagination information for requesting the next page.

Annotations
@Override
numberOfElementsback to summary
public int numberOfElements()

Implements jakarta.data.page.Page.numberOfElements.

Doc from jakarta.data.page.Page.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.

Annotations
@Override
pageRequestback to summary
public PageRequest pageRequest()

Record Component getter of pageRequest.

Implements jakarta.data.page.Page.pageRequest.

Doc from jakarta.data.page.Page.pageRequest.

Returns the page request for which this page was obtained.

Record Component
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()

Record Component getter of previousPageRequest.

Implements jakarta.data.page.CursoredPage.previousPageRequest.

Doc from jakarta.data.page.CursoredPage.previousPageRequest.

Creates a request for the previous page in a reverse direction from the current page. This method computes a cursor from the first entity of the current page and includes the cursor in the pagination information so that it can be used to obtain the previous page in a reverse direction to the sort criteria and relative to that entity. Within a single page, results are not reversed and remain ordered according to the sort criteria.

Page numbers are not accurate and should not be relied upon when using cursor-based pagination. Jakarta Data providers should aim to at least avoid returning negative or 0 as page numbers when traversing pages in the previous page direction (this might otherwise occur when matching entities are added prior to the first page and the previous page is requested) by assigning a page number of 1 to such pages. This means that there can be multiple consecutive pages numbered 1 and that navigating to the previous page and then forward again cannot be relied upon to return a page number that is equal to the current page number.

Record Component
A page request for the previous page of results
Returns:PageRequest

pagination information for requesting the previous page.

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.

totalElementsback to summary
public long totalElements()

Record Component getter of totalElements.

Implements jakarta.data.page.Page.totalElements.

Doc from jakarta.data.page.Page.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.

Record Component
The total number of elements across all pages that can be requested for the query
Returns:long

the total number of elements across all pages.

Annotations
@Override
totalPagesback to summary
public long totalPages()

Implements jakarta.data.page.Page.totalPages.

Doc from jakarta.data.page.Page.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.

Annotations
@Override