Record Class CursoredPageRecord<T>

java.lang.Object
java.lang.Record
jakarta.data.page.impl.CursoredPageRecord<T>
Type Parameters:
T - The type of elements on the page
Record Components:
content - The page content, that is, the query results, in order
cursors - A list of PageRequest.Cursor instances for result, in order
totalElements - The total number of elements across all pages that can be requested for the query
pageRequest - The page request for which this page was obtained
nextPageRequest - A page request for the next page of results
previousPageRequest - A page request for the previous page of results
All Implemented Interfaces:
CursoredPage<T>, Page<T>, Iterable<T>

public record CursoredPageRecord<T>(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest) extends Record implements CursoredPage<T>
Record type implementing CursoredPage. This may be used to simplify implementation of a repository interface.
  • Constructor Details

    • CursoredPageRecord

      public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, boolean firstPage, boolean lastPage)
      Parameters:
      content - The page content, that is, the query results, in order
      cursors - A list of PageRequest.Cursor instances for result, in order
      totalElements - The total number of elements across all pages that can be requested for the query
      pageRequest - The page request for which this page was obtained
      firstPage - True, if this is the first page of results
      lastPage - True, if this is the last page of results
    • CursoredPageRecord

      public CursoredPageRecord(List<T> content, List<PageRequest.Cursor> cursors, long totalElements, PageRequest pageRequest, PageRequest nextPageRequest, PageRequest previousPageRequest)
      Creates an instance of a CursoredPageRecord record class.
      Parameters:
      content - the value for the content record component
      cursors - the value for the cursors record component
      totalElements - the value for the totalElements record component
      pageRequest - the value for the pageRequest record component
      nextPageRequest - the value for the nextPageRequest record component
      previousPageRequest - the value for the previousPageRequest record component
  • Method Details

    • hasContent

      public boolean hasContent()
      Description copied from interface: Page
      Returns whether the Page has content at all.
      Specified by:
      hasContent in interface Page<T>
      Returns:
      whether the Page has content at all.
    • numberOfElements

      public int numberOfElements()
      Description copied from interface: Page
      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.
      Specified by:
      numberOfElements in interface Page<T>
      Returns:
      the number of elements on this Page.
    • hasNext

      public boolean hasNext()
      Description copied from interface: Page
      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 Page.nextPageRequest() will definitely not return null.
      Specified by:
      hasNext in interface Page<T>
      Returns:
      false if this is the last page of results.
    • hasPrevious

      public boolean hasPrevious()
      Description copied from interface: CursoredPage
      Returns true when it is possible to navigate to a previous page of results or if it is necessary to request a previous page in order to determine whether there are more previous results.
      Specified by:
      hasPrevious in interface CursoredPage<T>
      Specified by:
      hasPrevious in interface Page<T>
      Returns:
      false if the current page is empty or if it is known that there is not a previous page.
    • nextPageRequest

      public PageRequest nextPageRequest()
      Returns the value of the nextPageRequest record component.
      Specified by:
      nextPageRequest in interface CursoredPage<T>
      Specified by:
      nextPageRequest in interface Page<T>
      Returns:
      the value of the nextPageRequest record component
    • previousPageRequest

      public PageRequest previousPageRequest()
      Returns the value of the previousPageRequest record component.
      Specified by:
      previousPageRequest in interface CursoredPage<T>
      Specified by:
      previousPageRequest in interface Page<T>
      Returns:
      the value of the previousPageRequest record component
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • cursor

      public PageRequest.Cursor cursor(int index)
      Description copied from interface: CursoredPage
      Returns a Cursor for key values at the specified position.
      Specified by:
      cursor in interface CursoredPage<T>
      Parameters:
      index - position (0 is first) of a result on the page.
      Returns:
      cursor for key values at the specified position.
    • hasTotals

      public boolean hasTotals()
      Description copied from interface: Page
      Returns true if the Page.pageRequest() specified that the total number of elements should be retrieved from the database, and that it is therefore safe to call Page.totalElements() or Page.totalPages().
      Specified by:
      hasTotals in interface Page<T>
      Returns:
      true if totals are available.
    • totalElements

      public long totalElements()
      Returns the value of the totalElements record component.
      Specified by:
      totalElements in interface Page<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 the Page.pageRequest() specified that the total should be retrieved from the database.
      Specified by:
      totalPages in interface Page<T>
      Returns:
      the total number of pages.
    • 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

      public List<T> content()
      Returns the value of the content record component.
      Specified by:
      content in interface Page<T>
      Returns:
      the value of the content record component
    • cursors

      public List<PageRequest.Cursor> cursors()
      Returns the value of the cursors record component.
      Returns:
      the value of the cursors record component
    • pageRequest

      public PageRequest pageRequest()
      Returns the value of the pageRequest record component.
      Specified by:
      pageRequest in interface Page<T>
      Returns:
      the value of the pageRequest record component