Class DNFConditionalBuilder<T>

java.lang.Object
org.skriptlang.skript.lang.condition.DNFConditionalBuilder<T>
Type Parameters:
T - The context class to use for evaluation.

public class DNFConditionalBuilder<T> extends Object
Builds a Disjunctive Normal Form 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 Details

    • build

      public Conditional<T> 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

      @Contract("_ -> this") public DNFConditionalBuilder<T> andNot(Conditional<T> conditional)
      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

      @Contract("_ -> this") public DNFConditionalBuilder<T> orNot(Conditional<T> conditional)
      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