Package jakarta.data.page.impl
Record Class CursoredPageRecord<T>
java.lang.Object
java.lang.Record
jakarta.data.page.impl.CursoredPageRecord<T>
- Type Parameters:
T
- The type of elements on the page- Record Components:
content
- The page content, that is, the query results, in ordercursors
- A list ofPageRequest.Cursor
instances for result, in ordertotalElements
- The total number of elements across all pages that can be requested for the querypageRequest
- Thepage request
for which this page was obtainednextPageRequest
- Apage request
for the next page of resultspreviousPageRequest
- Apage request
for the previous page of results
- All Implemented Interfaces:
CursoredPage<T>
,Page<T>
,Iterable<T>
public record CursoredPageRecord<T>(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest)
extends Record
implements CursoredPage<T>
Record type implementing
CursoredPage
.
This may be used to simplify implementation of a repository interface.-
Constructor Summary
ConstructorDescriptionCursoredPageRecord
(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, boolean firstPage, boolean lastPage) CursoredPageRecord
(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest) Creates an instance of aCursoredPageRecord
record class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()
Returns the value of thecontent
record component.cursor
(int index) Returns aCursor
for key values at the specified position.cursors()
Returns the value of thecursors
record component.final boolean
Indicates whether some other object is "equal to" this one.boolean
Returns whether thePage
has content at all.final int
hashCode()
Returns a hash code value for this object.boolean
hasNext()
Returnstrue
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 thatPage.nextPageRequest()
will definitely not returnnull
.boolean
Returnstrue
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.boolean
Returnstrue
if thePage.pageRequest()
specified that the total number of elements should be retrieved from the database, and that it is therefore safe to callPage.totalElements()
orPage.totalPages()
.iterator()
Returns the value of thenextPageRequest
record component.int
Returns the number of elements on thisPage
, which must be no larger than the maximumsize
of the page request.Returns the value of thepageRequest
record component.Returns the value of thepreviousPageRequest
record component.final String
toString()
Returns a string representation of this record class.long
Returns the value of thetotalElements
record component.long
Returns the total number of pages of query results, if thePage.pageRequest()
specified that the total should be retrieved from the database.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CursoredPageRecord
public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, boolean firstPage, boolean lastPage) - Parameters:
content
- The page content, that is, the query results, in ordercursors
- A list ofPageRequest.Cursor
instances for result, in ordertotalElements
- The total number of elements across all pages that can be requested for the querypageRequest
- Thepage request
for which this page was obtainedfirstPage
- True, if this is the first page of resultslastPage
- True, if this is the last page of results
-
CursoredPageRecord
public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest) Creates an instance of aCursoredPageRecord
record class.- Parameters:
content
- the value for thecontent
record componentcursors
- the value for thecursors
record componenttotalElements
- the value for thetotalElements
record componentpageRequest
- the value for thepageRequest
record componentnextPageRequest
- the value for thenextPageRequest
record componentpreviousPageRequest
- the value for thepreviousPageRequest
record component
-
-
Method Details
-
hasContent
public boolean hasContent()Description copied from interface:Page
Returns whether thePage
has content at all.- Specified by:
hasContent
in interfacePage<T>
- Returns:
- whether the
Page
has content at all.
-
numberOfElements
public int numberOfElements()Description copied from interface:Page
Returns the number of elements on thisPage
, which must be no larger than the maximumsize
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.- Specified by:
numberOfElements
in interfacePage<T>
- Returns:
- the number of elements on this
Page
.
-
hasNext
public boolean hasNext()Description copied from interface:Page
Returnstrue
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 thatPage.nextPageRequest()
will definitely not returnnull
. -
hasPrevious
public boolean hasPrevious()Description copied from interface:CursoredPage
Returnstrue
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.- Specified by:
hasPrevious
in interfaceCursoredPage<T>
- Specified by:
hasPrevious
in interfacePage<T>
- Returns:
false
if the current page is empty or if it is known that there is not a previous page.
-
nextPageRequest
Returns the value of thenextPageRequest
record component.- Specified by:
nextPageRequest
in interfaceCursoredPage<T>
- Specified by:
nextPageRequest
in interfacePage<T>
- Returns:
- the value of the
nextPageRequest
record component
-
previousPageRequest
Returns the value of thepreviousPageRequest
record component.- Specified by:
previousPageRequest
in interfaceCursoredPage<T>
- Specified by:
previousPageRequest
in interfacePage<T>
- Returns:
- the value of the
previousPageRequest
record component
-
iterator
-
cursor
Description copied from interface:CursoredPage
Returns aCursor
for key values at the specified position.- Specified by:
cursor
in interfaceCursoredPage<T>
- Parameters:
index
- position (0 is first) of a result on the page.- Returns:
- cursor for key values at the specified position.
-
hasTotals
public boolean hasTotals()Description copied from interface:Page
Returnstrue
if thePage.pageRequest()
specified that the total number of elements should be retrieved from the database, and that it is therefore safe to callPage.totalElements()
orPage.totalPages()
. -
totalElements
public long totalElements()Returns the value of thetotalElements
record component.- Specified by:
totalElements
in interfacePage<T>
- Returns:
- the value of the
totalElements
record component
-
totalPages
public long totalPages()Description copied from interface:Page
Returns the total number of pages of query results, if thePage.pageRequest()
specified that the total should be retrieved from the database.- Specified by:
totalPages
in interfacePage<T>
- Returns:
- the total number of pages.
-
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. -
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 '=='. -
content
Returns the value of thecontent
record component. -
cursors
Returns the value of thecursors
record component.- Returns:
- the value of the
cursors
record component
-
pageRequest
Returns the value of thepageRequest
record component.- Specified by:
pageRequest
in interfacePage<T>
- Returns:
- the value of the
pageRequest
record component
-