Class PageRequest

java.lang.Object
com.blazebit.persistence.deltaspike.data.PageRequest
All Implemented Interfaces:
Pageable, Serializable
Direct Known Subclasses:
KeysetPageRequest

public class PageRequest extends Object implements Pageable, Serializable
Immutable implementation of Pageable, heavily inspired by Spring Data's PageRequest.
Since:
1.2.0
Author:
Christian Beikov
See Also:
  • Constructor Details

    • PageRequest

      public PageRequest(int page, int pageSize)
      Creates a new PageRequest for requesting the given page with the given page size.
      Parameters:
      page - The zero based page number
      pageSize - The number of elements per page
    • PageRequest

      public PageRequest(int page, int pageSize, Sort.Direction direction, String... paths)
      Creates a new PageRequest with a sorting based on the given paths and direction.
      Parameters:
      page - The zero based page number
      pageSize - The number of elements per page
      direction - The direction to use for the Sort to be specified, may be null
      paths - The paths to sort by
    • PageRequest

      public PageRequest(int page, int pageSize, Sort sort)
      Creates a new PageRequest with given sorting.
      Parameters:
      page - The zero based page number
      pageSize - The number of elements per page
      sort - The sorting to use for the page, may be null
    • PageRequest

      public PageRequest(Sort sort, int offset, int pageSize)
      Creates a new PageRequest with given sorting.
      Parameters:
      sort - The sorting to use for the page, may be null
      offset - The zero based offset number
      pageSize - The number of elements per page
      Since:
      1.3.0
  • Method Details

    • getSort

      public Sort getSort()
      Description copied from interface: Pageable
      Returns the sorting that should be used for pagination.
      Specified by:
      getSort in interface Pageable
      Returns:
      The sorting
    • next

      public Pageable next()
      Description copied from interface: Pageable
      Returns the Pageable that can be used to request the next Page.
      Specified by:
      next in interface Pageable
      Returns:
      The Pageable for the next Page
    • first

      public Pageable first()
      Description copied from interface: Pageable
      Returns the Pageable that can be used to request the first Page.
      Specified by:
      first in interface Pageable
      Returns:
      The Pageable for the first Page
    • getPageSize

      public int getPageSize()
      Description copied from interface: Pageable
      Returns the number of elements per page to be returned.
      Specified by:
      getPageSize in interface Pageable
      Returns:
      The number of elements per page
    • getPageNumber

      public int getPageNumber()
      Description copied from interface: Pageable
      Returns the page to be returned. Zero based.
      Specified by:
      getPageNumber in interface Pageable
      Returns:
      The page to be returned.
    • getOffset

      public int getOffset()
      Description copied from interface: Pageable
      Returns the offset represented by the page number multiplied with the page size.
      Specified by:
      getOffset in interface Pageable
      Returns:
      The offset
    • hasPrevious

      public boolean hasPrevious()
      Description copied from interface: Pageable
      Returns whether there is a previous Pageable i.e. if the page number is greater than 0.
      Specified by:
      hasPrevious in interface Pageable
      Returns:
      Whether there is a previous page
    • previous

      public Pageable previous()
      Description copied from interface: Pageable
      Returns the Pageable that can be used to request the previous Page or null if the current one already is the first one.
      Specified by:
      previous in interface Pageable
      Returns:
      The Pageable for the previous Page
    • previousOrFirst

      public Pageable previousOrFirst()
      Description copied from interface: Pageable
      Returns the Pageable that can be used to request the previous Page or the first if the current one already is the first one.
      Specified by:
      previousOrFirst in interface Pageable
      Returns:
      The Pageable for the previous or first Page
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object