Package io.micronaut.data.model
Interface Pageable
- All Superinterfaces:
Sort
- All Known Subinterfaces:
CursoredPageable
Models pageable data. The
from(int, int) method can be used to construct a new instance to pass to Micronaut Data methods.- Since:
- 1.0.0
- Author:
- boros, graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn interface for defining pagination cursors.static enumThe type of pagination: offset-based or currentCursor-based, which includes a direction.Nested classes/interfaces inherited from interface io.micronaut.data.model.Sort
Sort.Order -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic CursoredPageableafterCursor(Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageablefor forward pagination given the currentCursor after which to query.static CursoredPageablebeforeCursor(Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageablefor backward pagination given the currentCursor after which to query.default Optional<Pageable.Cursor> cursor()Get the currentCursor in case cursored pagination is used.static Pageablefrom(int page) Creates a newPageableat the given offset with a default size of 10.static Pageablefrom(int page, int size) Creates a newPageableat the given offset.static PageableCreates a newPageablewith the given offset.static PageableCreates a newPageablewith the given offset.static Pageablefrom(int page, int size, @Nullable Pageable.Mode mode, @Nullable Pageable.Cursor cursor, @Nullable Sort sort, boolean requestTotal) Creates a newPageablewith the given parameters.static PageableCreates a newPageableat the given offset.default LimitgetLimit()default Pageable.ModegetMode()The pagination mode that is either offset pagination, currentCursor forward or currentCursor backward pagination.intdefault longOffset in the requested collection.default List<Sort.Order> intgetSize()Maximum size of the page to be returned.default SortgetSort()default booleanisSorted()default booleandefault Pageablenext()default Pageableorder(Sort.Order order) Adds an order object.default PageableOrders by the specified property name (defaults to ascending).default Pageableorder(String propertyName, Sort.Order.Direction direction) Orders by the specified property name and direction.default Pageableorders(List<Sort.Order> orders) Adds an orders.default Pageableprevious()default booleanWhether the returned page should contain information about total items that can be produced by this query.static Pageableunpaged()default PageableRemoves paging.default PageableRemoves ordering.default PageableSpecify that thePageresponse should not have information about total size.default PageableCreates a newPageablewith a custom sort.default PageableSpecify that thePageresponse should have information about total size.
-
Field Details
-
UNPAGED
Constant for no pagination.
-
-
Method Details
-
getNumber
int getNumber()- Returns:
- The page page.
-
getSize
int getSize()Maximum size of the page to be returned. A value of -1 indicates no maximum.- Returns:
- size of the requested page of items
-
getMode
The pagination mode that is either offset pagination, currentCursor forward or currentCursor backward pagination.- Returns:
- The pagination mode
- Since:
- 4.8.0
-
cursor
Get the currentCursor in case cursored pagination is used.- Returns:
- The currentCursor
- Since:
- 4.8.0
-
requestTotal
default boolean requestTotal()Whether the returned page should contain information about total items that can be produced by this query. If the value is false,Page.getTotalSize()andPage.getTotalPages()methods will fail. By default, pageable will have this value set to true.- Returns:
- Whether total size information is required.
- Since:
- 4.8.0
-
getOffset
default long getOffset()Offset in the requested collection. Defaults to zero.- Returns:
- offset in the requested collection
-
getSort
- Returns:
- The sort definition to use.
-
getLimit
- Returns:
- The limit
- Since:
- 4.13
-
next
- Returns:
- The next pageable.
-
previous
- Returns:
- The previous pageable
-
isUnpaged
default boolean isUnpaged()- Returns:
- Whether it is unpaged
-
order
Description copied from interface:SortOrders by the specified property name (defaults to ascending). -
isSorted
default boolean isSorted() -
order
Description copied from interface:SortAdds an order object. -
order
Description copied from interface:SortOrders by the specified property name and direction. -
orders
Description copied from interface:SortAdds an orders. -
withoutSort
Removes ordering.- Returns:
- A pageable without ordering
- Since:
- 4.10
-
withoutPaging
Removes paging.- Returns:
- A pageable without paging
- Since:
- 4.10
-
withSort
Creates a newPageablewith a custom sort.- Parameters:
sort- a new sort- Returns:
- A pageable instance with a new sort
- Since:
- 4.10
-
getOrderBy
- Specified by:
getOrderByin interfaceSort- Returns:
- The order definitions for this sort.
-
withTotal
Specify that thePageresponse should have information about total size.- Returns:
- A pageable instance that will request the total size.
- Since:
- 4.8.0
- See Also:
-
withoutTotal
Specify that thePageresponse should not have information about total size.- Returns:
- A pageable instance that won't request the total size.
- Since:
- 4.8.0
- See Also:
-
from
Creates a newPageableat the given offset with a default size of 10.- Parameters:
page- The page- Returns:
- The pageable
-
from
Creates a newPageableat the given offset.- Parameters:
page- The pagesize- the size- Returns:
- The pageable
-
from
Creates a newPageablewith the given offset.- Parameters:
page- The pagesize- the sizesort- the sort- Returns:
- The pageable
-
from
Creates a newPageablewith the given offset.- Parameters:
page- The pagesize- the sizesort- the sortrequestTotal- The request total- Returns:
- The pageable
- Since:
- 4.13
-
from
@Internal static Pageable from(int page, int size, @Nullable Pageable.Mode mode, @Nullable Pageable.Cursor cursor, @Nullable Sort sort, boolean requestTotal) Creates a newPageablewith the given parameters. The method is used for deserialization and most likely should not be used as an API.- Parameters:
page- The pagesize- The sizemode- The pagination modecursor- The current cursorsort- The sortrequestTotal- Whether to query total count- Returns:
- The pageable
-
from
Creates a newPageableat the given offset.- Parameters:
sort- the sort- Returns:
- The pageable
-
unpaged
- Returns:
- A new instance without paging data.
-
afterCursor
static CursoredPageable afterCursor(Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageablefor forward pagination given the currentCursor after which to query.- Parameters:
cursor- The currentCursorpage- The page pagesize- The page sizesort- The sorting- Returns:
- The pageable
- Since:
- 4.8.0
-
beforeCursor
static CursoredPageable beforeCursor(Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageablefor backward pagination given the currentCursor after which to query.- Parameters:
cursor- The currentCursorpage- The page pagesize- The page sizesort- The sorting- Returns:
- The pageable
- Since:
- 4.8.0
-