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
Modifier and TypeInterfaceDescriptionstatic interface
An interface for defining pagination cursors.static enum
The 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull CursoredPageable
afterCursor
(@NonNull Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageable
for forward pagination given the currentCursor after which to query.static @NonNull CursoredPageable
beforeCursor
(@NonNull Pageable.Cursor cursor, int page, int size, @Nullable Sort sort) Create a newPageable
for backward pagination given the currentCursor after which to query.default Optional<Pageable.Cursor>
cursor()
Get the currentCursor in case cursored pagination is used.static @NonNull Pageable
from
(int page) Creates a newPageable
at the given offset with a default size of 10.static @NonNull Pageable
from
(int page, int size) Creates a newPageable
at the given offset.static @NonNull Pageable
from
(int page, int size, @Nullable Pageable.Mode mode, @Nullable Pageable.Cursor cursor, @Nullable Sort sort, boolean requestTotal) Creates a newPageable
with the given parameters.static @NonNull Pageable
Creates a newPageable
with the given offset.static @NonNull Pageable
Creates a newPageable
at the given offset.default Pageable.Mode
getMode()
The pagination mode that is either offset pagination, currentCursor forward or currentCursor backward pagination.int
default long
Offset in the requested collection.default @NonNull List<Sort.Order>
int
getSize()
Maximum size of the page to be returned.default @NonNull Sort
getSort()
default boolean
isSorted()
default boolean
default @NonNull Pageable
next()
default @NonNull Pageable
order
(@NonNull Sort.Order order) Adds an order object.default @NonNull Pageable
Orders by the specified property name (defaults to ascending).default @NonNull Pageable
order
(@NonNull String propertyName, Sort.Order.Direction direction) Orders by the specified property name and direction.default @NonNull Pageable
previous()
default boolean
Whether the returned page should contain information about total items that can be produced by this query.static @NonNull Pageable
unpaged()
default Pageable
Specify that thePage
response should not have information about total size.default Pageable
Specify that thePage
response 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.
-
next
- Returns:
- The next pageable.
-
previous
- Returns:
- The previous pageable
-
isUnpaged
default boolean isUnpaged()- Returns:
- Whether it is unpaged
-
order
Description copied from interface:Sort
Orders by the specified property name (defaults to ascending). -
isSorted
default boolean isSorted() -
order
Description copied from interface:Sort
Adds an order object. -
order
@NonNull default @NonNull Pageable order(@NonNull @NonNull String propertyName, @NonNull Sort.Order.Direction direction) Description copied from interface:Sort
Orders by the specified property name and direction. -
getOrderBy
- Specified by:
getOrderBy
in interfaceSort
- Returns:
- The order definitions for this sort.
-
withTotal
Specify that thePage
response 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 thePage
response 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 newPageable
at the given offset with a default size of 10.- Parameters:
page
- The page- Returns:
- The pageable
-
from
Creates a newPageable
at the given offset.- Parameters:
page
- The pagesize
- the size- Returns:
- The pageable
-
from
Creates a newPageable
with the given offset.- Parameters:
page
- The pagesize
- the sizesort
- the sort- Returns:
- The pageable
-
from
@Internal @NonNull static @NonNull Pageable from(int page, int size, @Nullable @Nullable Pageable.Mode mode, @Nullable @Nullable Pageable.Cursor cursor, @Nullable @Nullable Sort sort, boolean requestTotal) Creates a newPageable
with 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 newPageable
at the given offset.- Parameters:
sort
- the sort- Returns:
- The pageable
-
unpaged
- Returns:
- A new instance without paging data.
-
afterCursor
@NonNull static @NonNull CursoredPageable afterCursor(@NonNull @NonNull Pageable.Cursor cursor, int page, int size, @Nullable @Nullable Sort sort) Create a newPageable
for 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
@NonNull static @NonNull CursoredPageable beforeCursor(@NonNull @NonNull Pageable.Cursor cursor, int page, int size, @Nullable @Nullable Sort sort) Create a newPageable
for 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
-