Class ProviderItemChannelLinkRegistry
java.lang.Object
org.openhab.core.automation.module.script.providersupport.shared.ProviderItemChannelLinkRegistry
- All Implemented Interfaces:
org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry,Registry<ItemChannelLink,String>
@NonNullByDefault
public class ProviderItemChannelLinkRegistry
extends Object
implements Registry<ItemChannelLink,String>, org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry
The
ProviderItemChannelLinkRegistry is implementing a Registry to provide a comfortable way to
provide ItemChannelLinks from scripts without worrying about the need to remove them again when the script is
unloaded.
Nonetheless, using the addPermanent(ItemChannelLink) method it is still possible to them permanently.
Use a new instance of this class for each ScriptEngine.
ATTENTION: This class does not provide the same methods as ItemChannelLinkRegistry.
- Author:
- Florian Hotze - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionProviderItemChannelLinkRegistry(ItemChannelLinkRegistry itemChannelLinkRegistry, ScriptedItemChannelLinkProvider scriptedProvider) -
Method Summary
Modifier and TypeMethodDescriptionadd(ItemChannelLink element) Adds the given element to the accordingManagedProvider.addPermanent(ItemChannelLink element) Adds anItemChannelLinkpermanently to the registry.voidAdds aRegistryChangeListenerto the registry.@Nullable ItemChannelLinkThis method retrieves a single element from the registry.getAll()Returns a collection of all elements in the registry.intpurge()@Nullable ItemChannelLinkRemoves the given element from the accordingManagedProvider.voidRemoves all elements that are provided by the script theProviderRegistryinstance is bound to.intremoveLinksForItem(String itemName) intremoveLinksForThing(ThingUID thingUID) voidRemoves aRegistryChangeListenerfrom the registry.stream()Returns a stream of all elements in the registry.@Nullable ItemChannelLinkupdate(ItemChannelLink element) Updates the given element at the accordingManagedProvider.
-
Constructor Details
-
Method Details
-
addRegistryChangeListener
Description copied from interface:RegistryAdds aRegistryChangeListenerto the registry.- Specified by:
addRegistryChangeListenerin interfaceRegistry<ItemChannelLink,String> - Parameters:
listener- registry change listener
-
getAll
Description copied from interface:RegistryReturns a collection of all elements in the registry.- Specified by:
getAllin interfaceRegistry<ItemChannelLink,String> - Returns:
- collection of all elements in the registry
-
stream
Description copied from interface:RegistryReturns a stream of all elements in the registry.- Specified by:
streamin interfaceRegistry<ItemChannelLink,String> - Returns:
- stream of all elements in the registry
-
get
Description copied from interface:RegistryThis method retrieves a single element from the registry.- Specified by:
getin interfaceRegistry<ItemChannelLink,String> - Parameters:
key- key of the element- Returns:
- element or null if no element was found
-
removeRegistryChangeListener
Description copied from interface:RegistryRemoves aRegistryChangeListenerfrom the registry.- Specified by:
removeRegistryChangeListenerin interfaceRegistry<ItemChannelLink,String> - Parameters:
listener- registry change listener
-
add
Description copied from interface:RegistryAdds the given element to the accordingManagedProvider.- Specified by:
addin interfaceRegistry<ItemChannelLink,String> - Parameters:
element- element to be added (must not be null)- Returns:
- the added element or newly created object of the same type
-
addPermanent
Adds anItemChannelLinkpermanently to the registry. ThisItemChannelLinkwill be kept in the registry even if the script is unloaded- Parameters:
element- theItemChannelLinkto be added (must not be null)- Returns:
- the added
ItemChannelLink
-
update
Description copied from interface:RegistryUpdates the given element at the accordingManagedProvider.- Specified by:
updatein interfaceRegistry<ItemChannelLink,String> - Parameters:
element- element to be updated (must not be null)- Returns:
- returns the old element or null if no element with the same key exists
-
remove
Description copied from interface:RegistryRemoves the given element from the accordingManagedProvider.- Specified by:
removein interfaceRegistry<ItemChannelLink,String> - Parameters:
key- key of the element (must not be null)- Returns:
- element that was removed, or null if no element with the given key exists
-
removeLinksForThing
-
removeLinksForItem
-
purge
public int purge() -
removeAllAddedByScript
public void removeAllAddedByScript()Description copied from interface:org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistryRemoves all elements that are provided by the script theProviderRegistryinstance is bound to. To be called when the script is unloaded or reloaded.- Specified by:
removeAllAddedByScriptin interfaceorg.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry
-