Package io.micronaut.data.model
Interface Page<T>
- Type Parameters:
T
- The generic type
- All Known Subinterfaces:
CursoredPage<T>
@DefaultImplementation(io.micronaut.data.model.DefaultPage.class)
public interface Page<T>
extends Slice<T>
Inspired by the Spring Data's
Page
and GORM's PagedResultList
, this models a type that supports
pagination operations.
A Page is a result set associated with a particular Pageable
that includes a calculation of the total
size of page of records.
- Since:
- 1.0.0
- Author:
- graemerocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T2> @NonNull Page<T2>
empty()
Creates an empty page object.default int
Get the total count of pages that can be given by this query.long
Get the total count of all the records that can be given by this query.default boolean
hasNext()
Determine whether there is a next page.boolean
default <T2> @NonNull Page<T2>
Maps the content with the given function.static <T> @NonNull Page<T>
Creates a page from the given content, pageable and totalSize.static <T> @NonNull Page<T>
ofCursors
(@NonNull List<T> content, @NonNull Pageable pageable, @Nullable List<Pageable.Cursor> cursors, @Nullable Long totalSize) Creates a page from the given content, pageable, cursors and totalSize.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.micronaut.data.model.Slice
getContent, getNumberOfElements, getOffset, getPageable, getPageNumber, getSize, getSort, hasPrevious, isEmpty, iterator, nextPageable, previousPageable
-
Field Details
-
EMPTY
-
-
Method Details
-
hasTotalSize
boolean hasTotalSize()- Returns:
- Whether this
Page
contains the total count of the records - Since:
- 4.8.0
-
getTotalSize
long getTotalSize()Get the total count of all the records that can be given by this query. The method may produce aIllegalStateException
if thePageable
request did not ask for total size.- Returns:
- The total size of the all records.
-
getTotalPages
default int getTotalPages()Get the total count of pages that can be given by this query. The method may produce aIllegalStateException
if thePageable
request did not ask for total size.- Returns:
- The total page of pages
-
hasNext
default boolean hasNext()Description copied from interface:Slice
Determine whether there is a next page. -
map
Maps the content with the given function. -
of
@NonNull static <T> @NonNull Page<T> of(@NonNull @NonNull List<T> content, @NonNull @NonNull Pageable pageable, @Nullable @Nullable Long totalSize) Creates a page from the given content, pageable and totalSize.- Type Parameters:
T
- The generic type- Parameters:
content
- The contentpageable
- The pageabletotalSize
- The total size- Returns:
- The slice
-
ofCursors
@Internal @NonNull static <T> @NonNull Page<T> ofCursors(@NonNull @NonNull List<T> content, @NonNull @NonNull Pageable pageable, @Nullable @Nullable List<Pageable.Cursor> cursors, @Nullable @Nullable Long totalSize) Creates a page from the given content, pageable, cursors and totalSize. This method is for JSON deserialization. Please useCursoredPage.of(java.util.List<T>, io.micronaut.data.model.Pageable, java.util.List<io.micronaut.data.model.Pageable.Cursor>, java.lang.Long)
instead.- Type Parameters:
T
- The generic type- Parameters:
content
- The contentpageable
- The pageablecursors
- The cursors for cursored paginationtotalSize
- The total size- Returns:
- The slice
-
empty
Creates an empty page object.- Type Parameters:
T2
- The generic type- Returns:
- The slice
-