Interface FieldSpan

All Superinterfaces:
Comparable<FieldSpan>, End.EndSpan<Field,FieldSpan>, Span<End<Field>,FieldSpan>
All Known Implementing Classes:
FieldSpan.Empty, FieldSpan.Impl

public sealed interface FieldSpan extends End.EndSpan<Field,FieldSpan> permits FieldSpan.Empty, FieldSpan.Impl
A span of database field values

We must allow open endpoints here. Consider a string field. There is no well-defined increment or decrement on strings. Let them be ordered lexicographically. What string immediately precedes "Span"? It is not "Spam", since "Spammer" falls between. In fact, for any string having the prefix "Spam", you can add another character to it to find a string after it, but still preceding "Span". Thus, we use End.EndSpan, so that End("Span" - epsilon) can stand in for the value immediately preceding "Span".

  • Field Details

  • Method Details

    • sub

      static FieldSpan sub(Field from, boolean fromInclusive, Field to, boolean toInclusive, DirectedIterator.Direction direction)
      Get the span for a sub collection

      from must precede to, unless direction is DirectedIterator.Direction.BACKWARD, in which case the opposite is required. The endpoints may be equal but unless both are inclusive, the result is EMPTY. The two endpoints are not automatically inverted to correct ordering. More often than not, accidental mis-ordering indicates an implementation flaw.

      Parameters:
      from - the lower bound
      fromInclusive - true if the bound includes from
      to - the upper bound
      toInclusive - true if the bound includes to
      direction - the direction, true to swap from and to
      Returns:
      the span
    • head

      static FieldSpan head(Field to, boolean toInclusive, DirectedIterator.Direction direction)
      Get the span for the head of a collection

      When direction is DirectedIterator.Direction.BACKWARD this behaves as if a tail collection; however, the implication is that iteration will start from the maximum and proceed toward the given bound.

      Parameters:
      to - the upper bound
      toInclusive - true if the bound includes to
      direction - the direction, true to create a tail instead
      Returns:
      the span
    • tail

      static FieldSpan tail(Field from, boolean fromInclusive, DirectedIterator.Direction direction)
      Get the span for the tail of a collection

      When direction is DirectedIterator.Direction.BACKWARD this behaves as if a head collection; however, the implication is that iteration will start from the bound and proceed toward the minimum.

      Parameters:
      from - the lower bound
      fromInclusive - true if the bound includes to
      direction - the direction, true to create a head instead
      Returns:
      the span