Interface Slice<T>
- Type Parameters:
T- The generic type
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
CursoredPage<T>, Page<T>
@DefaultImplementation(io.micronaut.data.model.DefaultSlice.class)
public interface Slice<T>
extends Iterable<T>
Inspired by the Spring Data's
Slice and GORM's PagedResultList, this models a type that supports
pagination operations.
A slice is a result list associated with a particular Pageable
- Since:
- 1.0.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault intdefault longdefault intdefault intgetSize()default SortgetSort()default booleanhasNext()Determine whether there is a next page.default booleanDetermine whether there is a previous page.default booleanisEmpty()iterator()default <T2> Slice<T2> Maps the content with the given function.default PageableCreate a pageable for querying the next page of data.static <T2> Slice<T2> Creates a slice from the given content and pageable.default PageableCreate a pageable for querying the previous page of data.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getContent
-
getPageable
Pageable getPageable()- Returns:
- The pageable for this slice.
-
getPageNumber
default int getPageNumber()- Returns:
- The page number
-
hasNext
default boolean hasNext()Determine whether there is a next page.- Returns:
- Whether there exist a next page.
- Since:
- 4.8.0
-
hasPrevious
default boolean hasPrevious()Determine whether there is a previous page.- Returns:
- Whether there exist a previous page.
- Since:
- 4.8.0
-
nextPageable
Create a pageable for querying the next page of data.A pageable may be created even if the end of data was reached to accommodate for cases when new data might be added to the repository. Use
hasNext()to verify if you have reached the end.- Returns:
- The next pageable
-
previousPageable
Create a pageable for querying the previous page of data.A pageable may be created even if the end of data was reached to accommodate for cases when new data might be added to the repository. Use
hasPrevious()to verify if you have reached the end.- Returns:
- The previous pageable
-
getOffset
default long getOffset()- Returns:
- The offset.
-
getSize
default int getSize()- Returns:
- The size of the slice.
-
isEmpty
default boolean isEmpty()- Returns:
- Whether the slice is empty
-
getSort
- Returns:
- The sort
-
getNumberOfElements
default int getNumberOfElements()- Returns:
- The page of elements
-
iterator
-
map
-
of
-