Interface Conditional<T>
- Type Parameters:
T- The context class to use for evaluation.
- All Superinterfaces:
Debuggable
- All Known Implementing Classes:
CondBrewingConsume,CondCanAge,CondCanBreed,CondEquipCompDamage,CondEquipCompDispensable,CondEquipCompInteract,CondEquipCompShearable,CondEquipCompSwapEquipment,CondFishingLure,CondHasLootTable,CondIsAdult,CondIsBaby,CondIsInLove,CondIsInOpenWater,CondIsLootable,CondIsPressingKey,CondIsTagged,Condition,CondScalesWithDifficulty,CondTextDisplayHasDropShadow,CondTextDisplaySeeThroughBlocks,CondWasIndirect,PropCondContains,PropCondIsEmpty,PropertyBaseCondition,ch.njol.skript.conditions.base.PropertyCondition,SimplifiedCondition
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents a boolean logic operator. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull DNFConditionalBuilder<T> builderDNF(Class<T> ignoredContextClass) Provides a builder for conditions in disjunctive normal form.static <T> @NotNull DNFConditionalBuilder<T> builderDNF(Conditional<T> conditional) static <T> Conditional<T> compound(Conditional.Operator operator, Collection<Conditional<T>> conditionals) Creates a compound conditional from multiple conditionals usingConditional.Operator.ANDorConditional.Operator.OR.static <T> Conditional<T> compound(Conditional.Operator operator, Conditional<T>... conditionals) Creates a compound conditional from multiple conditionals usingConditional.Operator.ANDorConditional.Operator.OR.Evaluates this object as `true`, `false`, or `unknown`.default KleeneanEvaluates this object as `true`, `false`, or `unknown`.default KleeneanevaluateAnd(Kleenean other, T context) ComputesKleenean.and(Kleenean)with the evaluation of thisConditionaland the given Kleenean.default KleeneanevaluateAnd(Kleenean other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.and(Kleenean)with the evaluation of thisConditionaland the given Kleenean.default KleeneanevaluateAnd(Conditional<T> other, T context) ComputesKleenean.and(Kleenean)with the evaluations of thisConditionaland the other.default KleeneanevaluateAnd(Conditional<T> other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.and(Kleenean)with the evaluations of thisConditionaland the other.default KleeneanevaluateNot(T context) ComputesKleenean.not()on the evaluation of thisConditional.default KleeneanevaluateNot(T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.not()on the evaluation of thisConditional.default KleeneanevaluateOr(Kleenean other, T context) ComputesKleenean.or(Kleenean)with the evaluation of thisConditionaland the given Kleenean.default KleeneanevaluateOr(Kleenean other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.or(Kleenean)with the evaluation of thisConditionaland the given Kleenean.default KleeneanevaluateOr(Conditional<T> other, T context) ComputesKleenean.or(Kleenean)with the evaluations of thisConditionaland the other.default KleeneanevaluateOr(Conditional<T> other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.or(Kleenean)with the evaluations of thisConditionaland the other.static <T> Conditional<T> negate(Conditional<T> conditional) Negates a given conditional.Methods inherited from interface ch.njol.skript.lang.Debuggable
toString, toString
-
Method Details
-
evaluate
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
ComputesKleenean.and(Kleenean)with the evaluations of thisConditionaland the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE.- Parameters:
other- TheConditionalto 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) ComputesKleenean.and(Kleenean)with the evaluations of thisConditionaland the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other- TheConditionalto 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
ComputesKleenean.and(Kleenean)with the evaluation of thisConditionaland the given Kleenean. Evaluates this object iff the givenKleeneanisKleenean.TRUE.- Parameters:
other- TheKleeneanto 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) ComputesKleenean.and(Kleenean)with the evaluation of thisConditionaland the given Kleenean. Evaluates this object iff the givenKleeneanis notKleenean.FALSE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other- TheKleeneanto 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
ComputesKleenean.or(Kleenean)with the evaluations of thisConditionaland the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE.- Parameters:
other- TheConditionalto 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) ComputesKleenean.or(Kleenean)with the evaluations of thisConditionaland the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other- TheConditionalto 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
ComputesKleenean.or(Kleenean)with the evaluation of thisConditionaland the given Kleenean. Evaluates this object iff the givenKleeneanisKleenean.FALSEorKleenean.UNKNOWN.- Parameters:
other- TheKleeneanto 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) ComputesKleenean.or(Kleenean)with the evaluation of thisConditionaland the given Kleenean. Evaluates this object iff the givenKleeneanisKleenean.FALSEorKleenean.UNKNOWN. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other- TheKleeneanto 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
ComputesKleenean.not()on the evaluation of thisConditional.- 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) ComputesKleenean.not()on the evaluation of thisConditional.- 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 usingConditional.Operator.ANDorConditional.Operator.OR. This does not maintain DNF. UseDNFConditionalBuilderfor 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 usingConditional.Operator.ANDorConditional.Operator.OR. This does not maintain DNF. UseDNFConditionalBuilderfor 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
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.
-