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.intReturns the number of the currentSlice.intReturns the number of elements currently on thisSlice.default PageableintgetSize()Returns the size of theSlice.getSort()Returns the sorting parameters for theSlice.booleanReturns whether theSlicehas content at all.booleanhasNext()Returns if there is a nextSlice.booleanReturns if there is a previousSlice.booleanisFirst()Returns whether the currentSliceis the first one.booleanisLast()Returns whether the currentSliceis the last one.<U> Slice<U>default PageableReturns thePageabledescribing the next slice or the one describing the current slice in case it's the last one.default PageableReturns thePageabledescribing 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 theSlicehas content at all.- Returns:
-
getSort
Sort getSort()Returns the sorting parameters for theSlice.- Returns:
-
isFirst
boolean isFirst()Returns whether the currentSliceis the first one.- Returns:
-
isLast
boolean isLast()Returns whether the currentSliceis 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 thePageableto request the nextSlice. Can bePageable.unpaged()in case the currentSliceis already the last one. Clients should checkhasNext()before calling this method.- Returns:
- See Also:
-
previousPageable
Pageable previousPageable()Returns thePageableto request the previousSlice. Can bePageable.unpaged()in case the currentSliceis already the first one. Clients should checkhasPrevious()before calling this method.- Returns:
- See Also:
-
map
- Specified by:
mapin interfaceStreamable<T>- Parameters:
converter- must not be null.- Returns:
- a new
Slicewith the content of the current one mapped by the givenConverter. - Since:
- 1.10
- See Also:
-
nextOrLastPageable
Returns thePageabledescribing the next slice or the one describing the current slice in case it's the last one.- Returns:
- Since:
- 2.2
-
previousOrFirstPageable
Returns thePageabledescribing the previous slice or the one describing the current slice in case it's the first one.- Returns:
- Since:
- 2.2
-