Package io.micronaut.data.model
Interface Page<T>
-
- Type Parameters:
T- The generic type
- All Superinterfaces:
java.lang.Iterable<T>,Slice<T>
public interface Page<T> extends Slice<T>
Inspired by the Spring Data'sPageand GORM'sPagedResultList, this models a type that supports pagination operations.A Page is a result set associated with a particular
Pageablethat includes a calculation of the total size of number of records.- Since:
- 1.0.0
- Author:
- graemerocher
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T2> Page<T2>empty()Creates an empty page object.default intgetTotalPages()longgetTotalSize()default <T2> Page<T2>map(java.util.function.Function<T,T2> function)Maps the content with the given function.static <T> Page<T>of(java.util.List<T> content, Pageable pageable, long totalSize)Creates a slice from the given content and pageable.-
Methods inherited from interface io.micronaut.data.model.Slice
getContent, getNumberOfElements, getOffset, getPageable, getPageNumber, getSize, getSort, isEmpty, iterator, nextPageable, previousPageable
-
-
-
-
Field Detail
-
EMPTY
static final Page<?> EMPTY
-
-
Method Detail
-
getTotalSize
long getTotalSize()
- Returns:
- The total size of the all records.
-
getTotalPages
default int getTotalPages()
- Returns:
- The total number of pages
-
map
@NonNull default <T2> Page<T2> map(java.util.function.Function<T,T2> function)
Maps the content with the given function.
-
of
@NonNull static <T> Page<T> of(@NonNull java.util.List<T> content, @NonNull Pageable pageable, long totalSize)
Creates a slice from the given content and pageable.- Type Parameters:
T- The generic type- Parameters:
content- The contentpageable- The pageabletotalSize- The total size- Returns:
- The slice
-
empty
@NonNull static <T2> Page<T2> empty()
Creates an empty page object.- Type Parameters:
T2- The generic type- Returns:
- The slice
-
-