Package st.orm

Interface Slice<R>

Type Parameters:
R - the type of the results.
All Superinterfaces:
Iterable<R>
All Known Implementing Classes:
Page, Window

public interface Slice<R> extends Iterable<R>
A slice of query results: the shape a Page, a Window and a plain slice share.

A slice holds its content in the order it was read and says whether rows existed after and before it at query time. It iterates over its content, so a loop reads for (user : slice). A page adds a total count and navigates by page number, a window navigates by keyset, and the plain slice that slice(pageable) returns is a page without the count query, navigated through its Pageable.

Since:
1.10
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the results in this slice, in the order they were read.
    boolean
    Returns true if rows existed after this slice at query time.
    boolean
    Returns true if rows existed before this slice at query time.
    default boolean
    Returns true if this slice holds no results.
    default Iterator<R>
     
    static <R> Slice<R>
    of(List<R> content, boolean hasNext, boolean hasPrevious)
    Creates a plain slice with the given content and flags.
    default int
    Returns the number of results in this slice.
    default Stream<R>
    Returns the results as a stream.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • content

      List<R> content()
      Returns the results in this slice, in the order they were read.
      Returns:
      the content; never contains null elements.
    • hasNext

      boolean hasNext()
      Returns true if rows existed after this slice at query time.
      Returns:
      true if a next slice exists.
    • hasPrevious

      boolean hasPrevious()
      Returns true if rows existed before this slice at query time.
      Returns:
      true if a previous slice exists.
    • size

      default int size()
      Returns the number of results in this slice.
      Returns:
      the number of results.
    • isEmpty

      default boolean isEmpty()
      Returns true if this slice holds no results.
      Returns:
      true if the slice is empty.
    • iterator

      default Iterator<R> iterator()
      Specified by:
      iterator in interface Iterable<R>
    • stream

      default Stream<R> stream()
      Returns the results as a stream.
      Returns:
      a stream over the content.
    • of

      static <R> Slice<R> of(List<R> content, boolean hasNext, boolean hasPrevious)
      Creates a plain slice with the given content and flags.
      Type Parameters:
      R - the type of the results.
      Parameters:
      content - the results.
      hasNext - true if rows existed after the slice.
      hasPrevious - true if rows existed before the slice.
      Returns:
      the slice.
      Since:
      1.14