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<T> pageRequest, PageRequest<T> nextPageRequest, PageRequest<T> previousPageRequest) extends Record implements CursoredPage<T>
Record type implementing CursoredPage. This may be used to simplify implementation of a repository interface.
  • Constructor Details

  • 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.
    • pageRequest

      public <E> PageRequest<E> pageRequest(Class<E> entityClass)
      Description copied from interface: Page

      Returns the page request for which this page was obtained.

      This method is useful when the query language is used to return a result of different type to the entity class that was queried, allowing the subsequent PageRequest to be cast back to the type of entity class that was queried.

      Specified by:
      pageRequest in interface Page<T>
      Type Parameters:
      E - entity class of the attributes that are used as sort criteria.
      Parameters:
      entityClass - entity class of the attributes that are used as sort criteria.
      Returns:
      the request for the current page; will never be null.
    • nextPageRequest

      public PageRequest<T> 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
    • nextPageRequest

      public <E> PageRequest<E> nextPageRequest(Class<E> entityClass)
      Description copied from interface: Page

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

      This method is useful when the query language is used to return a result of different type to the entity class that was queried, allowing the subsequent PageRequest to be cast back to the type of entity class that was queried.

      Specified by:
      nextPageRequest in interface Page<T>
      Type Parameters:
      E - entity class of the attributes that are used as sort criteria.
      Parameters:
      entityClass - entity class of the attributes that are used as sort criteria.
      Returns:
      a request for the next page.
    • previousPageRequest

      public PageRequest<T> 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
    • previousPageRequest

      public <E> PageRequest<E> previousPageRequest(Class<E> entityClass)
      Description copied from interface: Page

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

      This method is useful when the query language is used to return a result of different type to the entity class that was queried, allowing the subsequent PageRequest to be cast back to the type of entity class that was queried.

      Specified by:
      previousPageRequest in interface Page<T>
      Type Parameters:
      E - entity class of the attributes that are used as sort criteria.
      Parameters:
      entityClass - entity class of the attributes that are used as sort criteria.
      Returns:
      a request for the previous page.
    • 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<T> pageRequest()
      Returns the value of the pageRequest record component.
      Specified by:
      pageRequest in interface Page<T>
      Returns:
      the value of the pageRequest record component