Class RuleSupportRuleRegistryDelegate
java.lang.Object
org.openhab.core.automation.module.script.rulesupport.shared.RuleSupportRuleRegistryDelegate
- All Implemented Interfaces:
RuleRegistry,Registry<Rule,String>
@NonNullByDefault
public class RuleSupportRuleRegistryDelegate
extends Object
implements RuleRegistry
The
RuleSupportRuleRegistryDelegate is wrapping a RuleRegistry to provide a comfortable way to add
rules to the RuleManager without worrying about the need to remove rules again. Nonetheless, using the addPermanent
method it is still possible to add rules permanently.- Author:
- Simon Merschjohann - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionRuleSupportRuleRegistryDelegate(RuleRegistry ruleRegistry, ScriptedRuleProvider ruleProvider) -
Method Summary
Modifier and TypeMethodDescriptionThis method is used to register aRuleinto theRuleRegistry.voidaddPermanent(Rule element) add a rule permanently to the RuleManagervoidaddRegistryChangeListener(RegistryChangeListener<Rule> listener) Adds aRegistryChangeListenerto the registry.@Nullable RuleThis method retrieves a single element from the registry.getAll()Returns a collection of all elements in the registry.Gets a collection ofRules which shares same tag.Gets a collection ofRules which has specified tags.voidregenerateFromTemplate(String ruleUID) This method triggers a new generation of the rule from its template by reverting the rule to its "rule stub" state only containing the template configuration.@Nullable RuleRemoves the given element from the accordingManagedProvider.voidcalled when the script is unloaded or reloadedvoidRemoves aRegistryChangeListenerfrom the registry.stream()Returns a stream of all elements in the registry.@Nullable RuleUpdates the given element at the accordingManagedProvider.
-
Constructor Details
-
Method Details
-
addRegistryChangeListener
Description copied from interface:RegistryAdds aRegistryChangeListenerto the registry.- Specified by:
addRegistryChangeListenerin interfaceRegistry<Rule,String> - Parameters:
listener- registry change listener
-
getAll
Description copied from interface:RegistryReturns a collection of all elements in the registry. -
stream
Description copied from interface:RegistryReturns a stream of all elements in the registry. -
get
Description copied from interface:RegistryThis method retrieves a single element from the registry. -
removeRegistryChangeListener
Description copied from interface:RegistryRemoves aRegistryChangeListenerfrom the registry.- Specified by:
removeRegistryChangeListenerin interfaceRegistry<Rule,String> - Parameters:
listener- registry change listener
-
add
Description copied from interface:RuleRegistryThis method is used to register aRuleinto theRuleRegistry. First theRulebecomeRuleStatus.UNINITIALIZED. Then verification procedure will be done and the Rule becomeRuleStatus.IDLE. If the verification fails, the Rule will stayRuleStatus.UNINITIALIZED.- Specified by:
addin interfaceRegistry<Rule,String> - Specified by:
addin interfaceRuleRegistry- Parameters:
element- aRuleinstance which have to be added into theRuleRegistry.- Returns:
- a copy of the added
Rule
-
addPermanent
add a rule permanently to the RuleManager- Parameters:
element- the rule
-
update
Description copied from interface:RegistryUpdates the given element at the accordingManagedProvider. -
remove
Description copied from interface:RegistryRemoves the given element from the accordingManagedProvider. -
getByTag
Description copied from interface:RuleRegistryGets a collection ofRules which shares same tag.- Specified by:
getByTagin interfaceRuleRegistry- Parameters:
tag- specifies a tag that will filter the rules.- Returns:
- collection of
Rules having specified tag.
-
removeAllAddedByScript
public void removeAllAddedByScript()called when the script is unloaded or reloaded -
getByTags
Description copied from interface:RuleRegistryGets a collection ofRules which has specified tags.- Specified by:
getByTagsin interfaceRuleRegistry- Parameters:
tags- specifies tags that will filter the rules.- Returns:
- collection of
Rules having specified tags.
-
regenerateFromTemplate
Description copied from interface:RuleRegistryThis method triggers a new generation of the rule from its template by reverting the rule to its "rule stub" state only containing the template configuration.- Specified by:
regenerateFromTemplatein interfaceRuleRegistry- Parameters:
ruleUID- the UID of theRule.
-