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
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
Modifier and TypeInterfaceDescriptionstatic enum
Represents 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.AND
orConditional.Operator.OR
.static <T> Conditional
<T> compound
(Conditional.Operator operator, Conditional<T>... conditionals) Creates a compound conditional from multiple conditionals usingConditional.Operator.AND
orConditional.Operator.OR
.Evaluates this object as `true`, `false`, or `unknown`.default Kleenean
Evaluates this object as `true`, `false`, or `unknown`.default Kleenean
evaluateAnd
(Kleenean other, T context) ComputesKleenean.and(Kleenean)
with the evaluation of thisConditional
and the given Kleenean.default Kleenean
evaluateAnd
(Kleenean other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.and(Kleenean)
with the evaluation of thisConditional
and the given Kleenean.default Kleenean
evaluateAnd
(Conditional<T> other, T context) ComputesKleenean.and(Kleenean)
with the evaluations of thisConditional
and the other.default Kleenean
evaluateAnd
(Conditional<T> other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.and(Kleenean)
with the evaluations of thisConditional
and the other.default Kleenean
evaluateNot
(T context) ComputesKleenean.not()
on the evaluation of thisConditional
.default Kleenean
evaluateNot
(T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.not()
on the evaluation of thisConditional
.default Kleenean
evaluateOr
(Kleenean other, T context) ComputesKleenean.or(Kleenean)
with the evaluation of thisConditional
and the given Kleenean.default Kleenean
evaluateOr
(Kleenean other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.or(Kleenean)
with the evaluation of thisConditional
and the given Kleenean.default Kleenean
evaluateOr
(Conditional<T> other, T context) ComputesKleenean.or(Kleenean)
with the evaluations of thisConditional
and the other.default Kleenean
evaluateOr
(Conditional<T> other, T context, @Nullable Map<Conditional<T>, Kleenean> cache) ComputesKleenean.or(Kleenean)
with the evaluations of thisConditional
and 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 thisConditional
and the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE
.- Parameters:
other
- TheConditional
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) ComputesKleenean.and(Kleenean)
with the evaluations of thisConditional
and 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
- TheConditional
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
ComputesKleenean.and(Kleenean)
with the evaluation of thisConditional
and the given Kleenean. Evaluates this object iff the givenKleenean
isKleenean.TRUE
.- Parameters:
other
- TheKleenean
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) ComputesKleenean.and(Kleenean)
with the evaluation of thisConditional
and the given Kleenean. Evaluates this object iff the givenKleenean
is notKleenean.FALSE
. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other
- TheKleenean
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
ComputesKleenean.or(Kleenean)
with the evaluations of thisConditional
and the other. Evaluates the other first, and shortcuts if it is notKleenean.TRUE
.- Parameters:
other
- TheConditional
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) ComputesKleenean.or(Kleenean)
with the evaluations of thisConditional
and 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
- TheConditional
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
ComputesKleenean.or(Kleenean)
with the evaluation of thisConditional
and the given Kleenean. Evaluates this object iff the givenKleenean
isKleenean.FALSE
orKleenean.UNKNOWN
.- Parameters:
other
- TheKleenean
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) ComputesKleenean.or(Kleenean)
with the evaluation of thisConditional
and the given Kleenean. Evaluates this object iff the givenKleenean
isKleenean.FALSE
orKleenean.UNKNOWN
. Uses a mutable cache of evaluated conditionals to prevent duplicate evaluations.- Parameters:
other
- TheKleenean
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
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.AND
orConditional.Operator.OR
. This does not maintain DNF. UseDNFConditionalBuilder
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 usingConditional.Operator.AND
orConditional.Operator.OR
. This does not maintain DNF. UseDNFConditionalBuilder
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
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.
-