Interface Conditional<T>

Type Parameters:
T - The context class to use for evaluation.
All Superinterfaces:
Debuggable
All Known Implementing Classes:
CondCanAge, CondCanBreed, CondFishingLure, CondHasLootTable, CondIsAdult, CondIsBaby, CondIsInLove, CondIsInOpenWater, CondIsLootable, CondIsPressingKey, CondIsTagged, Condition, CondTextDisplayHasDropShadow, CondTextDisplaySeeThroughBlocks, ch.njol.skript.conditions.base.PropertyCondition

public interface Conditional<T> extends Debuggable
An object which can evaluate to `true`, `false`, or `unknown`. `unknown` is currently unused, but intended for future handling of unexpected runtime situations, where some aspect of the condition in ill-defined by the user and would result in ambiguous or undefined behavior.
  • Method Details

    • evaluate

      @Contract(pure=true) Kleenean evaluate(T context)
      Evaluates this object as `true`, `false`, or `unknown`. This value may change between subsequent callings.
      Parameters:
      context - The context with which to evaluate this object.
      Returns:
      The evaluation of this object.
    • evaluate

      @Contract(pure=true) default Kleenean evaluate(T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Evaluates this object as `true`, `false`, or `unknown`. This value may change between subsequent callings. May use a mutable cache of evaluated conditionals to prevent duplicate evaluations.
      Parameters:
      context - The context with which to evaluate this object.
      cache - The cache of evaluated conditionals.
      Returns:
      The evaluation of this object.
    • evaluateAnd

      @Contract(pure=true) default Kleenean evaluateAnd(Conditional<T> other, T context)
      Computes Kleenean.and(Kleenean) with the evaluations of this Conditional and the other. Evaluates the other first, and shortcuts if it is not Kleenean.TRUE.
      Parameters:
      other - The Conditional to AND with. Will always be evaluated.
      context - The context with which to evaluate the conditionals.
      Returns:
      The result of Kleenean.and(Kleenean), given the evaluations of the two conditionals.
    • evaluateAnd

      @Contract(pure=true) default Kleenean evaluateAnd(Conditional<T> other, T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Computes Kleenean.and(Kleenean) with the evaluations of this Conditional and the other. Evaluates the other first, and shortcuts if it is not Kleenean.TRUE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.
      Parameters:
      other - The Conditional to AND with. Will always be evaluated.
      context - The context with which to evaluate the conditionals.
      cache - The cache of evaluated conditionals.
      Returns:
      The result of Kleenean.and(Kleenean), given the evaluations of the two conditionals.
    • evaluateAnd

      @Contract(pure=true) default Kleenean evaluateAnd(Kleenean other, T context)
      Computes Kleenean.and(Kleenean) with the evaluation of this Conditional and the given Kleenean. Evaluates this object iff the given Kleenean is Kleenean.TRUE.
      Parameters:
      other - The Kleenean to AND with.
      context - The context with which to evaluate the conditional, if necessary.
      Returns:
      The result of Kleenean.and(Kleenean), given the evaluation of the conditional.
    • evaluateAnd

      @Contract(pure=true) default Kleenean evaluateAnd(Kleenean other, T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Computes Kleenean.and(Kleenean) with the evaluation of this Conditional and the given Kleenean. Evaluates this object iff the given Kleenean is not Kleenean.FALSE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.
      Parameters:
      other - The Kleenean to AND with.
      context - The context with which to evaluate the conditional, if necessary.
      cache - The cache of evaluated conditionals.
      Returns:
      The result of Kleenean.and(Kleenean), given the evaluation of the conditional.
    • evaluateOr

      @Contract(pure=true) default Kleenean evaluateOr(Conditional<T> other, T context)
      Computes Kleenean.or(Kleenean) with the evaluations of this Conditional and the other. Evaluates the other first, and shortcuts if it is not Kleenean.TRUE.
      Parameters:
      other - The Conditional to OR with. Will always be evaluated.
      context - The context with which to evaluate the conditionals.
      Returns:
      The result of Kleenean.or(Kleenean), given the evaluations of the two conditionals.
    • evaluateOr

      @Contract(pure=true) default Kleenean evaluateOr(Conditional<T> other, T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Computes Kleenean.or(Kleenean) with the evaluations of this Conditional and the other. Evaluates the other first, and shortcuts if it is not Kleenean.TRUE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.
      Parameters:
      other - The Conditional to OR with. Will always be evaluated.
      context - The context with which to evaluate the conditionals.
      cache - The cache of evaluated conditionals.
      Returns:
      The result of Kleenean.and(Kleenean), given the evaluations of the two conditionals.
    • evaluateOr

      @Contract(pure=true) default Kleenean evaluateOr(Kleenean other, T context)
      Computes Kleenean.or(Kleenean) with the evaluation of this Conditional and the given Kleenean. Evaluates this object iff the given Kleenean is Kleenean.FALSE or Kleenean.UNKNOWN.
      Parameters:
      other - The Kleenean to OR with.
      context - The context with which to evaluate the conditional, if necessary.
      Returns:
      The result of Kleenean.or(Kleenean), given the evaluation of the conditional.
    • evaluateOr

      @Contract(pure=true) default Kleenean evaluateOr(Kleenean other, T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Computes Kleenean.or(Kleenean) with the evaluation of this Conditional and the given Kleenean. Evaluates this object iff the given Kleenean is Kleenean.FALSE or Kleenean.UNKNOWN. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.
      Parameters:
      other - The Kleenean to OR with.
      context - The context with which to evaluate the conditional, if necessary.
      cache - The cache of evaluated conditionals.
      Returns:
      The result of Kleenean.or(Kleenean), given the evaluation of the conditional.
    • evaluateNot

      @Contract(pure=true) default Kleenean evaluateNot(T context)
      Computes Kleenean.not() on the evaluation of this Conditional.
      Parameters:
      context - The context with which to evaluate the conditional.
      Returns:
      The result of Kleenean.not(), given the evaluation of the conditional.
    • evaluateNot

      @Contract(pure=true) default Kleenean evaluateNot(T context, @Nullable @Nullable Map<Conditional<T>,Kleenean> cache)
      Computes Kleenean.not() on the evaluation of this Conditional.
      Parameters:
      context - The context with which to evaluate the conditional.
      Returns:
      The result of Kleenean.not(), given the evaluation of the conditional.
    • compound

      @Contract("_, _ -> new") static <T> Conditional<T> compound(Conditional.Operator operator, Collection<Conditional<T>> conditionals)
      Creates a compound conditional from multiple conditionals using Conditional.Operator.AND or Conditional.Operator.OR. This does not maintain DNF. Use DNFConditionalBuilder for that purpose.
      Parameters:
      operator - The operator to use (AND or OR).
      conditionals - The conditionals to combine.
      Returns:
      A new conditional that contains this conditional and the given conditionals
    • compound

      @Contract("_, _ -> new") static <T> Conditional<T> compound(Conditional.Operator operator, Conditional<T>... conditionals)
      Creates a compound conditional from multiple conditionals using Conditional.Operator.AND or Conditional.Operator.OR. This does not maintain DNF. Use DNFConditionalBuilder for that purpose.
      Parameters:
      operator - The operator to use (AND or OR).
      conditionals - The conditionals to combine.
      Returns:
      A new conditional that contains this conditional and the given conditionals
    • builderDNF

      @Contract(value="_ -> new", pure=true) @NotNull static <T> @NotNull DNFConditionalBuilder<T> builderDNF(Class<T> ignoredContextClass)
      Provides a builder for conditions in disjunctive normal form. ex: (A && B) || C || (!D &&E)
      Parameters:
      ignoredContextClass - The class of the context to use for the built condition.
      Returns:
      a new builder object for making DNF conditions.
    • builderDNF

      @Contract("_ -> new") @NotNull static <T> @NotNull DNFConditionalBuilder<T> builderDNF(Conditional<T> conditional)
      Parameters:
      conditional - A conditional to begin the builder with.
      Returns:
      a new builder object for making conditions, specifically compound ones.
    • negate

      static <T> Conditional<T> negate(Conditional<T> conditional)
      Negates a given conditional. Follows the following transformation rules:
      !!a -> a
      !(a || b) -> (!a && !b)
      !(a && b) -> (!a || !b)
      Parameters:
      conditional - The conditional to negate.
      Returns:
      The negated conditional.