Package org.springframework.data.domain
Interface Slice<T>
- All Superinterfaces:
Iterable<T>
,Streamable<T>
,Supplier<Stream<T>>
- All Known Subinterfaces:
Page<T>
A slice of data that indicates whether there's a next or previous slice available. Allows to obtain a
Pageable
to request a previous or next Slice
.- Since:
- 1.8
- Author:
- Oliver Gierke
-
Method Summary
Modifier and TypeMethodDescriptionReturns the page content asList
.int
Returns the number of the currentSlice
.int
Returns the number of elements currently on thisSlice
.default Pageable
int
getSize()
Returns the size of theSlice
.getSort()
Returns the sorting parameters for theSlice
.boolean
Returns whether theSlice
has content at all.boolean
hasNext()
Returns if there is a nextSlice
.boolean
Returns if there is a previousSlice
.boolean
isFirst()
Returns whether the currentSlice
is the first one.boolean
isLast()
Returns whether the currentSlice
is the last one.<U> Slice<U>
Returns a newSlice
with the content of the current one mapped by the givenConverter
.default Pageable
Returns thePageable
describing the next slice or the one describing the current slice in case it's the last one.default Pageable
Returns thePageable
describing the previous slice or the one describing the current slice in case it's the first one.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getNumber
int getNumber()Returns the number of the currentSlice
. Is always non-negative.- Returns:
- the number of the current
Slice
.
-
getSize
int getSize()Returns the size of theSlice
.- Returns:
- the size of the
Slice
.
-
getNumberOfElements
int getNumberOfElements()Returns the number of elements currently on thisSlice
.- Returns:
- the number of elements currently on this
Slice
.
-
getContent
Returns the page content asList
.- Returns:
-
hasContent
boolean hasContent()Returns whether theSlice
has content at all.- Returns:
-
getSort
Sort getSort()Returns the sorting parameters for theSlice
.- Returns:
-
isFirst
boolean isFirst()Returns whether the currentSlice
is the first one.- Returns:
-
isLast
boolean isLast()Returns whether the currentSlice
is the last one.- Returns:
-
hasNext
boolean hasNext()Returns if there is a nextSlice
.- Returns:
- if there is a next
Slice
.
-
hasPrevious
boolean hasPrevious()Returns if there is a previousSlice
.- Returns:
- if there is a previous
Slice
.
-
getPageable
- Returns:
- Since:
- 2.0
-
nextPageable
Pageable nextPageable()Returns thePageable
to request the nextSlice
. Can bePageable.unpaged()
in case the currentSlice
is already the last one. Clients should checkhasNext()
before calling this method.- Returns:
- See Also:
-
previousPageable
Pageable previousPageable()Returns thePageable
to request the previousSlice
. Can bePageable.unpaged()
in case the currentSlice
is already the first one. Clients should checkhasPrevious()
before calling this method.- Returns:
- See Also:
-
map
Returns a newSlice
with the content of the current one mapped by the givenConverter
.- Specified by:
map
in interfaceStreamable<T>
- Parameters:
converter
- must not be null.- Returns:
- a new
Slice
with the content of the current one mapped by the givenConverter
. - Since:
- 1.10
- See Also:
-
nextOrLastPageable
Returns thePageable
describing the next slice or the one describing the current slice in case it's the last one.- Returns:
- Since:
- 2.2
-
previousOrFirstPageable
Returns thePageable
describing the previous slice or the one describing the current slice in case it's the first one.- Returns:
- Since:
- 2.2
-