Class RuleExtensions
java.lang.Object
org.openhab.core.model.script.lib.RuleExtensions
RuleExtensions provides DSL Rule extensions.- Author:
- Ravi Nadahar - Initial contribution
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck whether the specified rule is enabled.Run the specified rule.Run the specified rule while optionally taking conditions into account.Run the specified rule with the specified context, while optionally taking conditions into account.Run the specified rule with the specified context, while optionally taking conditions into account.Run the specified rule with the specified context.static voidsetEnabled(Rule rule, boolean enabled) Set whether the specified rule is enabled.
-
Constructor Details
-
RuleExtensions
public RuleExtensions()
-
-
Method Details
-
run
Run the specified rule.- Parameters:
rule- theRuleto run.- Returns:
- A copy of the rule context, including possible return values.
- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
run
Run the specified rule while optionally taking conditions into account.- Parameters:
rule- theRuleto run.considerConditions-trueto not run the rule if its conditions don't qualify.- Returns:
- A copy of the rule context, including possible return values.
- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
run
Run the specified rule with the specified context.- Parameters:
rule- theRuleto run.context- theMapofStringandObjectpairs that constitutes the context.- Returns:
- A copy of the rule context, including possible return values.
- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
run
public static Map<String,@Nullable Object> run(Rule rule, boolean considerConditions, Object... context) Run the specified rule with the specified context, while optionally taking conditions into account.- Parameters:
rule- theRuleto run.considerConditions-trueto not run the rule if its conditions don't qualify.context- the pairs ofStrings andObjects that constitutes the context. Must be in pairs, the first is the key, the second is the value.- Returns:
- A copy of the rule context, including possible return values.
- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
run
public static Map<String,@Nullable Object> run(Rule rule, boolean considerConditions, @Nullable Map<String, @Nullable Object> context) Run the specified rule with the specified context, while optionally taking conditions into account.- Parameters:
rule- theRuleto run.considerConditions-trueto not run the rule if its conditions don't qualify.context- theMapofStringandObjectpairs that constitutes the context.- Returns:
- A copy of the rule context, including possible return values.
- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
isEnabled
Check whether the specified rule is enabled.- Parameters:
rule- theRuleto check.- Returns:
trueif the rule is enabled,falseotherwise.- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-
setEnabled
Set whether the specified rule is enabled.- Parameters:
rule- theRuleto enable or disable.enabled-trueto enable the rule,falseto disable the rule.- Throws:
IllegalArgumentException- If the specified rule isn't registered.IllegalStateException- If noRuleManagerinstance exists.
-