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 ofPageable, heavily inspired by Spring Data'sPageRequest.- Since:
- 1.2.0
- Author:
- Christian Beikov
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PageRequest(int page, int pageSize)Creates a newPageRequestfor requesting the given page with the given page size.PageRequest(int page, int pageSize, Sort sort)Creates a newPageRequestwith given sorting.PageRequest(int page, int pageSize, Sort.Direction direction, String... paths)Creates a newPageRequestwith a sorting based on the given paths and direction.PageRequest(Sort sort, int offset, int pageSize)Creates a newPageRequestwith given sorting.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Pageablefirst()intgetOffset()Returns the offset represented by the page number multiplied with the page size.intgetPageNumber()Returns the page to be returned.intgetPageSize()Returns the number of elements per page to be returned.SortgetSort()Returns the sorting that should be used for pagination.inthashCode()booleanhasPrevious()Returns whether there is a previous Pageable i.e. if the page number is greater than 0.Pageablenext()Pageableprevious()PageablepreviousOrFirst()StringtoString()
-
-
-
Constructor Detail
-
PageRequest
public PageRequest(int page, int pageSize)Creates a newPageRequestfor requesting the given page with the given page size.- Parameters:
page- The zero based page numberpageSize- The number of elements per page
-
PageRequest
public PageRequest(int page, int pageSize, Sort.Direction direction, String... paths)Creates a newPageRequestwith a sorting based on the given paths and direction.- Parameters:
page- The zero based page numberpageSize- The number of elements per pagedirection- The direction to use for theSortto be specified, may benullpaths- The paths to sort by
-
PageRequest
public PageRequest(int page, int pageSize, Sort sort)Creates a newPageRequestwith given sorting.- Parameters:
page- The zero based page numberpageSize- The number of elements per pagesort- The sorting to use for the page, may benull
-
PageRequest
public PageRequest(Sort sort, int offset, int pageSize)
Creates a newPageRequestwith given sorting.- Parameters:
sort- The sorting to use for the page, may benulloffset- The zero based offset numberpageSize- The number of elements per page- Since:
- 1.3.0
-
-
Method Detail
-
getSort
public Sort getSort()
Description copied from interface:PageableReturns the sorting that should be used for pagination.
-
getPageSize
public int getPageSize()
Description copied from interface:PageableReturns the number of elements per page to be returned.- Specified by:
getPageSizein interfacePageable- Returns:
- The number of elements per page
-
getPageNumber
public int getPageNumber()
Description copied from interface:PageableReturns the page to be returned. Zero based.- Specified by:
getPageNumberin interfacePageable- Returns:
- The page to be returned.
-
getOffset
public int getOffset()
Description copied from interface:PageableReturns the offset represented by the page number multiplied with the page size.
-
hasPrevious
public boolean hasPrevious()
Description copied from interface:PageableReturns whether there is a previous Pageable i.e. if the page number is greater than 0.- Specified by:
hasPreviousin interfacePageable- Returns:
- Whether there is a previous page
-
previousOrFirst
public Pageable previousOrFirst()
Description copied from interface:PageableReturns the Pageable that can be used to request the previousPageor the first if the current one already is the first one.- Specified by:
previousOrFirstin interfacePageable- Returns:
- The Pageable for the previous or first Page
-
-