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
-
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
-
isPaged
-
isUnpaged
-
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
-
getSortOr
-
next
-
previousOrFirst
-
first
-
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
-
toOptional
-
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
-