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
-
unpaged
- Parameters:
sort
- must not be null, useSort.unsorted()
if needed.- Returns:
- an unpaged
Pageable
instance representing no pagination setup considering the givenSort
order. - Since:
- 3.2
-
ofSize
-
isPaged
-
isUnpaged
-
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
-
getSortOr
-
next
-
previousOrFirst
-
first
-
withPage
Creates a newPageable
withpageNumber
applied.- Parameters:
pageNumber
- the page numbe, zero-based.- 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
-
toOptional
-
toLimit
- Returns:
- a
Limit
object based on the current page size. - Since:
- 3.2
-
toScrollPosition
Returns anOffsetScrollPosition
from this pageable if the page requestis paged
.Given the exclusive nature of scrolling the
ScrollPosition
forPage(0, 10)
translates aninitial
position, whereasPage(1, 10)
will point to the last element ofPage(0,10)
resulting inScrollPosition(9)
.- Returns:
- new instance of
OffsetScrollPosition
. - Throws:
IllegalStateException
- if the request isisUnpaged()
- Since:
- 3.1
-