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.- 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 currentPageablecontains pagination information.- Returns:
-
isUnpaged
default boolean isUnpaged()Returns whether the currentPageabledoes not contain pagination information.- Returns:
-
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:
-
getSortOr
Returns the currentSortor 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 thePageablerequesting the first page.- Returns:
-
withPage
Creates a newPageablewithpageNumberapplied.- Parameters:
pageNumber-- 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:
-
toOptional
Returns anOptionalso that it can easily be mapped on.- Returns:
-
toLimit
- Returns:
- 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, where asPage(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
-