Class CassandraPageRequest

java.lang.Object
org.springframework.data.domain.AbstractPageRequest
org.springframework.data.domain.PageRequest
org.springframework.data.cassandra.core.query.CassandraPageRequest
All Implemented Interfaces:
Serializable, org.springframework.data.domain.Pageable

public class CassandraPageRequest extends org.springframework.data.domain.PageRequest
Cassandra-specific PageRequest implementation providing access to paging state. This class allows creation of the first page request and represents through Cassandra paging is based on the progress of fetched pages and allows forward-only navigation. Accessing a particular page requires fetching of all pages until the desired page is reached.

The fetching progress is represented as paging state. Query results are associated with a paging state that is used on the next query as input parameter to continue page fetching.

Since:
2.0
Author:
Mark Paluch
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    first(int size)
    Creates a new unsorted PageRequest for the first page.
    first(int size, org.springframework.data.domain.Sort sort)
    Creates a new PageRequest with sort parameters applied for the first page.
    first(int size, org.springframework.data.domain.Sort.Direction direction, String... properties)
    Creates a new PageRequest with sort direction and properties applied for the first page.
     
    int
     
    boolean
    Returns whether there's a next Pageable we can access from the current one.
     
    of(int page, int size)
    Creates a new unsorted PageRequest.
    of(int page, int size, org.springframework.data.domain.Sort sort)
    Creates a new PageRequest with sort parameters applied.
    of(int page, int size, org.springframework.data.domain.Sort.Direction direction, String... properties)
    Creates a new PageRequest with sort direction and properties applied.
    of(org.springframework.data.domain.Pageable current, ByteBuffer pagingState)
    Creates a a PageRequest with sort direction and properties applied.
    org.springframework.data.domain.PageRequest
     
     
    static void
    validatePageable(org.springframework.data.domain.Pageable pageable)
    Validate the Pageable whether it can be used for querying.
    withSort(org.springframework.data.domain.Sort sort)
    Create a new CassandraPageRequest associated with Sort sort order.

    Methods inherited from class org.springframework.data.domain.PageRequest

    first, getSort, ofSize, withPage, withSort

    Methods inherited from class org.springframework.data.domain.AbstractPageRequest

    getOffset, getPageNumber, getPageSize, hasPrevious, previousOrFirst

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.data.domain.Pageable

    getSortOr, isPaged, isUnpaged, toOptional, toScrollPosition
  • Method Details

    • of

      public static CassandraPageRequest of(int page, int size)
      Creates a new unsorted PageRequest.
      Parameters:
      page - zero-based page index.
      size - the size of the page to be returned.
      Throws:
      IllegalArgumentException - for page requests other than the first page.
    • of

      public static CassandraPageRequest of(int page, int size, org.springframework.data.domain.Sort sort)
      Creates a new PageRequest with sort parameters applied.
      Parameters:
      page - zero-based page index.
      size - the size of the page to be returned.
      sort - must not be null.
      Throws:
      IllegalArgumentException - for page requests other than the first page.
    • of

      public static CassandraPageRequest of(int page, int size, org.springframework.data.domain.Sort.Direction direction, String... properties)
      Creates a new PageRequest with sort direction and properties applied.
      Parameters:
      page - zero-based page index.
      size - the size of the page to be returned.
      direction - must not be null.
      properties - must not be null.
      Throws:
      IllegalArgumentException - for page requests other than the first page.
    • of

      public static CassandraPageRequest of(org.springframework.data.domain.Pageable current, @Nullable ByteBuffer pagingState)
      Creates a a PageRequest with sort direction and properties applied.
      Parameters:
      current - the current Pageable, must not be null.
      pagingState - the paging state associated with the current Pageable. Can be null if there is no paging state associated.
    • first

      public static CassandraPageRequest first(int size)
      Creates a new unsorted PageRequest for the first page.
      Parameters:
      size - the size of the page to be returned.
    • first

      public static CassandraPageRequest first(int size, org.springframework.data.domain.Sort sort)
      Creates a new PageRequest with sort parameters applied for the first page.
      Parameters:
      size - the size of the page to be returned.
      sort - must not be null.
    • first

      public static CassandraPageRequest first(int size, org.springframework.data.domain.Sort.Direction direction, String... properties)
      Creates a new PageRequest with sort direction and properties applied for the first page.
      Parameters:
      size - the size of the page to be returned.
      direction - must not be null.
      properties - must not be null.
    • validatePageable

      public static void validatePageable(org.springframework.data.domain.Pageable pageable)
      Validate the Pageable whether it can be used for querying. Valid pageables are either:
      Parameters:
      pageable -
      Throws:
      IllegalArgumentException - if the Pageable is not valid.
    • getPagingState

      @Nullable public ByteBuffer getPagingState()
      Returns:
      the paging state for the current CassandraPageRequest or null if the current Pageable represents the last page.
    • hasNext

      public boolean hasNext()
      Returns whether there's a next Pageable we can access from the current one. Will return false in case the current Pageable already refers to the next page.
      Returns:
      true if there's a next Pageable we can access from the current one.
    • next

      public CassandraPageRequest next()
      Specified by:
      next in interface org.springframework.data.domain.Pageable
      Overrides:
      next in class org.springframework.data.domain.PageRequest
    • withSort

      public CassandraPageRequest withSort(org.springframework.data.domain.Sort sort)
      Create a new CassandraPageRequest associated with Sort sort order.
      Overrides:
      withSort in class org.springframework.data.domain.PageRequest
      Parameters:
      sort - must not be null.
      Returns:
      a new CassandraPageRequest associated with the given Sort.
      Since:
      2.1.13
    • previous

      public org.springframework.data.domain.PageRequest previous()
      Overrides:
      previous in class org.springframework.data.domain.PageRequest
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class org.springframework.data.domain.PageRequest
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class org.springframework.data.domain.PageRequest
    • toString

      public String toString()
      Overrides:
      toString in class org.springframework.data.domain.PageRequest