Record Class Pagination
java.lang.Object
java.lang.Record
jakarta.data.page.Pagination
- All Implemented Interfaces:
PageRequest
record Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal)
extends Record
implements PageRequest
Built-in implementation of PageRequest.
-
Nested Class Summary
Nested classes/interfaces inherited from interface PageRequest
PageRequest.Cursor, PageRequest.Mode -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PageRequest.ModeThe field for themoderecord component.private final longThe field for thepagerecord component.private final booleanThe field for therequestTotalrecord component.private final intThe field for thesizerecord component.private final PageRequest.CursorThe field for thetyperecord component. -
Constructor Summary
ConstructorsConstructorDescriptionPagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal) Creates an instance of aPaginationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionafterCursor(PageRequest.Cursor cursor) Requests cursor-based pagination in the forward direction, starting after the specified key.beforeCursor(PageRequest.Cursor cursor) Requests cursor-based pagination in the previous page direction relative to the specified key values.cursor()Returns the key values which are the starting point for cursor-based pagination.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.mode()Returns the value of themoderecord component.longpage()Returns the value of thepagerecord component.booleanReturns the value of therequestTotalrecord component.intsize()Returns the value of thesizerecord component.size(int maxPageSize) Creates a new page request with the same pagination information, but with the specified maximum page size.toString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Returns an otherwise-equivalent page request withPageRequest.requestTotal()set tofalse, so that totals will not be retrieved from the database.Returns an otherwise-equivalent page request withPageRequest.requestTotal()set tofalse, so that totals will be retrieved from the database.
-
Field Details
-
page
private final long pageThe field for thepagerecord component. -
size
private final int sizeThe field for thesizerecord component. -
mode
The field for themoderecord component. -
type
The field for thetyperecord component. -
requestTotal
private final boolean requestTotalThe field for therequestTotalrecord component.
-
-
Constructor Details
-
Pagination
Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal) Creates an instance of aPaginationrecord class.- Parameters:
page- the value for thepagerecord componentsize- the value for thesizerecord componentmode- the value for themoderecord componenttype- the value for thetyperecord componentrequestTotal- the value for therequestTotalrecord component
-
-
Method Details
-
withoutTotal
Description copied from interface:PageRequestReturns an otherwise-equivalent page request withPageRequest.requestTotal()set tofalse, so that totals will not be retrieved from the database. Note that when totals are not retrieved by a repository method with return typePage, the operationsPage.totalElements()andPage.totalPages()throw anIllegalStateExceptionwhen called.- Specified by:
withoutTotalin interfacePageRequest- Returns:
- a page request with
PageRequest.requestTotal()set tofalse.
-
withTotal
Description copied from interface:PageRequestReturns an otherwise-equivalent page request withPageRequest.requestTotal()set tofalse, so that totals will be retrieved from the database.- Specified by:
withTotalin interfacePageRequest- Returns:
- a page request with
PageRequest.requestTotal()set totrue.
-
afterCursor
Description copied from interface:PageRequestRequests cursor-based pagination in the forward direction, starting after the specified key.
- Specified by:
afterCursorin interfacePageRequest- Parameters:
cursor- cursor with key values, the order and number of which must match theOrderByannotations,Sortparameters, orOrderByname pattern of the repository method to which this pagination will be supplied.- Returns:
- a new instance of
PageRequestwith forward cursor-based pagination. This method never returnsnull.
-
beforeCursor
Description copied from interface:PageRequestRequests cursor-based pagination in the previous page direction relative to the specified key values.
- Specified by:
beforeCursorin interfacePageRequest- Parameters:
cursor- cursor with key values, the order and number of which must match theOrderByannotations,Sortparameters, orOrderByname pattern of the repository method to which this pagination will be supplied.- Returns:
- a new instance of
PageRequestwith cursor-based pagination in the previous page direction. This method never returnsnull.
-
cursor
Description copied from interface:PageRequestReturns the key values which are the starting point for cursor-based pagination.- Specified by:
cursorin interfacePageRequest- Returns:
- the cursor;
Optional.empty()if using offset pagination.
-
toString
-
size
Description copied from interface:PageRequestCreates 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.
- Specified by:
sizein interfacePageRequest- Parameters:
maxPageSize- the number of query results in a full page.- Returns:
- a new instance of
PageRequest. This method never returnsnull.
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes.- Specified by:
equalsin interfacePageRequest- Specified by:
equalsin classRecord- Parameters:
o- the object with which to compare- Returns:
trueif this object is the same as theoargument;falseotherwise.
-
page
public long page()Returns the value of thepagerecord component.- Specified by:
pagein interfacePageRequest- Returns:
- the value of the
pagerecord component
-
size
public int size()Returns the value of thesizerecord component.- Specified by:
sizein interfacePageRequest- Returns:
- the value of the
sizerecord component
-
mode
Returns the value of themoderecord component.- Specified by:
modein interfacePageRequest- Returns:
- the value of the
moderecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
requestTotal
public boolean requestTotal()Returns the value of therequestTotalrecord component.- Specified by:
requestTotalin interfacePageRequest- Returns:
- the value of the
requestTotalrecord component
-