Interface Pageable

All Known Implementing Classes:
AbstractPageRequest, PageRequest, QPageRequest

public interface Pageable
Abstract interface for pagination information.
Author:
Oliver Gierke, Mark Paluch
  • Method Details

    • unpaged

      static Pageable unpaged()
      Returns a Pageable instance representing no pagination setup.
      Returns:
    • ofSize

      static Pageable ofSize(int pageSize)
      Creates a new Pageable for the first page (page number 0) given pageSize .
      Parameters:
      pageSize - the size of the page to be returned, must be greater than 0.
      Returns:
      a new Pageable.
      Since:
      2.5
    • isPaged

      default boolean isPaged()
      Returns whether the current Pageable contains pagination information.
      Returns:
    • isUnpaged

      default boolean isUnpaged()
      Returns whether the current Pageable does not contain pagination information.
      Returns:
    • getPageNumber

      int getPageNumber()
      Returns the page to be returned.
      Returns:
      the page to be returned.
    • getPageSize

      int getPageSize()
      Returns the number of items to be returned.
      Returns:
      the number of items of that page
    • getOffset

      long getOffset()
      Returns the offset to be taken according to the underlying page and page size.
      Returns:
      the offset to be taken
    • getSort

      Sort getSort()
      Returns the sorting parameters.
      Returns:
    • getSortOr

      default Sort getSortOr(Sort sort)
      Returns the current Sort or the given one if the current one is unsorted.
      Parameters:
      sort - must not be null.
      Returns:
    • next

      Pageable next()
      Returns the Pageable requesting the next Page.
      Returns:
    • previousOrFirst

      Pageable previousOrFirst()
      Returns the previous Pageable or the first Pageable if the current one already is the first one.
      Returns:
    • first

      Pageable first()
      Returns the Pageable requesting the first page.
      Returns:
    • withPage

      Pageable withPage(int pageNumber)
      Creates a new Pageable with pageNumber applied.
      Parameters:
      pageNumber -
      Returns:
      a new PageRequest.
      Since:
      2.5
    • hasPrevious

      boolean hasPrevious()
      Returns whether there's a previous Pageable we can access from the current one. Will return false in case the current Pageable already refers to the first page.
      Returns:
    • toOptional

      default Optional<Pageable> toOptional()
      Returns an Optional so that it can easily be mapped on.
      Returns: