Class PageRequest

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

public class PageRequest extends AbstractPageRequest
Basic Java Bean implementation of Pageable.
Author:
Oliver Gierke, Thomas Darimont, Anastasiia Smirnova, Mark Paluch, Thach Le
See Also:
  • Constructor Details

    • PageRequest

      protected PageRequest(int pageNumber, int pageSize, Sort sort)
      Creates a new PageRequest with sort parameters applied.
      Parameters:
      pageNumber - zero-based page number, must not be negative.
      pageSize - the size of the page to be returned, must be greater than 0.
      sort - must not be null, use Sort.unsorted() instead.
  • Method Details

    • of

      public static PageRequest of(int pageNumber, int pageSize)
      Creates a new unsorted PageRequest.
      Parameters:
      pageNumber - zero-based page number, must not be negative.
      pageSize - the size of the page to be returned, must be greater than 0.
      Since:
      2.0
    • of

      public static PageRequest of(int pageNumber, int pageSize, Sort sort)
      Creates a new PageRequest with sort parameters applied.
      Parameters:
      pageNumber - zero-based page number, must not be negative.
      pageSize - the size of the page to be returned, must be greater than 0.
      sort - must not be null, use Sort.unsorted() instead.
      Since:
      2.0
    • of

      public static PageRequest of(int pageNumber, int pageSize, Sort.Direction direction, String... properties)
      Creates a new PageRequest with sort direction and properties applied.
      Parameters:
      pageNumber - zero-based page number, must not be negative.
      pageSize - the size of the page to be returned, must be greater than 0.
      direction - must not be null.
      properties - must not be null.
      Since:
      2.0
    • ofSize

      public static PageRequest ofSize(int pageSize)
      Creates a new PageRequest 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 PageRequest.
      Since:
      2.5
    • getSort

      public Sort getSort()
      Description copied from interface: Pageable
      Returns the sorting parameters.
      Returns:
    • next

      public PageRequest next()
      Description copied from interface: Pageable
      Returns the Pageable requesting the next Page.
      Specified by:
      next in interface Pageable
      Specified by:
      next in class AbstractPageRequest
      Returns:
    • previous

      public PageRequest previous()
      Description copied from class: AbstractPageRequest
      Returns the Pageable requesting the previous Page.
      Specified by:
      previous in class AbstractPageRequest
      Returns:
    • first

      public PageRequest first()
      Description copied from interface: Pageable
      Returns the Pageable requesting the first page.
      Specified by:
      first in interface Pageable
      Specified by:
      first in class AbstractPageRequest
      Returns:
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class AbstractPageRequest
    • withPage

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

      public PageRequest withSort(Sort.Direction direction, String... properties)
      Creates a new PageRequest with Sort.Direction and properties applied.
      Parameters:
      direction - must not be null.
      properties - must not be null.
      Returns:
      a new PageRequest.
      Since:
      2.5
    • withSort

      public PageRequest withSort(Sort sort)
      Creates a new PageRequest with Sort applied.
      Parameters:
      sort - must not be null.
      Returns:
      a new PageRequest.
      Since:
      2.5
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractPageRequest
    • toString

      public String toString()
      Overrides:
      toString in class Object