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
ConstructorsModifierConstructorDescriptionprotectedPageRequest(int pageNumber, int pageSize, Sort sort) Creates a newPageRequestwith sort parameters applied. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfirst()Returns thePageablerequesting the first page.getSort()Returns the sorting parameters.inthashCode()next()static PageRequestof(int pageNumber, int pageSize) Creates a new unsortedPageRequest.static PageRequestCreates a newPageRequestwith sort parameters applied.static PageRequestof(int pageNumber, int pageSize, Sort.Direction direction, String... properties) Creates a newPageRequestwith sort direction and properties applied.static PageRequestofSize(int pageSize) previous()toString()withPage(int pageNumber) Creates a newPageRequestwithpageNumberapplied.Creates a newPageRequestwithSortapplied.withSort(Sort.Direction direction, String... properties) Methods inherited from class org.springframework.data.domain.AbstractPageRequest
getOffset, getPageNumber, getPageSize, hasPrevious, previousOrFirstMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.domain.Pageable
getSortOr, isPaged, isUnpaged, toLimit, toOptional, toScrollPosition
-
Constructor Details
-
PageRequest
Creates a newPageRequestwith 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 newPageRequestwith 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 newPageRequestwith 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:PageableReturns the sorting parameters.- Returns:
- the sorting order.
-
next
Description copied from interface:Pageable -
previous
Description copied from class:AbstractPageRequest- Specified by:
previousin classAbstractPageRequest- Returns:
- the previous
Pageable
-
first
Description copied from interface:PageableReturns thePageablerequesting the first page.- Specified by:
firstin interfacePageable- Specified by:
firstin classAbstractPageRequest- Returns:
- the
Pageablerequesting the first page.
-
withPage
Creates a newPageRequestwithpageNumberapplied.- Parameters:
pageNumber- the page number to apply.- Returns:
- a new
PageRequest. - Since:
- 2.5
-
withSort
@Contract("_, _ -> new") @CheckReturnValue public PageRequest withSort(Sort.Direction direction, String... properties) - Parameters:
direction- must not be null.properties- must not be null.- Returns:
- a new
PageRequest. - Since:
- 2.5
-
withSort
Creates a newPageRequestwithSortapplied.- Parameters:
sort- must not be null.- Returns:
- a new
PageRequest. - Since:
- 2.5
-
equals
- Overrides:
equalsin classAbstractPageRequest
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractPageRequest
-
toString
-