Interface Slice<T>
-
- Type Parameters:
T- The type of content in this slice.
- All Known Subinterfaces:
Page<T>
- All Known Implementing Classes:
AbstractSlice,PageImpl,SliceImpl
public interface Slice<T>A slice of data.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<T>content()static <S> Slice<S>empty()Creates an emptySlice.static <S> Slice<S>empty(int number, int size, SortingData sortingData, boolean hasNext)Creates an emptySlice, using the given paging and sorting information.static <S> Slice<S>emptyUnsorted(int number, int size, boolean hasNext)Creates an empty unsortedSlice, using the given paging information.PagingRequestfirstRequest()booleanhasContent()Indicates whether there are elements in this slice.booleanhasNext()Indicates whether this is the last slice.booleanhasPrevious()Indicates whether there is a previous slice.booleanisFirst()Indicates whether this is the first slice.booleanisLast()Indicates whether this is the last slice.<U> Slice<U>map(java.util.function.Function<T,U> mapper)Maps the content of this slice according to the givenmapper.java.util.Optional<PagingRequest>nextRequest()intnumber()intnumberOfElements()static <S> Slice<S>of(int number, int size, SortingData sortingData, java.util.List<S> content, boolean hasNext)Creates aSlice.longoffset()static <S> Slice<S>ofUnsorted(int number, int size, java.util.List<S> content, boolean hasNext)Creates an unsortedSlice.java.util.Optional<PagingRequest>previousRequest()PagingRequestrequestedBy()intsize()SortingDatasortingData()
-
-
-
Method Detail
-
number
int number()
- Returns:
- Number of slice.
-
size
int size()
- Returns:
- Slice size.
-
sortingData
SortingData sortingData()
- Returns:
SortingDatathat was used to sort contents of this slice.
-
numberOfElements
int numberOfElements()
- Returns:
- Amount of elements in the slice (can be less than the slice size if it is the last one).
-
offset
long offset()
- Returns:
- The offset to be taken according to the underlying
Slicenumber and size.
-
content
java.util.List<T> content()
- Returns:
- Content in this slice.
-
hasContent
boolean hasContent()
Indicates whether there are elements in this slice.- Returns:
trueif there are elements, orfalseotherwise.
-
map
<U> Slice<U> map(java.util.function.Function<T,U> mapper)
Maps the content of this slice according to the givenmapper.- Type Parameters:
U- Concrete type of the resulting contents.- Parameters:
mapper- AFunctionthat maps the contents of this slice.- Returns:
- A new slice containing the mapped elements.
-
requestedBy
PagingRequest requestedBy()
- Returns:
- A
PagingRequestfrom which this slice can be requested.
-
isFirst
boolean isFirst()
Indicates whether this is the first slice.- Returns:
trueif it is the first slice, orfalseotherwise.
-
firstRequest
PagingRequest firstRequest()
- Returns:
- A
PagingRequestfrom which the first slice can be requested.
-
hasPrevious
boolean hasPrevious()
Indicates whether there is a previous slice.- Returns:
trueif there is a previous slice, orfalseotherwise.
-
previousRequest
java.util.Optional<PagingRequest> previousRequest()
- Returns:
- An
OptionalofPagingRequestfrom which the previous slice can be requested, if there is such, or empty otherwise.
-
hasNext
boolean hasNext()
Indicates whether this is the last slice.- Returns:
trueif it is the last slice, orfalseotherwise.
-
nextRequest
java.util.Optional<PagingRequest> nextRequest()
- Returns:
- An
OptionalofPagingRequestfrom which the next slice can be requested, if there is such, or empty otherwise.
-
isLast
boolean isLast()
Indicates whether this is the last slice.- Returns:
trueif it is the last slice, orfalseotherwise.
-
empty
static <S> Slice<S> empty()
Creates an emptySlice.- Type Parameters:
S- The type of elements in the slice.- Returns:
- An empty
Slice.
-
emptyUnsorted
static <S> Slice<S> emptyUnsorted(int number, int size, boolean hasNext)
Creates an empty unsortedSlice, using the given paging information.- Type Parameters:
S- The type of elements in the slice.- Parameters:
number- The number of the slice.size- The size of the slice.hasNext- A flag indicating whether there is another slice.- Returns:
- An unsorted empty
Slice.
-
empty
static <S> Slice<S> empty(int number, int size, SortingData sortingData, boolean hasNext)
Creates an emptySlice, using the given paging and sorting information.- Type Parameters:
S- The type of elements in the slice.- Parameters:
number- The number of the slice.size- The size of the slice.sortingData- TheSortingDatathat was used to sort contents of this slice.hasNext- A flag indicating whether there is another slice.- Returns:
- An empty
Slice.
-
ofUnsorted
static <S> Slice<S> ofUnsorted(int number, int size, java.util.List<S> content, boolean hasNext)
Creates an unsortedSlice.- Type Parameters:
S- The type of elements in the slice.- Parameters:
number- The number of the slice.size- The size of the slice.content- The elements in the slice.hasNext- A flag indicating whether there is another slice.- Returns:
- An unsorted
Slice.
-
of
static <S> Slice<S> of(int number, int size, SortingData sortingData, java.util.List<S> content, boolean hasNext)
Creates aSlice.- Type Parameters:
S- The type of elements in the slice.- Parameters:
number- The number of the slice.size- The size of the slice.sortingData- TheSortingDatathat was used to sort contents of this slice.content- The elements in the slice.hasNext- A flag indicating whether there is another slice.- Returns:
- A
Slice.
-
-