Class SliceImpl<T>

java.lang.Object
org.springframework.data.domain.SliceImpl<T>
All Implemented Interfaces:
Serializable, Iterable<T>, Supplier<Stream<T>>, Slice<T>, Streamable<T>

public class SliceImpl<T> extends Object
Default implementation of Slice.
Since:
1.8
Author:
Oliver Gierke, Keegan Witt
See Also:
  • Constructor Details

    • SliceImpl

      public SliceImpl(List<T> content, Pageable pageable, boolean hasNext)
      Creates a new Slice with the given content and Pageable.
      Parameters:
      content - the content of this Slice, must not be null.
      pageable - the paging information, must not be null.
      hasNext - whether there's another slice following the current one.
    • SliceImpl

      public SliceImpl(List<T> content)
      Creates a new SliceImpl with the given content. This will result in the created Slice being identical to the entire List.
      Parameters:
      content - must not be null.
  • Method Details

    • hasNext

      public boolean hasNext()
      Description copied from interface: Slice
      Returns if there is a next Slice.
      Returns:
      if there is a next Slice.
    • map

      public <U> Slice<U> map(Function<? super T,? extends U> converter)
      Description copied from interface: Slice
      Returns a new Slice with the content of the current one mapped by the given Converter.
      Parameters:
      converter - must not be null.
      Returns:
      a new Slice with the content of the current one mapped by the given Converter.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(@Nullable Object obj)
    • hashCode

      public int hashCode()
    • getNumber

      public int getNumber()
      Description copied from interface: Slice
      Returns the number of the current Slice. Is always non-negative.
      Specified by:
      getNumber in interface Slice<T>
      Returns:
      the number of the current Slice.
    • getSize

      public int getSize()
      Description copied from interface: Slice
      Returns the size of the Slice.
      Specified by:
      getSize in interface Slice<T>
      Returns:
      the size of the Slice.
    • getNumberOfElements

      public int getNumberOfElements()
      Description copied from interface: Slice
      Returns the number of elements currently on this Slice.
      Specified by:
      getNumberOfElements in interface Slice<T>
      Returns:
      the number of elements currently on this Slice.
    • hasPrevious

      public boolean hasPrevious()
      Description copied from interface: Slice
      Returns if there is a previous Slice.
      Specified by:
      hasPrevious in interface Slice<T>
      Returns:
      if there is a previous Slice.
    • isFirst

      public boolean isFirst()
      Description copied from interface: Slice
      Returns whether the current Slice is the first one.
      Specified by:
      isFirst in interface Slice<T>
      Returns:
    • isLast

      public boolean isLast()
      Description copied from interface: Slice
      Returns whether the current Slice is the last one.
      Specified by:
      isLast in interface Slice<T>
      Returns:
    • nextPageable

      public Pageable nextPageable()
      Description copied from interface: Slice
      Returns the Pageable to request the next Slice. Can be Pageable.unpaged() in case the current Slice is already the last one. Clients should check Slice.hasNext() before calling this method.
      Specified by:
      nextPageable in interface Slice<T>
      Returns:
      See Also:
    • previousPageable

      public Pageable previousPageable()
      Description copied from interface: Slice
      Returns the Pageable to request the previous Slice. Can be Pageable.unpaged() in case the current Slice is already the first one. Clients should check Slice.hasPrevious() before calling this method.
      Specified by:
      previousPageable in interface Slice<T>
      Returns:
      See Also:
    • hasContent

      public boolean hasContent()
      Description copied from interface: Slice
      Returns whether the Slice has content at all.
      Specified by:
      hasContent in interface Slice<T>
      Returns:
    • getContent

      public List<T> getContent()
      Description copied from interface: Slice
      Returns the page content as List.
      Specified by:
      getContent in interface Slice<T>
      Returns:
    • getPageable

      public Pageable getPageable()
      Description copied from interface: Slice
      Returns the Pageable that's been used to request the current Slice.
      Specified by:
      getPageable in interface Slice<T>
      Returns:
    • getSort

      public Sort getSort()
      Description copied from interface: Slice
      Returns the sorting parameters for the Slice.
      Specified by:
      getSort in interface Slice<T>
      Returns:
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • getConvertedContent

      protected <U> List<U> getConvertedContent(Function<? super T,? extends U> converter)
      Applies the given Function to the content of the Chunk.
      Parameters:
      converter - must not be null.
      Returns: