public class SingleValuedCriterion extends NegatableCriterion
A SingleValuedCriterion
can encode that an attribute value must be
less than, equal to or greater than or equal to
some value. Double bounded ranges can also be represented.
Examples of multi-valued criteria include attribute=tennis
,
attribute<42
and 4<attribute<17
.
Criterion.Operator
NEGATION
Constructor and Description |
---|
SingleValuedCriterion(String attribute,
String value)
Instantiates a
SingleValuedCriterion that represents an equality
test on the given attribute. |
SingleValuedCriterion(String attribute,
String low,
String high,
boolean negation)
Instantiates a
SingleValuedCriterion on the given
(int/float/text) attribute. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getGreaterThan()
Returns the internal low value.
|
String |
getLessThan()
Returns the internal high value.
|
int |
hashCode() |
boolean |
isEqual()
Tells whether this criterion is an equality test.
|
SingleValuedCriterion |
setEqualTo(String value)
Sets this criterion to test for equality against the given value.
|
SingleValuedCriterion |
setGreaterThan(String lowParam)
Sets the lower bound of this criterion.
|
SingleValuedCriterion |
setLessThan(String highParam)
Sets the upper bound of this criterion.
|
void |
toLocation(StringBuilder builder)
Appends the string representation of this criterion to the given
StringBuilder . |
isNegate, isValidAttributeName, setNegate
getAttributeName, toLocation, toString
public SingleValuedCriterion(String attribute, String value)
SingleValuedCriterion
that represents an equality
test on the given attribute.attribute
- The non-ML name of the attribute on which this criterion
operates.value
- The value to test against.SingleValuedCriterion(String, String, String, boolean)
public SingleValuedCriterion(String attribute, String low, String high, boolean negation)
SingleValuedCriterion
on the given
(int/float/text) attribute.
This criterion will select items which value for the specified attribute is bounded by the given lower and upper bound. These bounds are called the low and high, respectively. The lower bound is inclusive, the upper bound is exclusive. As a special exception, if low equals high then this criterion represents an equality test.
attribute
- The non-ML name of the attribute on which this criterion
operates.low
- The lower bound for this criterion; null
if no lower
bound.high
- The upper bound for this criterion; null
if no upper
bound.negation
- If true
this criterion will be configured to be a
negation.IllegalArgumentException
- If attribute is not a valid attribute name or both
low and high are null
.public void toLocation(StringBuilder builder)
StringBuilder
.
The general contract of this method is that if the StringBuilder
contains a valid location ending in a forward slash string prior
to invocation of this method, then its contents must also form a valid
location string upon completion of this method.
Important: this method will not itself insert a leading slash!
toLocation
in class Criterion
builder
- The StringBuilder
to which the string representation of
this criterion is to be appended.public SingleValuedCriterion setGreaterThan(String lowParam)
lowParam
- The lower bound for this criterion.MultiValuedCriterion
instance; useful for chained
manipulations.IllegalArgumentException
- If low is null
while the internal
high value is null
as well.public String getGreaterThan()
null
if no
lower bound is set.public SingleValuedCriterion setLessThan(String highParam)
highParam
- The upper bound for this criterion.MultiValuedCriterion
instance; useful for chained
manipulations.IllegalArgumentException
- If high is null
while the internal
low value is null
as well.public String getLessThan()
null
if no
upper bound is set.public SingleValuedCriterion setEqualTo(String value)
value
- The value to test against.SingleValuedCriterion
instance; useful for chained
manipulations.IllegalArgumentException
- If value is null
.public boolean isEqual()
true
if the internal low and high
values are equal; false
otherwise.public boolean equals(Object o)
equals
in class NegatableCriterion
public int hashCode()
hashCode
in class NegatableCriterion
Copyright © 2021 RWS Group for and on behalf of its affiliates and subsidiaries. All rights reserved.