Package org.springframework.data.domain
Interface Pageable
- All Known Implementing Classes:
AbstractPageRequest
,PageRequest
,QPageRequest
public interface Pageable
Abstract interface for pagination information.
- Author:
- Oliver Gierke, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionfirst()
Returns thePageable
requesting the first page.long
Returns the offset to be taken according to the underlying page and page size.int
Returns the page to be returned.int
Returns the number of items to be returned.getSort()
Returns the sorting parameters.default Sort
Returns the currentSort
or the given one if the current one is unsorted.boolean
Returns whether there's a previousPageable
we can access from the current one.default boolean
isPaged()
Returns whether the currentPageable
contains pagination information.default boolean
Returns whether the currentPageable
does not contain pagination information.next()
static Pageable
ofSize
(int pageSize) Returns anOptional
so that it can easily be mapped on.static Pageable
unpaged()
Returns aPageable
instance representing no pagination setup.withPage
(int pageNumber) Creates a newPageable
withpageNumber
applied.
-
Method Details
-
unpaged
Returns aPageable
instance representing no pagination setup.- Returns:
-
ofSize
- Parameters:
pageSize
- the size of the page to be returned, must be greater than 0.- Returns:
- a new
Pageable
. - Since:
- 2.5
-
isPaged
default boolean isPaged()Returns whether the currentPageable
contains pagination information.- Returns:
-
isUnpaged
default boolean isUnpaged()Returns whether the currentPageable
does not contain pagination information.- Returns:
-
getPageNumber
int getPageNumber()Returns the page to be returned.- Returns:
- the page to be returned.
-
getPageSize
int getPageSize()Returns the number of items to be returned.- Returns:
- the number of items of that page
-
getOffset
long getOffset()Returns the offset to be taken according to the underlying page and page size.- Returns:
- the offset to be taken
-
getSort
Sort getSort()Returns the sorting parameters.- Returns:
-
getSortOr
Returns the currentSort
or the given one if the current one is unsorted.- Parameters:
sort
- must not be null.- Returns:
-
next
Pageable next()- Returns:
-
previousOrFirst
Pageable previousOrFirst()- Returns:
-
first
Pageable first()Returns thePageable
requesting the first page.- Returns:
-
withPage
Creates a newPageable
withpageNumber
applied.- Parameters:
pageNumber
-- Returns:
- a new
PageRequest
. - Since:
- 2.5
-
hasPrevious
boolean hasPrevious()Returns whether there's a previousPageable
we can access from the current one. Will return false in case the currentPageable
already refers to the first page.- Returns:
-
toOptional
Returns anOptional
so that it can easily be mapped on.- Returns:
-