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 thePageablerequesting the first page.longReturns the offset to be taken according to the underlying page and page size.intReturns the page to be returned.intReturns the number of items to be returned.getSort()Returns the sorting parameters.default SortReturns the currentSortor the given one if the current one is unsorted.booleanReturns whether there's a previousPageablewe can access from the current one.default booleanisPaged()Returns whether the currentPageablecontains pagination information.default booleanReturns whether the currentPageabledoes not contain pagination information.next()static PageableofSize(int pageSize) default LimittoLimit()Returns anOptionalso that it can easily be mapped on.default OffsetScrollPositionReturns anOffsetScrollPositionfrom this pageable if the page requestis paged.static Pageableunpaged()Returns aPageableinstance representing no pagination setup.static PageablewithPage(int pageNumber) Creates a newPageablewithpageNumberapplied.
-
Method Details
-
unpaged
Returns aPageableinstance representing no pagination setup. -
unpaged
- Parameters:
sort- must not be null, useSort.unsorted()if needed.- Returns:
- an unpaged
Pageableinstance representing no pagination setup considering the givenSortorder. - 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 currentPageablecontains pagination information.- Returns:
- true if the current
Pageablecontains pagination information.
-
isUnpaged
default boolean isUnpaged()Returns whether the currentPageabledoes not contain pagination information.- Returns:
- true if the current
Pageabledoes not contain pagination information.
-
getPageNumber
int getPageNumber()Returns the page to be returned.- Returns:
- the page to be returned or throws
UnsupportedOperationExceptionif 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
UnsupportedOperationExceptionif 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
UnsupportedOperationExceptionif the object isisUnpaged(). - Throws:
UnsupportedOperationException- if the object isisUnpaged().
-
getSort
Sort getSort()Returns the sorting parameters.- Returns:
- the sorting order.
-
getSortOr
Returns the currentSortor the given one if the current one is unsorted.- Parameters:
sort- must not be null.- Returns:
- the current
Sortor thesortone if the current one is unsorted.
-
next
-
previousOrFirst
-
first
Returns thePageablerequesting the first page.- Returns:
- the
Pageablerequesting the first page.
-
withPage
Creates a newPageablewithpageNumberapplied.- Parameters:
pageNumber- the page numbe, zero-based.- Returns:
- a new
PageRequestor throwsUnsupportedOperationExceptionif the object isisUnpaged()and thepageNumberis not zero. - Throws:
UnsupportedOperationException- if the object isisUnpaged().- Since:
- 2.5
-
hasPrevious
boolean hasPrevious()Returns whether there's a previousPageablewe can access from the current one. Will return false in case the currentPageablealready refers to the first page.- Returns:
- true if there's a previous
Pageablewe can access from the current one.
-
toOptional
Returns anOptionalso that it can easily be mapped on.- Returns:
- an
Optionalso that it can easily be mapped on.
-
toLimit
- Returns:
- a
Limitobject based on the current page size. - Since:
- 3.2
-
toScrollPosition
Returns anOffsetScrollPositionfrom this pageable if the page requestis paged.Given the exclusive nature of scrolling the
ScrollPositionforPage(0, 10)translates aninitialposition, 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
-