java.lang.Object
java.lang.Record
jakarta.data.page.impl.PageRecord<T>
- Type Parameters:
T
- The type of elements on the page- Record Components:
pageRequest
- Thepage request
for which this page was obtainedcontent
- The page contenttotalElements
- The total number of elements across all pages that can be requested for the query. A negative value indicates that a total count of elements and pages is not available.moreResults
- whether there is a (nonempty) next page of results
public record PageRecord<T>(PageRequest pageRequest, List<T> content, long totalElements, boolean moreResults)
extends Record
implements Page<T>
Record type implementing
Page
.
This may be used to simplify implementation of a repository interface.-
Constructor Summary
ConstructorDescriptionPageRecord
(PageRequest pageRequest, List<T> content, long totalElements) Constructs a new instance, computing themoreResults
component astrue
if the pagecontent
is a full page of results and thetotalElements
is either unavailable (indicated by a negative value) or it exceeds the current page number multiplied by thesize
of a full page.PageRecord
(PageRequest pageRequest, List<T> content, long totalElements, boolean moreResults) Creates an instance of aPageRecord
record class. -
Method Summary
Modifier and TypeMethodDescriptioncontent()
Returns the value of thecontent
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
if it is known that there are previous results or that it is necessary to request the previous page to determine whether there are previous results, so thatPage.previousPageRequest()
will not returnnull
.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()
boolean
Returns the value of themoreResults
record component.Returns a request for the next page ifPage.hasNext()
indicates there might be a next page.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 a request for the previous page, ifPage.hasPrevious()
indicates there might be a previous page.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
-
PageRecord
Constructs a new instance, computing themoreResults
component astrue
if the pagecontent
is a full page of results and thetotalElements
is either unavailable (indicated by a negative value) or it exceeds the current page number multiplied by thesize
of a full page.- Parameters:
pageRequest
- Thepage request
for which this page was obtained.content
- The page content.totalElements
- The total number of elements across all pages that can be requested for the query. A negative value indicates that a total count of elements and pages is not available.
-
PageRecord
public PageRecord(PageRequest pageRequest, List<T> content, long totalElements, boolean moreResults) Creates an instance of aPageRecord
record class.- Parameters:
pageRequest
- the value for thepageRequest
record componentcontent
- the value for thecontent
record componenttotalElements
- the value for thetotalElements
record componentmoreResults
- the value for themoreResults
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
. -
nextPageRequest
Description copied from interface:Page
Returns a request for the next page ifPage.hasNext()
indicates there might be a next page.- Specified by:
nextPageRequest
in interfacePage<T>
- Returns:
- a request for the next page.
-
hasPrevious
public boolean hasPrevious()Description copied from interface:Page
Returnstrue
if it is known that there are previous results or that it is necessary to request the previous page to determine whether there are previous results, so thatPage.previousPageRequest()
will not returnnull
.- Specified by:
hasPrevious
in interfacePage<T>
- Returns:
false
if this is the first page of results.
-
previousPageRequest
Description copied from interface:Page
Returns a request for the previous page, if
Page.hasPrevious()
indicates there might be a previous page.- Specified by:
previousPageRequest
in interfacePage<T>
- Returns:
- a request for the previous page.
-
iterator
-
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 '=='. -
pageRequest
Returns the value of thepageRequest
record component.- Specified by:
pageRequest
in interfacePage<T>
- Returns:
- the value of the
pageRequest
record component
-
content
Returns the value of thecontent
record component. -
moreResults
public boolean moreResults()Returns the value of themoreResults
record component.- Returns:
- the value of the
moreResults
record component
-