public abstract class Assertion extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Assertion.ComparisonResult
The possible results when two assertions are compared.
|
static class |
Assertion.Result
Enumeration indicating the result of a validation of a value.
|
Modifier and Type | Field and Description |
---|---|
protected MultiInterval |
intervals
Represents the intervals of allowed values for this assertion.
|
protected boolean |
isInteger
Indicates wether only integer values are allowed
|
Constructor and Description |
---|
Assertion() |
Modifier and Type | Method and Description |
---|---|
boolean |
allowsIntegersOnly()
Checks if this assertion allows only integer values.
|
boolean |
equals(Object o) |
Iterator<Interval> |
getIntervalIterator()
Returns an iterator over the intervals representing all allowed values in
this assertion.
|
MultiInterval |
getMultiInterval()
Returns the MultiInterval specifying the valid values for this assertion.
|
String |
toString() |
Assertion.Result |
validate(double value)
Checks if the current assertion holds for the given value
|
Assertion.Result |
validate(Value value)
Checks if the current assertion holds for the given value.
|
protected MultiInterval intervals
protected boolean isInteger
public Assertion()
public Iterator<Interval> getIntervalIterator()
public MultiInterval getMultiInterval()
public boolean allowsIntegersOnly()
true
if this assertion will validate only integer values
successfully, and false
otherwise.public Assertion.Result validate(Value value)
value
- An arbritrary object. The value the assertion will be verified
against will be retrieved from the object using its toString()
method.Result.NO_DATA
if value
is null
or
value.toString()
returns an empty string.
Result.NAN
if the string returned by value.toString()
does not represent a number parsable by Double.parseDouble()
.
Result.OK
if assertion holds for the value.
Result.FAILED
if the assertion failed for the value, unless
one of the reasons above.
public Assertion.Result validate(double value)
Result.OK
if the assertion holds for the value,
Result.NAN
if value == Double.NaN
Result.FAILED
otherwise.