Package st.orm

Record Class Page<R>

Type Parameters:
R - the type of the results.
Record Components:
content - the list of results in this page; never contains null elements.
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
    Constructor
    Description
    Page(List<R> content, long totalCount, int pageNumber, int pageSize)
    Creates a page with the specified content, total count, page number, and page size.
    Page(List<R> content, long totalCount, Pageable pageable)
    Creates an instance of a Page record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the content record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns true if there is a next page after this one.
    boolean
    Returns true if there is a previous page before this one.
    Returns the Pageable for the next page, preserving sort orders.
    Returns the value of the pageable record component.
    int
    Returns the zero-based index of this page.
    int
    Returns the maximum number of elements per page.
    Returns the Pageable for the previous page, or the first page if already on page 0.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the totalCount record component.
    int
    Returns the total number of pages.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Page

      public Page(@Nonnull List<R> content, long totalCount, @Nonnull Pageable pageable)
      Creates an instance of a Page record class.
      Parameters:
      content - the value for the content record component
      totalCount - the value for the totalCount record component
      pageable - the value for the pageable record component
    • Page

      public Page(@Nonnull List<R> content, long totalCount, int pageNumber, int pageSize)
      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()
      Returns true if there is a next page after this one.
      Specified by:
      hasNext in interface Slice<R>
      Returns:
      true if a next page exists, false otherwise.
    • hasPrevious

      public boolean hasPrevious()
      Returns true if there is a previous page before this one.
      Specified by:
      hasPrevious in interface Slice<R>
      Returns:
      true if a previous page exists, false otherwise.
    • nextPageable

      public Pageable nextPageable()
      Returns the Pageable for the next page, preserving sort orders.
      Returns:
      the pageable for the next page.
    • previousPageable

      public Pageable previousPageable()
      Returns the Pageable for the previous page, or the first page if already on page 0. Sort orders are preserved.
      Returns:
      the pageable for the previous page.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • content

      @Nonnull public List<R> content()
      Returns the value of the content record component.
      Specified by:
      content in interface Slice<R>
      Returns:
      the value of the content record component
    • totalCount

      public long totalCount()
      Returns the value of the totalCount record component.
      Returns:
      the value of the totalCount record component
    • pageable

      @Nonnull public Pageable pageable()
      Returns the value of the pageable record component.
      Returns:
      the value of the pageable record component