@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 | Class and Description |
---|---|
static class |
ComparisonRange.Type
Comparison ranges can be divided into three types, with distinct planning behaviour:
Empty ranges, to which any comparison can be added.
Equality ranges, to which only the same (equality) comparison can be added.
Inequality ranges, to which any other comparison can be added.
This behavior is defined in
tryToAdd(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() |
ComparisonRange.Type |
getRangeType() |
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 ComparisonRange.Type getRangeType()
@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)