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, Christoph Strobl
-
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) default Limit
toLimit()
Returns anOptional
so that it can easily be mapped on.default OffsetScrollPosition
Returns anOffsetScrollPosition
from this pageable if the page requestis paged
.static Pageable
unpaged()
Returns aPageable
instance representing no pagination setup.static Pageable
withPage
(int pageNumber) Creates a newPageable
withpageNumber
applied.
-
Method Details
-
unpaged
Returns aPageable
instance representing no pagination setup.- Returns:
-
unpaged
- Parameters:
sort
- must not be null, useSort.unsorted()
if needed.- Returns:
- never null.
- Since:
- 3.2
-
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 or throws
UnsupportedOperationException
if the object isisUnpaged()
. - Throws:
UnsupportedOperationException
- if the object isisUnpaged()
.
-
getPageSize
int getPageSize()Returns the number of items to be returned.- Returns:
- the number of items of that page or throws
UnsupportedOperationException
if the object isisUnpaged()
. - Throws:
UnsupportedOperationException
- if the object isisUnpaged()
.
-
getOffset
long getOffset()Returns the offset to be taken according to the underlying page and page size.- Returns:
- the offset to be taken or throws
UnsupportedOperationException
if the object isisUnpaged()
. - Throws:
UnsupportedOperationException
- if the object isisUnpaged()
.
-
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
or throwsUnsupportedOperationException
if the object isisUnpaged()
and thepageNumber
is not zero. - Throws:
UnsupportedOperationException
- if the object isisUnpaged()
.- 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:
-
toLimit
- Returns:
- Since:
- 3.2
-
toScrollPosition
Returns anOffsetScrollPosition
from this pageable if the page requestis paged
.- Returns:
- Throws:
IllegalStateException
- if the request isisUnpaged()
- Since:
- 3.1
-