Package io.micronaut.data.model
Interface Slice<T>
-
- Type Parameters:
T
- The generic type
- All Superinterfaces:
java.lang.Iterable<T>
- All Known Subinterfaces:
Page<T>
public interface Slice<T> extends java.lang.Iterable<T>
Inspired by the Spring Data'sSlice
and GORM'sPagedResultList
, 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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.List<T>
getContent()
default int
getNumberOfElements()
default long
getOffset()
Pageable
getPageable()
default int
getPageNumber()
default int
getSize()
default Sort
getSort()
default boolean
isEmpty()
default java.util.Iterator<T>
iterator()
default <T2> Slice<T2>
map(java.util.function.Function<T,T2> function)
Maps the content with the given function.default Pageable
nextPageable()
static <T2> Slice<T2>
of(java.util.List<T2> content, Pageable pageable)
Creates a slice from the given content and pageable.default Pageable
previousPageable()
-
-
-
Method Detail
-
getContent
@NonNull java.util.List<T> getContent()
- Returns:
- The content.
-
getPageable
@NonNull Pageable getPageable()
- Returns:
- The pageable for this slice.
-
getPageNumber
default int getPageNumber()
- Returns:
- The page number
-
nextPageable
@NonNull default Pageable nextPageable()
- Returns:
- The next pageable
-
previousPageable
@NonNull default Pageable previousPageable()
- 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
@NonNull default Sort getSort()
- Returns:
- The sort
-
getNumberOfElements
default int getNumberOfElements()
- Returns:
- The number of elements
-
iterator
@NonNull default java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
map
@NonNull default <T2> Slice<T2> map(java.util.function.Function<T,T2> function)
Maps the content with the given function.- Type Parameters:
T2
- The type returned by the function- Parameters:
function
- The function to apply to each element in the content.- Returns:
- A new slice with the mapped content
-
-