java.lang.Object
java.lang.Record
st.orm.Page<R>
- Type Parameters:
R- the type of the results.- Record Components:
content- the list of results in this page; never containsnullelements.totalCount- the total number of matching results across all pages.pageable- the pagination request that produced this page.
- All Implemented Interfaces:
Slice<R>
public record Page<R>(@Nonnull List<R> content, long totalCount, @Nonnull Pageable pageable)
extends Record
implements Slice<R>
Represents a page of query results for offset-based pagination.
A page contains a list of results along with metadata about the total number of matching results, the current page number, and the page size. This allows clients to compute total pages and navigate to arbitrary page positions.
Page numbers are zero-based: the first page is page 0.
- Since:
- 1.10
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanhasNext()Returnstrueif there is a next page after this one.booleanReturnstrueif there is a previous page before this one.Returns thePageablefor the next page, preserving sort orders.pageable()Returns the value of thepageablerecord component.intReturns the zero-based index of this page.intpageSize()Returns the maximum number of elements per page.Returns thePageablefor the previous page, or the first page if already on page 0.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalCountrecord component.intReturns the total number of pages.
-
Constructor Details
-
Page
Creates an instance of aPagerecord class.- Parameters:
content- the value for thecontentrecord componenttotalCount- the value for thetotalCountrecord componentpageable- the value for thepageablerecord component
-
Page
Creates a page with the specified content, total count, page number, and page size.- Parameters:
content- the list of results in this page.totalCount- the total number of matching results across all pages.pageNumber- the zero-based index of this page.pageSize- the maximum number of elements per page.
-
-
Method Details
-
pageNumber
public int pageNumber()Returns the zero-based index of this page.- Returns:
- the page number.
-
pageSize
public int pageSize()Returns the maximum number of elements per page.- Returns:
- the page size.
-
totalPages
public int totalPages()Returns the total number of pages.- Returns:
- the total number of pages needed to hold all elements.
-
hasNext
public boolean hasNext()Returnstrueif there is a next page after this one. -
hasPrevious
public boolean hasPrevious()Returnstrueif there is a previous page before this one.- Specified by:
hasPreviousin interfaceSlice<R>- Returns:
trueif a previous page exists,falseotherwise.
-
nextPageable
Returns thePageablefor the next page, preserving sort orders.- Returns:
- the pageable for the next page.
-
previousPageable
Returns thePageablefor the previous page, or the first page if already on page 0. Sort orders are preserved.- Returns:
- the pageable for the previous page.
-
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 thecontentrecord component. -
totalCount
public long totalCount()Returns the value of thetotalCountrecord component.- Returns:
- the value of the
totalCountrecord component
-
pageable
Returns the value of thepageablerecord component.- Returns:
- the value of the
pageablerecord component
-