Top Description Fields Constructors Methods
jakarta.data.page.impl

public final Record PageRecord<T>

extends Record
implements Page<T>
Class Inheritance
All Implemented Interfaces
jakarta.data.page.Page, java.lang.Iterable
Record Components
totalElements:long

Doc from jakarta.data.page.Page.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.

pageRequest:PageRequest

Doc from jakarta.data.page.Page.pageRequest. The page request for which this page was obtained

content:List<T>

Doc from jakarta.data.page.Page.content. The page content

moreResults:boolean
whether there is a (nonempty) next page of results
Type Parameters
<T>
The type of elements on the page
Imports
jakarta.data.page.Page, .PageRequest, java.util.Iterator, .List, .NoSuchElementException

Record type implementing Page. This may be used to simplify implementation of a repository interface.

Field Summary

Modifier and TypeField and Description
private final List<T>
content

Record Component accessed by content().

The page content
private final boolean
moreResults

Record Component accessed by moreResults().

whether there is a (nonempty) next page of results
private final PageRequest
pageRequest

Record Component accessed by pageRequest().

The page request for which this page was obtained
private final long
totalElements

Record Component accessed by totalElements().

The total number of elements across all pages that can be requested for the query.

Constructor Summary

AccessConstructor and Description
public
PageRecord(PageRequest
The page request for which this page was obtained.
pageRequest
,
List<T>
The page content.
content
,
long
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.
totalElements
)

Constructs a new instance, computing the moreResults component as true if the page content is a full page of results and the totalElements is either unavailable (indicated by a negative value) or it exceeds the current page number multiplied by the size of a full page.

public
PageRecord(PageRequest pageRequest, List<T> content, long totalElements, boolean moreResults)

Method Summary

Modifier and TypeMethod and Description
public List<T>
content()

Record Component getter of content.

Implements jakarta.data.page.Page.content.

Returns the page content as a List.

Record Component The page content

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public boolean
hasContent()

Implements jakarta.data.page.Page.hasContent.

Returns whether the Page has content at all.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
hasNext()

Implements jakarta.data.page.Page.hasNext.

Returns true 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 that nextPageRequest() will definitely not return null.

public boolean
hasPrevious()

Implements jakarta.data.page.Page.hasPrevious.

Returns true 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 that previousPageRequest() will not return null.

public boolean
hasTotals()

Implements jakarta.data.page.Page.hasTotals.

Returns true if the pageRequest() specified that the total number of elements should be retrieved from the database, and that it is therefore safe to call totalElements() or totalPages().

public Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public boolean
moreResults()

Record Component getter of moreResults.

Record Component whether there is a (nonempty) next page of results

public PageRequest
nextPageRequest()

Implements jakarta.data.page.Page.nextPageRequest.

Returns a request for the next page if hasNext() indicates there might be a next page.

public int
numberOfElements()

Implements jakarta.data.page.Page.numberOfElements.

Returns the number of elements on this Page, which must be no larger than the maximum size of the page request.

public PageRequest
pageRequest()

Record Component getter of pageRequest.

Implements jakarta.data.page.Page.pageRequest.

Returns the page request for which this page was obtained.

Record Component The page request for which this page was obtained

public PageRequest
previousPageRequest()

Implements jakarta.data.page.Page.previousPageRequest.

Returns a request for the previous page, if hasPrevious() indicates there might be a previous page.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public long
totalElements()

Record Component getter of totalElements.

Implements jakarta.data.page.Page.totalElements.

Returns the total number of elements across all pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Record Component The total number of elements across all pages that can be requested for the query.

public long
totalPages()

Implements jakarta.data.page.Page.totalPages.

Returns the total number of pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Field Detail

contentback to summary
private final List<T> content

Record Component accessed by content().

The page content

moreResultsback to summary
private final boolean moreResults

Record Component accessed by moreResults().

whether there is a (nonempty) next page of results

pageRequestback to summary
private final PageRequest pageRequest

Record Component accessed by pageRequest().

The page request for which this page was obtained

totalElementsback to summary
private final long totalElements

Record Component accessed by 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.

Constructor Detail

PageRecordback to summary
public PageRecord(PageRequest pageRequest, List<T> content, long totalElements)

Constructs a new instance, computing the moreResults component as true if the page content is a full page of results and the totalElements is either unavailable (indicated by a negative value) or it exceeds the current page number multiplied by the size of a full page.

Parameters
pageRequest:PageRequest

The page request for which this page was obtained.

content:List<T>

The page content.

totalElements:long

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.

PageRecordback to summary
public PageRecord(PageRequest pageRequest, List<T> content, long totalElements, boolean moreResults)

Method Detail

contentback to summary
public List<T> content()

Record Component getter of content.

Implements jakarta.data.page.Page.content.

Doc from jakarta.data.page.Page.content.

Returns the page content as a List. The list is sorted according to the combined sort criteria of the repository method and the sort criteria of the page request that is supplied to the repository method, sorting first by the sort criteria of the repository method, and then by the sort criteria of the page request.

Record Component
The page content
Returns:List<T>

the page content as a List; will never be null.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hasContentback to summary
public boolean hasContent()

Implements jakarta.data.page.Page.hasContent.

Doc from jakarta.data.page.Page.hasContent.

Returns whether the Page has content at all.

Returns:boolean

whether the Page has content at all.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

hasNextback to summary
public boolean hasNext()

Implements jakarta.data.page.Page.hasNext.

Doc from jakarta.data.page.Page.hasNext.

Returns true 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 that nextPageRequest() will definitely not return null.

Returns:boolean

false if this is the last page of results.

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements jakarta.data.page.Page.hasPrevious.

Doc from jakarta.data.page.Page.hasPrevious.

Returns true 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 that previousPageRequest() will not return null.

Returns:boolean

false if this is the first page of results.

Annotations
@Override
hasTotalsback to summary
public boolean hasTotals()

Implements jakarta.data.page.Page.hasTotals.

Doc from jakarta.data.page.Page.hasTotals.

Returns true if the pageRequest() specified that the total number of elements should be retrieved from the database, and that it is therefore safe to call totalElements() or totalPages().

Returns:boolean

true if totals are available.

Annotations
@Override
iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<T>

an Iterator.

Annotations
@Override
moreResultsback to summary
public boolean moreResults()

Record Component getter of moreResults.

Record Component
whether there is a (nonempty) next page of results
nextPageRequestback to summary
public PageRequest nextPageRequest()

Implements jakarta.data.page.Page.nextPageRequest.

Doc from jakarta.data.page.Page.nextPageRequest.

Returns a request for the next page if hasNext() indicates there might be a next page.

Returns:PageRequest

a request for the next page.

Annotations
@Override
numberOfElementsback to summary
public int numberOfElements()

Implements jakarta.data.page.Page.numberOfElements.

Doc from jakarta.data.page.Page.numberOfElements.

Returns the number of elements on this Page, which must be no larger than the maximum size 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.

Returns:int

the number of elements on this Page.

Annotations
@Override
pageRequestback to summary
public PageRequest pageRequest()

Record Component getter of pageRequest.

Implements jakarta.data.page.Page.pageRequest.

Doc from jakarta.data.page.Page.pageRequest.

Returns the page request for which this page was obtained.

Record Component
The page request for which this page was obtained
Returns:PageRequest

the request for the current page; will never be null.

previousPageRequestback to summary
public PageRequest previousPageRequest()

Implements jakarta.data.page.Page.previousPageRequest.

Doc from jakarta.data.page.Page.previousPageRequest.

Returns a request for the previous page, if hasPrevious() indicates there might be a previous page.

Returns:PageRequest

a request for the previous page.

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.

totalElementsback to summary
public long totalElements()

Record Component getter of totalElements.

Implements jakarta.data.page.Page.totalElements.

Doc from jakarta.data.page.Page.totalElements.

Returns the total number of elements across all pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Record Component
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.
Returns:long

the total number of elements across all pages.

Annotations
@Override
totalPagesback to summary
public long totalPages()

Implements jakarta.data.page.Page.totalPages.

Doc from jakarta.data.page.Page.totalPages.

Returns the total number of pages of query results, if the pageRequest() specified that the total should be retrieved from the database.

Returns:long

the total number of pages.

Annotations
@Override