Class DNFConditionalBuilder<T>
java.lang.Object
org.skriptlang.skript.lang.condition.DNFConditionalBuilder<T>
- Type Parameters:
T
- The context class to use for evaluation.
Builds a Disjunctive Normal Form
A builder should no longer be used after calling
CompoundConditional
, meaning it is solely composed of groups of ANDs all ORed together,
ex. (a && !b && c) || b || (!c && d)
.
A builder should no longer be used after calling
build()
.-
Method Summary
Modifier and TypeMethodDescriptionfinal DNFConditionalBuilder
<T> add
(boolean or, Conditional<T>... conditionals) Adds conditionals to the root node via the AND or OR operators.final DNFConditionalBuilder
<T> and
(Conditional<T>... andConditionals) Adds conditionals to the root node via the AND operator:(existing) && newA && newB && ...
.andNot
(Conditional<T> conditional) Adds a negated conditional to the root node via the AND and NOT operators:(existing) && !new
.build()
final DNFConditionalBuilder
<T> or
(Conditional<T>... orConditionals) Adds conditionals to the root node via the OR operator:(existing) || newA || newB || ...
.orNot
(Conditional<T> conditional) Adds a negated conditional to the root node via the OR and NOT operators:(existing) || !new
.
-
Method Details
-
build
- Returns:
- The root conditional, which will be DNF-compliant
- Throws:
IllegalStateException
- if the builder is empty.
-
and
@SafeVarargs @Contract("_ -> this") public final DNFConditionalBuilder<T> and(Conditional<T>... andConditionals) Adds conditionals to the root node via the AND operator:(existing) && newA && newB && ...
. If the root is currently OR, the statement is transformed as follows to maintain DNF:(a || b) && c -> (a && c) || (b && c)
- Parameters:
andConditionals
- conditionals to AND to the existing conditional.- Returns:
- the builder
-
or
@SafeVarargs @Contract("_ -> this") public final DNFConditionalBuilder<T> or(Conditional<T>... orConditionals) Adds conditionals to the root node via the OR operator:(existing) || newA || newB || ...
. If the root is currently AND, a new OR root node is created containing the previous root and the new conditionals.- Parameters:
orConditionals
- conditionals to OR to the existing conditional.- Returns:
- the builder
-
andNot
Adds a negated conditional to the root node via the AND and NOT operators:(existing) && !new
.- Parameters:
conditional
- The conditional to negate and add.- Returns:
- the builder
-
orNot
Adds a negated conditional to the root node via the OR and NOT operators:(existing) || !new
.- Parameters:
conditional
- The conditional to negate and add.- Returns:
- the builder
-
add
@SafeVarargs @Contract("_,_ -> this") public final DNFConditionalBuilder<T> add(boolean or, Conditional<T>... conditionals) Adds conditionals to the root node via the AND or OR operators. A helper for dynamically adding conditionals.- Parameters:
or
- Whether to use OR (true) or AND (false)conditionals
- The conditional to add.- Returns:
- the builder
-