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.Cursorinstances for result, in ordertotalElements- The total number of elements across all pages that can be requested for the querypageRequest- Thepage requestfor which this page was obtainednextPageRequest- Apage requestfor the next page of resultspreviousPageRequest- Apage requestfor 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.-
Field Summary
FieldsModifier and TypeFieldDescriptionThe field for thecontentrecord component.private final List<PageRequest.Cursor> The field for thecursorsrecord component.private final PageRequestThe field for thenextPageRequestrecord component.private final PageRequestThe field for thepageRequestrecord component.private final PageRequestThe field for thepreviousPageRequestrecord component.private final longThe field for thetotalElementsrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionCursoredPageRecord(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 aCursoredPageRecordrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.cursor(int index) Returns aCursorfor key values at the specified position.cursors()Returns the value of thecursorsrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns whether thePagehas content at all.final inthashCode()Returns a hash code value for this object.booleanhasNext()Returnstrueif 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.booleanReturnstruewhen 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.booleanReturnstrueif 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 thenextPageRequestrecord component.intReturns the number of elements on thisPage, which must be no larger than the maximumsizeof the page request.Returns the value of thepageRequestrecord component.Returns the value of thepreviousPageRequestrecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalElementsrecord component.longReturns the total number of pages of query results, if thePage.pageRequest()specified that the total should be retrieved from the database.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
-
cursors
The field for thecursorsrecord component. -
totalElements
private final long totalElementsThe field for thetotalElementsrecord component. -
pageRequest
The field for thepageRequestrecord component. -
nextPageRequest
The field for thenextPageRequestrecord component. -
previousPageRequest
The field for thepreviousPageRequestrecord component.
-
-
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.Cursorinstances for result, in ordertotalElements- The total number of elements across all pages that can be requested for the querypageRequest- Thepage requestfor 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 aCursoredPageRecordrecord class.- Parameters:
content- the value for thecontentrecord componentcursors- the value for thecursorsrecord componenttotalElements- the value for thetotalElementsrecord componentpageRequest- the value for thepageRequestrecord componentnextPageRequest- the value for thenextPageRequestrecord componentpreviousPageRequest- the value for thepreviousPageRequestrecord component
-
-
Method Details
-
hasContent
-
numberOfElements
public int numberOfElements()Description copied from interface:PageReturns the number of elements on thisPage, which must be no larger than the maximumsizeof 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:
numberOfElementsin interfacePage<T>- Returns:
- the number of elements on this
Page.
-
hasNext
public boolean hasNext()Description copied from interface:PageReturnstrueif 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:CursoredPageReturnstruewhen 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:
hasPreviousin interfaceCursoredPage<T>- Specified by:
hasPreviousin interfacePage<T>- Returns:
falseif the current page is empty or if it is known that there is not a previous page.
-
nextPageRequest
Returns the value of thenextPageRequestrecord component.- Specified by:
nextPageRequestin interfaceCursoredPage<T>- Specified by:
nextPageRequestin interfacePage<T>- Returns:
- the value of the
nextPageRequestrecord component
-
previousPageRequest
Returns the value of thepreviousPageRequestrecord component.- Specified by:
previousPageRequestin interfaceCursoredPage<T>- Specified by:
previousPageRequestin interfacePage<T>- Returns:
- the value of the
previousPageRequestrecord component
-
iterator
-
cursor
Description copied from interface:CursoredPageReturns aCursorfor key values at the specified position.- Specified by:
cursorin 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:PageReturnstrueif 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 thetotalElementsrecord component.- Specified by:
totalElementsin interfacePage<T>- Returns:
- the value of the
totalElementsrecord component
-
totalPages
public long totalPages()Description copied from interface:PageReturns the total number of pages of query results, if thePage.pageRequest()specified that the total should be retrieved from the database.- Specified by:
totalPagesin interfacePage<T>- Returns:
- the total number of pages.
-
toString
-
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. -
content
-
cursors
-
pageRequest
Returns the value of thepageRequestrecord component.- Specified by:
pageRequestin interfacePage<T>- Returns:
- the value of the
pageRequestrecord component
-