Class OffsetScrollPosition

java.lang.Object
org.springframework.data.domain.OffsetScrollPosition
All Implemented Interfaces:
ScrollPosition

public final class OffsetScrollPosition extends Object implements ScrollPosition
A ScrollPosition based on the offsets within query results.

An initial OffsetScrollPosition does not point to a specific element and is different to a position {ScrollPosition.offset(long).

Since:
3.1
Author:
Mark Paluch, Oliver Drotbohm, Christoph Strobl, Yanming Zhou
  • Method Details

    • positionFunction

      public static IntFunction<OffsetScrollPosition> positionFunction(long startOffset)
      Returns a position function starting at startOffset.
      Parameters:
      startOffset - the start offset to be used. Must not be negative.
      Returns:
      the offset-based position function.
    • positionFunction

      public IntFunction<OffsetScrollPosition> positionFunction()
      Returns the position function starting after the current offset.
      Returns:
      the offset-based position function.
      Since:
      3.3
    • getOffset

      public long getOffset()
      The zero or positive offset.

      An initial position does not define an offset and will raise an error.

      Returns:
      the offset.
      Throws:
      IllegalStateException - if isInitial().
    • advanceBy

      public OffsetScrollPosition advanceBy(long delta)
      Returns a new OffsetScrollPosition that has been advanced by the given value. Negative deltas will be constrained so that the new offset is at least zero.
      Parameters:
      delta - the value to advance the current offset by.
      Returns:
      will never be null.
    • isInitial

      public boolean isInitial()
      Description copied from interface: ScrollPosition
      Returns whether the current scroll position is the initial one.
      Specified by:
      isInitial in interface ScrollPosition
      Returns:
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object