Module jakarta.data

Record Class Pagination

java.lang.Object
java.lang.Record
jakarta.data.page.Pagination
All Implemented Interfaces:
PageRequest

record Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal) extends Record implements PageRequest
Built-in implementation of PageRequest.
  • Field Details

    • page

      private final long page
      The field for the page record component.
    • size

      private final int size
      The field for the size record component.
    • mode

      private final PageRequest.Mode mode
      The field for the mode record component.
    • type

      private final PageRequest.Cursor type
      The field for the type record component.
    • requestTotal

      private final boolean requestTotal
      The field for the requestTotal record component.
  • Constructor Details

    • Pagination

      Pagination(long page, int size, PageRequest.Mode mode, PageRequest.Cursor type, boolean requestTotal)
      Creates an instance of a Pagination record class.
      Parameters:
      page - the value for the page record component
      size - the value for the size record component
      mode - the value for the mode record component
      type - the value for the type record component
      requestTotal - the value for the requestTotal record component
  • Method Details

    • withoutTotal

      public PageRequest withoutTotal()
      Description copied from interface: PageRequest
      Returns an otherwise-equivalent page request with PageRequest.requestTotal() set to false, so that totals will not be retrieved from the database. Note that when totals are not retrieved by a repository method with return type Page, the operations Page.totalElements() and Page.totalPages() throw an IllegalStateException when called.
      Specified by:
      withoutTotal in interface PageRequest
      Returns:
      a page request with PageRequest.requestTotal() set to false.
    • withTotal

      public PageRequest withTotal()
      Description copied from interface: PageRequest
      Returns an otherwise-equivalent page request with PageRequest.requestTotal() set to false, so that totals will be retrieved from the database.
      Specified by:
      withTotal in interface PageRequest
      Returns:
      a page request with PageRequest.requestTotal() set to true.
    • afterCursor

      public PageRequest afterCursor(PageRequest.Cursor cursor)
      Description copied from interface: PageRequest

      Requests cursor-based pagination in the forward direction, starting after the specified key.

      Specified by:
      afterCursor in interface PageRequest
      Parameters:
      cursor - cursor with key values, the order and number of which must match the OrderBy annotations, Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.
      Returns:
      a new instance of PageRequest with forward cursor-based pagination. This method never returns null.
    • beforeCursor

      public PageRequest beforeCursor(PageRequest.Cursor cursor)
      Description copied from interface: PageRequest

      Requests cursor-based pagination in the previous page direction relative to the specified key values.

      Specified by:
      beforeCursor in interface PageRequest
      Parameters:
      cursor - cursor with key values, the order and number of which must match the OrderBy annotations, Sort parameters, or OrderBy name pattern of the repository method to which this pagination will be supplied.
      Returns:
      a new instance of PageRequest with cursor-based pagination in the previous page direction. This method never returns null.
    • cursor

      public Optional<PageRequest.Cursor> cursor()
      Description copied from interface: PageRequest
      Returns the key values which are the starting point for cursor-based pagination.
      Specified by:
      cursor in interface PageRequest
      Returns:
      the cursor; Optional.empty() if using offset pagination.
    • toString

      public 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
    • size

      public PageRequest size(int maxPageSize)
      Description copied from interface: PageRequest

      Creates a new page request with the same pagination information, but with the specified maximum page size. When a page is retrieved from the database, the number of elements in the page must be equal to the maximum page size unless there is an insufficient number of elements to retrieve from the database from the start of the page.

      Specified by:
      size in interface PageRequest
      Parameters:
      maxPageSize - the number of query results in a full page.
      Returns:
      a new instance of PageRequest. This method never returns null.
    • 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 interface PageRequest
      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.
    • page

      public long page()
      Returns the value of the page record component.
      Specified by:
      page in interface PageRequest
      Returns:
      the value of the page record component
    • size

      public int size()
      Returns the value of the size record component.
      Specified by:
      size in interface PageRequest
      Returns:
      the value of the size record component
    • mode

      public PageRequest.Mode mode()
      Returns the value of the mode record component.
      Specified by:
      mode in interface PageRequest
      Returns:
      the value of the mode record component
    • type

      public PageRequest.Cursor type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • requestTotal

      public boolean requestTotal()
      Returns the value of the requestTotal record component.
      Specified by:
      requestTotal in interface PageRequest
      Returns:
      the value of the requestTotal record component