Package org.springframework.data.domain
Class PageRequest
java.lang.Object
org.springframework.data.domain.AbstractPageRequest
org.springframework.data.domain.PageRequest
- All Implemented Interfaces:
Serializable
,Pageable
Basic Java Bean implementation of
Pageable
.- Author:
- Oliver Gierke, Thomas Darimont, Anastasiia Smirnova, Mark Paluch, Thach Le
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
PageRequest
(int pageNumber, int pageSize, Sort sort) Creates a newPageRequest
with sort parameters applied. -
Method Summary
Modifier and TypeMethodDescriptionboolean
first()
Returns thePageable
requesting the first page.getSort()
Returns the sorting parameters.int
hashCode()
next()
static PageRequest
of
(int pageNumber, int pageSize) Creates a new unsortedPageRequest
.static PageRequest
Creates a newPageRequest
with sort parameters applied.static PageRequest
of
(int pageNumber, int pageSize, Sort.Direction direction, String... properties) Creates a newPageRequest
with sort direction and properties applied.static PageRequest
ofSize
(int pageSize) previous()
toString()
withPage
(int pageNumber) Creates a newPageRequest
withpageNumber
applied.Creates a newPageRequest
withSort
applied.withSort
(Sort.Direction direction, String... properties) 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
-
Constructor Details
-
PageRequest
Creates a newPageRequest
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, useSort.unsorted()
instead.
-
-
Method Details
-
of
Creates a new unsortedPageRequest
.- 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
Creates a newPageRequest
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, useSort.unsorted()
instead.- Since:
- 2.0
-
of
public static PageRequest of(int pageNumber, int pageSize, Sort.Direction direction, String... properties) Creates a newPageRequest
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
- Parameters:
pageSize
- the size of the page to be returned, must be greater than 0.- Returns:
- a new
PageRequest
. - Since:
- 2.5
-
getSort
Description copied from interface:Pageable
Returns the sorting parameters.- Returns:
-
next
Description copied from interface:Pageable
- Specified by:
next
in interfacePageable
- Specified by:
next
in classAbstractPageRequest
- Returns:
-
previous
Description copied from class:AbstractPageRequest
- Specified by:
previous
in classAbstractPageRequest
- Returns:
-
first
Description copied from interface:Pageable
Returns thePageable
requesting the first page.- Specified by:
first
in interfacePageable
- Specified by:
first
in classAbstractPageRequest
- Returns:
-
equals
- Overrides:
equals
in classAbstractPageRequest
-
withPage
Creates a newPageRequest
withpageNumber
applied.- Parameters:
pageNumber
-- Returns:
- a new
PageRequest
. - Since:
- 2.5
-
withSort
- Parameters:
direction
- must not be null.properties
- must not be null.- Returns:
- a new
PageRequest
. - Since:
- 2.5
-
withSort
Creates a newPageRequest
withSort
applied.- Parameters:
sort
- must not be null.- Returns:
- a new
PageRequest
. - Since:
- 2.5
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractPageRequest
-
toString
-