Class ConditionResult
java.lang.Object
io.github.brantunger.unruly.api.language.ConditionResult
What evaluating a condition returned, and, from a language that can explain it, why: the value, which must be a
Boolean, and a detail. When the value is a Boolean, the engine records the detail on the rule's
evaluation in the run's result, unless the run
stops first; any other value fails the run, and the detail is dropped.
The detail is the language's own, such as the operands a comparison read or a trace of the subexpressions it
evaluated. The engine doesn't read it, only keeps it, so a caller can read it after the run. That's after the
run's session has gone back to the engine, to be used by another run or closed, so the detail must not be the
Session or hold it, nor anything that reads from it later.
A result without a detail for true or false is one of two shared instances, so returning one
allocates nothing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConditionResultThe result of a condition that wasfalse, without a detail.static final ConditionResultThe result of a condition that wastrue, without a detail. -
Method Summary
Modifier and TypeMethodDescription@Nullable Objectdetail()Returns why the condition evaluated to its value, in the language's own terms.booleanCompares the value and the detail, each with its ownequals, so a detail that is an array is compared by identity, asActionResultcompares the values of its properties.inthashCode()static ConditionResultstatic ConditionResultReturns the result of a condition with the detail that explains it.toString()@Nullable Objectvalue()Returns what the condition evaluated to.
-
Field Details
-
TRUE
The result of a condition that wastrue, without a detail. -
FALSE
The result of a condition that wasfalse, without a detail.
-
-
Method Details
-
of
- Parameters:
value- What the condition evaluated to. Anything but aBoolean, includingnull, fails the rule.- Returns:
- The result
-
of
Returns the result of a condition with the detail that explains it. With anulldetail, it'sof(Object). -
value
Returns what the condition evaluated to.- Returns:
- The value, which fails the rule unless it's a
Boolean
-
detail
Returns why the condition evaluated to its value, in the language's own terms.- Returns:
- The detail, or
nullif the language gave none
-
equals
Compares the value and the detail, each with its ownequals, so a detail that is an array is compared by identity, asActionResultcompares the values of its properties. -
hashCode
public int hashCode() -
toString
-