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
ConstructorDescriptionRuleSupportRuleRegistryDelegate
(RuleRegistry ruleRegistry, ScriptedRuleProvider ruleProvider) -
Method Summary
Modifier and TypeMethodDescriptionThis method is used to register aRule
into theRuleRegistry
.void
addPermanent
(Rule element) add a rule permanently to the RuleManagervoid
addRegistryChangeListener
(RegistryChangeListener<Rule> listener) Adds aRegistryChangeListener
to the registry.@Nullable Rule
This method retrieves a single element from the registry.getAll()
Returns a collection of all elements in the registry.Gets a collection ofRule
s which shares same tag.Gets a collection ofRule
s which has specified tags.@Nullable Rule
Removes the given element from the accordingManagedProvider
.void
called when the script is unloaded or reloadedvoid
Removes aRegistryChangeListener
from the registry.stream()
Returns a stream of all elements in the registry.@Nullable Rule
Updates the given element at the accordingManagedProvider
.
-
Constructor Details
-
Method Details
-
addRegistryChangeListener
Description copied from interface:Registry
Adds aRegistryChangeListener
to the registry.- Specified by:
addRegistryChangeListener
in interfaceRegistry<Rule,
String> - Parameters:
listener
- registry change listener
-
getAll
Description copied from interface:Registry
Returns a collection of all elements in the registry. -
stream
Description copied from interface:Registry
Returns a stream of all elements in the registry. -
get
Description copied from interface:Registry
This method retrieves a single element from the registry. -
removeRegistryChangeListener
Description copied from interface:Registry
Removes aRegistryChangeListener
from the registry.- Specified by:
removeRegistryChangeListener
in interfaceRegistry<Rule,
String> - Parameters:
listener
- registry change listener
-
add
Description copied from interface:RuleRegistry
This method is used to register aRule
into theRuleRegistry
. First theRule
becomeRuleStatus.UNINITIALIZED
. Then verification procedure will be done and the Rule becomeRuleStatus.IDLE
. If the verification fails, the Rule will stayRuleStatus.UNINITIALIZED
.- Specified by:
add
in interfaceRegistry<Rule,
String> - Specified by:
add
in interfaceRuleRegistry
- Parameters:
element
- aRule
instance 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:Registry
Updates the given element at the accordingManagedProvider
. -
remove
Description copied from interface:Registry
Removes the given element from the accordingManagedProvider
. -
getByTag
Description copied from interface:RuleRegistry
Gets a collection ofRule
s which shares same tag.- Specified by:
getByTag
in interfaceRuleRegistry
- Parameters:
tag
- specifies a tag that will filter the rules.- Returns:
- collection of
Rule
s having specified tag.
-
removeAllAddedByScript
public void removeAllAddedByScript()called when the script is unloaded or reloaded -
getByTags
Description copied from interface:RuleRegistry
Gets a collection ofRule
s which has specified tags.- Specified by:
getByTags
in interfaceRuleRegistry
- Parameters:
tags
- specifies tags that will filter the rules.- Returns:
- collection of
Rule
s having specified tags.
-