Top Description Fields Constructors Methods
jakarta.data.page

pack-priv final Record Pagination

extends Record
implements PageRequest
Class Inheritance
All Implemented Interfaces
jakarta.data.page.PageRequest
Record Components
page:long 
size:int 
mode:PageRequest.Mode 
type:PageRequest.Cursor 
requestTotal:boolean 
Imports
java.util.Optional

Built-in implementation of PageRequest.

Field Summary

Modifier and TypeField and Description
private final PageRequest.Mode
mode

Record Component accessed by mode().

private final long
page

Record Component accessed by page().

private final boolean
requestTotal

Record Component accessed by requestTotal().

private final int
size

Record Component accessed by size().

private final PageRequest.Cursor
type

Record Component accessed by type().

Constructor Summary

AccessConstructor and Description
pack-priv
Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal)

Method Summary

Modifier and TypeMethod and Description
public PageRequest
afterCursor(PageRequest.Cursor
cursor with key values, the order and number of which must match the OrderBy annotations, jakarta.data.Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.
cursor
)

Implements jakarta.data.page.PageRequest.afterCursor.

Requests cursor-based pagination in the forward direction, starting after the specified key.

public PageRequest
beforeCursor(PageRequest.Cursor
cursor with key values, the order and number of which must match the OrderBy annotations, jakarta.data.Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.
cursor
)

Implements jakarta.data.page.PageRequest.beforeCursor.

Requests cursor-based pagination in the previous page direction relative to the specified key values.

public Optional<PageRequest.Cursor>
cursor()

Implements jakarta.data.page.PageRequest.cursor.

Returns the key values which are the starting point for cursor-based pagination.

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

Implements abstract java.lang.Record.equals.

Implements jakarta.data.page.PageRequest.equals.

Compares with another instance to determine if both represent the same pagination information.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public PageRequest.Mode
mode()

Record Component getter of mode.

Implements jakarta.data.page.PageRequest.mode.

Returns the type of pagination.

public long
page()

Record Component getter of page.

Implements jakarta.data.page.PageRequest.page.

Returns the page to be returned.

public boolean
requestTotal()

Record Component getter of requestTotal.

Implements jakarta.data.page.PageRequest.requestTotal.

Indicates that a query method which returns a Page should retrieve the total number of elements available across all pages.

public PageRequest
size(int
the number of query results in a full page.
maxPageSize
)

Implements jakarta.data.page.PageRequest.size.

Creates a new page request with the same pagination information, but with the specified maximum page size.

public int
size()

Record Component getter of size.

Implements jakarta.data.page.PageRequest.size.

Returns the requested size of each page

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public PageRequest.Cursor
type()

Record Component getter of type.

public PageRequest
withoutTotal()

Implements jakarta.data.page.PageRequest.withoutTotal.

Returns an otherwise-equivalent page request with requestTotal() set to false, so that totals will not be retrieved from the database.

public PageRequest
withTotal()

Implements jakarta.data.page.PageRequest.withTotal.

Returns an otherwise-equivalent page request with requestTotal() set to false, so that totals will be retrieved from the database.

Field Detail

modeback to summary
private final PageRequest.Mode mode

Record Component accessed by mode().

pageback to summary
private final long page

Record Component accessed by page().

requestTotalback to summary
private final boolean requestTotal

Record Component accessed by requestTotal().

sizeback to summary
private final int size

Record Component accessed by size().

typeback to summary
private final PageRequest.Cursor type

Record Component accessed by type().

Constructor Detail

Paginationback to summary
pack-priv Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal)

Method Detail

afterCursorback to summary
public PageRequest afterCursor(PageRequest.Cursor cursor)

Implements jakarta.data.page.PageRequest.afterCursor.

Doc from jakarta.data.page.PageRequest.afterCursor.

Requests cursor-based pagination in the forward direction, starting after the specified key.

Parameters
cursor:PageRequest.Cursor

cursor with key values, the order and number of which must match the OrderBy annotations, jakarta.data.Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.

Returns:PageRequest

a new instance of PageRequest with forward cursor-based pagination. This method never returns null.

Annotations
@Override
beforeCursorback to summary
public PageRequest beforeCursor(PageRequest.Cursor cursor)

Implements jakarta.data.page.PageRequest.beforeCursor.

Doc from jakarta.data.page.PageRequest.beforeCursor.

Requests cursor-based pagination in the previous page direction relative to the specified key values.

Parameters
cursor:PageRequest.Cursor

cursor with key values, the order and number of which must match the OrderBy annotations, jakarta.data.Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.

Returns:PageRequest

a new instance of PageRequest with cursor-based pagination in the previous page direction. This method never returns null.

Annotations
@Override
cursorback to summary
public Optional<PageRequest.Cursor> cursor()

Implements jakarta.data.page.PageRequest.cursor.

Doc from jakarta.data.page.PageRequest.cursor.

Returns the key values which are the starting point for cursor-based pagination.

Returns:Optional<PageRequest.Cursor>

the cursor; Optional#empty() if using offset pagination.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Implements jakarta.data.page.PageRequest.equals.

Doc from jakarta.data.page.PageRequest.equals.

Compares with another instance to determine if both represent the same pagination information.

Parameters
o:Object

Doc from java.lang.Record.equals.

the reference object with which to compare.

Returns:boolean

true if both instances are of the same class and represent the same pagination information. Otherwise false.

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.

modeback to summary
public PageRequest.Mode mode()

Record Component getter of mode.

Implements jakarta.data.page.PageRequest.mode.

Doc from jakarta.data.page.PageRequest.mode.

Returns the type of pagination.

Returns:PageRequest.Mode

the type of pagination.

pageback to summary
public long page()

Record Component getter of page.

Implements jakarta.data.page.PageRequest.page.

Doc from jakarta.data.page.PageRequest.page.

Returns the page to be returned.

Returns:long

the page to be returned.

requestTotalback to summary
public boolean requestTotal()

Record Component getter of requestTotal.

Implements jakarta.data.page.PageRequest.requestTotal.

Doc from jakarta.data.page.PageRequest.requestTotal.

Indicates that a query method which returns a Page should retrieve the total number of elements available across all pages. This behavior is enabled by default. To obtain a page request with total retrieval disabled, call withoutTotal().

Returns:boolean

true if the total number of elements should be retrieved from the database.

sizeback to summary
public PageRequest size(int maxPageSize)

Implements jakarta.data.page.PageRequest.size.

Doc from jakarta.data.page.PageRequest.size.

Creates a new page request with the same pagination information, but with the specified maximum page size. When a page is retrieved from the database, the number of elements in the page must be equal to the maximum page size unless there is an insufficient number of elements to retrieve from the database from the start of the page.

Parameters
maxPageSize:int

the number of query results in a full page.

Returns:PageRequest

a new instance of PageRequest. This method never returns null.

Annotations
@Override
sizeback to summary
public int size()

Record Component getter of size.

Implements jakarta.data.page.PageRequest.size.

Doc from jakarta.data.page.PageRequest.size.

Returns the requested size of each page

Returns:int

the requested size of each page

toStringback to summary
public 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.

Annotations
@Override
typeback to summary
public PageRequest.Cursor type()

Record Component getter of type.

withoutTotalback to summary
public PageRequest withoutTotal()

Implements jakarta.data.page.PageRequest.withoutTotal.

Doc from jakarta.data.page.PageRequest.withoutTotal.

Returns an otherwise-equivalent page request with requestTotal() set to false, so that totals will not be retrieved from the database. Note that when totals are not retrieved by a repository method with return type Page, the operations Page#totalElements() and Page#totalPages() throw an IllegalStateException when called.

Returns:PageRequest

a page request with requestTotal() set to false.

Annotations
@Override
withTotalback to summary
public PageRequest withTotal()

Implements jakarta.data.page.PageRequest.withTotal.

Doc from jakarta.data.page.PageRequest.withTotal.

Returns an otherwise-equivalent page request with requestTotal() set to false, so that totals will be retrieved from the database.

Returns:PageRequest

a page request with requestTotal() set to true.

Annotations
@Override