@FunctionalInterface
public interface Logic
Model.
This interface can be implemented by any type capable of evaluating the
current Model state to a boolean value. This interface also
implements composition functions.
| Modifier and Type | Field and Description |
|---|---|
static Logic |
FALSE
a logic instance that always evaluates to
false |
static Logic |
TRUE
a logic instance that always evaluates to
true |
| Modifier and Type | Method and Description |
|---|---|
static Logic |
all(Logic... logics)
Creates a logic instance that evaluates to
true iff all base
instance evaluate to true. |
default Logic |
and(Logic other)
Combines this logic instance with another one in an
AND
operation. |
static Logic |
and(Logic logic0,
Logic... logics)
Creates a
Logic instance that combines all given logic instances
with an AND operation. |
static Logic |
any(Logic... logics)
Creates a logic instance that evaluates to
true if any base
instance evaluates to true. |
static LogicCluster |
cluster(Logic... elements)
prepares a function evaluating all given elements and returns a summary
representing all states as a number.
|
static Logic |
count(int target,
Logic... logics)
Creates a logic instance that counts how many base instances evaluate to
true. |
default Logic |
edge() |
static Logic |
edge(Logic logic) |
boolean |
evaluate()
Evaluates the logic object to a boolean value.
|
static Logic |
none(Logic... logics)
Creates a logic instance that evaluates to
true iff all base
instances evaluate to false. |
default Logic |
not()
Returns an instance with inverted logic.
|
static Logic |
not(Logic logic)
Creates a logic instance with inverted logic.
|
default Logic |
or(Logic other)
Combines this logic instance with another one in an
OR operation. |
static Logic |
or(Logic logic0,
Logic... logics)
Creates a
Logic instance that combines all given logic instances
with an OR operation. |
static final Logic TRUE
truestatic final Logic FALSE
falsestatic LogicCluster cluster(Logic... elements)
true is indicated as a 1. The first
parameter lies in the unit column, the second in the two's column etc.
null parameters will always yield 0 digits. This allows for
hex-alignment.elements - the Logic instances to evaluate. Limited to 32.boolean evaluate()
default Logic not()
default Logic and(Logic other)
AND
operation.
The resulting logic instance evaluates to true iff both this and
the other instance evaluate to true. If either instance evaluates
to false, the result will be false.
other - the logic instance to combine with this oneAND composition of
both this and the other logic instancejava.lang.NullPointerException - if the other parameter is nulldefault Logic or(Logic other)
OR operation.
The resulting logic instance evaluates to true if either this or
the other instance evaluates to true (or both).
other - the logic instance to combine with this oneOR composition of both
this and the other logic instancejava.lang.NullPointerException - if the other parameter is nulldefault Logic edge()
static Logic or(Logic logic0, Logic... logics)
Logic instance that combines all given logic instances
with an OR operation.
If any logic instance evaluates to true the combined logic
evaluates to true. The instance evaluates to false iff
all base logic instances also evaluate to false.
logic0 - the first logic instancelogics - the remaining logic instancesjava.lang.NullPointerException - if any parameter is null, or the logics array
contains null values.java.lang.IllegalArgumentException - if the logics array is emptystatic Logic and(Logic logic0, Logic... logics)
Logic instance that combines all given logic instances
with an AND operation.
The instance evaluates to true iff all base logic instances also
evaluate to true. If any logic instance evaluates to
false the combined logic evaluates to false.
logic0 - the first logic instancelogics - the remaining logic instancesjava.lang.NullPointerException - if any parameter is null, or the logics array
contains null values.java.lang.IllegalArgumentException - if the logics array is emptystatic Logic count(int target, Logic... logics)
true. The instance evaluates to true iff the number of
base instances that evaluate to true matches the given
target parameter.target - the exact number of logic instances that must evaluate to
true for this instance to evaluate to true.logics - the base logic instancesjava.lang.NullPointerException - if the logics array is null or any of its elements is
nulljava.lang.IllegalArgumentException - if the logics array is emptyjava.lang.IllegalArgumentException - if the target value is negative or larger than the
number of elements in the logics array. Both of these
conditions would result in the instance evaluating to
false and are therefore prohibited.static Logic none(Logic... logics)
true iff all base
instances evaluate to false.logics - the base logicsjava.lang.NullPointerException - if the logics array is null or any of its elements
are nulljava.lang.IllegalArgumentException - if the logics array is emptystatic Logic all(Logic... logics)
true iff all base
instance evaluate to true. This is essentially identical to an
AND operation over all base logics.logics - the base logicsjava.lang.NullPointerException - if the logics array is null or any of its elements
are nulljava.lang.IllegalArgumentException - if the logics array is emptystatic Logic any(Logic... logics)
true if any base
instance evaluates to true. This is essentially identical to an
OR operation over all base logics.logics - the base logicsjava.lang.NullPointerException - if the logics array is null or any of its elements
are nulljava.lang.IllegalArgumentException - if the logics array is emptystatic Logic not(Logic logic)
true if the base instance evaluates to false
(and vice versa).java.lang.NullPointerException - if the logic parameter is nullCopyright © 2018. All Rights Reserved.