@API(value=EXPERIMENTAL) public class ComparisonRange extends Object
KeyExpression
representing a contiguous range of values for that field.
A ComparisonRange
is similar to a ScanComparisons
but represents a contiguous range of values for a
single field, rather than for an entire KeyExpression
. A comparison range is effectively a sum type, with
the following options:
EQUALS "foo"
.
> 8
and < 30
. The comparison range may include redundant
comparisons by contract, but it may or may not simplify the range into a more compact form. For example,
the comparison range can include the comparisons > 8
, < 30
, and < 20
, but it
may optionally simplify this to > 8
and < 20
. Note that this behavior is not fully
implemented right now; similarly, this implementation does not currently convert a range such as < 8
and > 30
to an empty range. However, this normalization logic will be added here in the future.
A ComparisonRange
is an immutable object that provides a variety of methods for producing new range from the
current one and some Comparisons.Comparison
objects. For example, see tryToAdd(Comparisons.Comparison)
and from(Comparisons.Comparison)
.
Modifier and Type | Field and Description |
---|---|
static ComparisonRange |
EMPTY |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static Optional<ComparisonRange> |
from(Comparisons.Comparison comparison) |
Comparisons.Comparison |
getEqualityComparison() |
List<Comparisons.Comparison> |
getInequalityComparisons() |
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isEquality() |
boolean |
isInequality() |
String |
toString() |
Optional<ComparisonRange> |
tryToAdd(Comparisons.Comparison comparison) |
public static final ComparisonRange EMPTY
public boolean isEmpty()
public boolean isEquality()
public boolean isInequality()
@Nonnull public Comparisons.Comparison getEqualityComparison()
@Nullable public List<Comparisons.Comparison> getInequalityComparisons()
@Nonnull public Optional<ComparisonRange> tryToAdd(@Nonnull Comparisons.Comparison comparison)
@Nonnull public static Optional<ComparisonRange> from(@Nonnull Comparisons.Comparison comparison)