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 jakarta.data.page.PageRequest
PageRequest.Cursor, PageRequest.Mode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PageRequest.Mode
The field for themode
record component.private final long
The field for thepage
record component.private final boolean
The field for therequestTotal
record component.private final int
The field for thesize
record component.private final PageRequest.Cursor
The field for thetype
record component. -
Constructor Summary
ConstructorsConstructorDescriptionPagination
(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal) Creates an instance of aPagination
record 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 boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.mode()
Returns the value of themode
record component.long
page()
Returns the value of thepage
record component.boolean
Returns the value of therequestTotal
record component.int
size()
Returns the value of thesize
record 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 thetype
record 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 thepage
record component. -
size
private final int sizeThe field for thesize
record component. -
mode
The field for themode
record component. -
type
The field for thetype
record component. -
requestTotal
private final boolean requestTotalThe field for therequestTotal
record component.
-
-
Constructor Details
-
Pagination
Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal) Creates an instance of aPagination
record class.- Parameters:
page
- the value for thepage
record componentsize
- the value for thesize
record componentmode
- the value for themode
record componenttype
- the value for thetype
record componentrequestTotal
- the value for therequestTotal
record component
-
-
Method Details
-
withoutTotal
Description copied from interface:PageRequest
Returns 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 anIllegalStateException
when called.- Specified by:
withoutTotal
in interfacePageRequest
- Returns:
- a page request with
PageRequest.requestTotal()
set tofalse
.
-
withTotal
Description copied from interface:PageRequest
Returns an otherwise-equivalent page request withPageRequest.requestTotal()
set tofalse
, so that totals will be retrieved from the database.- Specified by:
withTotal
in interfacePageRequest
- Returns:
- a page request with
PageRequest.requestTotal()
set totrue
.
-
afterCursor
Description copied from interface:PageRequest
Requests cursor-based pagination in the forward direction, starting after the specified key.
- Specified by:
afterCursor
in interfacePageRequest
- Parameters:
cursor
- cursor with key values, the order and number of which must match theOrderBy
annotations,Sort
parameters, orOrderBy
name pattern of the repository method to which this pagination will be supplied.- Returns:
- a new instance of
PageRequest
with forward cursor-based pagination. This method never returnsnull
.
-
beforeCursor
Description copied from interface:PageRequest
Requests cursor-based pagination in the previous page direction relative to the specified key values.
- Specified by:
beforeCursor
in interfacePageRequest
- Parameters:
cursor
- cursor with key values, the order and number of which must match theOrderBy
annotations,Sort
parameters, orOrderBy
name pattern of the repository method to which this pagination will be supplied.- Returns:
- a new instance of
PageRequest
with cursor-based pagination in the previous page direction. This method never returnsnull
.
-
cursor
Description copied from interface:PageRequest
Returns the key values which are the starting point for cursor-based pagination.- Specified by:
cursor
in interfacePageRequest
- Returns:
- the cursor;
Optional.empty()
if using offset pagination.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
size
Description copied from interface:PageRequest
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.
- Specified by:
size
in interfacePageRequest
- Parameters:
maxPageSize
- the number of query results in a full page.- Returns:
- a new instance of
PageRequest
. This method never returnsnull
.
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='.- Specified by:
equals
in interfacePageRequest
- Specified by:
equals
in classRecord
- Parameters:
o
- the object with which to compare- Returns:
true
if this object is the same as theo
argument;false
otherwise.
-
page
public long page()Returns the value of thepage
record component.- Specified by:
page
in interfacePageRequest
- Returns:
- the value of the
page
record component
-
size
public int size()Returns the value of thesize
record component.- Specified by:
size
in interfacePageRequest
- Returns:
- the value of the
size
record component
-
mode
Returns the value of themode
record component.- Specified by:
mode
in interfacePageRequest
- Returns:
- the value of the
mode
record component
-
type
Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-
requestTotal
public boolean requestTotal()Returns the value of therequestTotal
record component.- Specified by:
requestTotal
in interfacePageRequest
- Returns:
- the value of the
requestTotal
record component
-