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 Detail

      • number

        int number()
        Returns:
        Number of slice.
      • size

        int size()
        Returns:
        Slice size.
      • 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 Slice number 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:
        true if there are elements, or false otherwise.
      • map

        <U> Slice<U> map​(java.util.function.Function<T,​U> mapper)
        Maps the content of this slice according to the given mapper.
        Type Parameters:
        U - Concrete type of the resulting contents.
        Parameters:
        mapper - A Function that maps the contents of this slice.
        Returns:
        A new slice containing the mapped elements.
      • isFirst

        boolean isFirst()
        Indicates whether this is the first slice.
        Returns:
        true if it is the first slice, or false otherwise.
      • hasPrevious

        boolean hasPrevious()
        Indicates whether there is a previous slice.
        Returns:
        true if there is a previous slice, or false otherwise.
      • previousRequest

        java.util.Optional<PagingRequest> previousRequest()
        Returns:
        An Optional of PagingRequest from 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:
        true if it is the last slice, or false otherwise.
      • nextRequest

        java.util.Optional<PagingRequest> nextRequest()
        Returns:
        An Optional of PagingRequest from 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:
        true if it is the last slice, or false otherwise.
      • empty

        static <S> Slice<S> empty()
        Creates an empty Slice.
        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 unsorted Slice, 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 empty Slice, 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 - The SortingData that 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 unsorted Slice.
        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 a Slice.
        Type Parameters:
        S - The type of elements in the slice.
        Parameters:
        number - The number of the slice.
        size - The size of the slice.
        sortingData - The SortingData that 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.