Class ProviderItemRegistryDelegate
java.lang.Object
org.openhab.core.automation.module.script.providersupport.shared.ProviderItemRegistryDelegate
- All Implemented Interfaces:
org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry,Registry<Item,,String> ItemRegistry
@NonNullByDefault
public class ProviderItemRegistryDelegate
extends Object
implements ItemRegistry, org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry
The
ProviderItemRegistryDelegate is wrapping a ItemRegistry to provide a comfortable way to provide
items from scripts without worrying about the need to remove items again when the script is unloaded.
Nonetheless, using the addPermanent(Item) method it is still possible to add items permanently.
Use a new instance of this class for each ScriptEngine.
- Author:
- Florian Hotze - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionProviderItemRegistryDelegate(ItemRegistry itemRegistry, ScriptedItemProvider scriptedProvider) -
Method Summary
Modifier and TypeMethodDescriptionAdds the given element to the accordingManagedProvider.addPermanent(Item element) Add an item permanently to the registry.voidaddRegistryChangeListener(RegistryChangeListener<Item> listener) Adds aRegistryChangeListenerto the registry.@Nullable ItemThis method retrieves a single element from the registry.getAll()Returns a collection of all elements in the registry.This method retrieves a single item from the registry.getItemByPattern(String name) This method retrieves a single item from the registry.getItems()This method retrieves all items that are currently available in the registryThis method retrieves all items that match a given search pattern<T extends Item>
Collection<T> getItemsByTag(Class<T> typeFilter, String... tags) Returns list of items which contains all of the given tags.getItemsByTag(String... tags) Returns list of items which contains all of the given tags.getItemsByTagAndType(String type, String... tags) Returns list of items with a certain type containing all of the given tags.getItemsOfType(String type) This method retrieves all items with the given type@Nullable ItemRemoves the given element from the accordingManagedProvider.@Nullable ItemvoidRemoves all elements that are provided by the script theProviderRegistryinstance is bound to.voidRemoves aRegistryChangeListenerfrom the registry.stream()Returns a stream of all elements in the registry.@Nullable ItemUpdates the given element at the accordingManagedProvider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openhab.core.items.ItemRegistry
notifyListenersAboutItemExternalUpdate
-
Constructor Details
-
Method Details
-
addRegistryChangeListener
Description copied from interface:RegistryAdds aRegistryChangeListenerto the registry.- Specified by:
addRegistryChangeListenerin interfaceRegistry<Item,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<Item,String> - Parameters:
listener- registry change listener
-
add
Description copied from interface:RegistryAdds the given element to the accordingManagedProvider. -
addPermanent
Add an item permanently to the registry. This item will be kept in the registry even if the script is unloaded.- Parameters:
element- the item to be added (must not be null)- Returns:
- the added item
-
update
Description copied from interface:RegistryUpdates the given element at the accordingManagedProvider. -
remove
Description copied from interface:RegistryRemoves the given element from the accordingManagedProvider. -
getItem
Description copied from interface:ItemRegistryThis method retrieves a single item from the registry.- Specified by:
getItemin interfaceItemRegistry- Parameters:
name- the item name- Returns:
- the uniquely identified item
- Throws:
ItemNotFoundException- if no item matches the input
-
getItemByPattern
Description copied from interface:ItemRegistryThis method retrieves a single item from the registry. Search patterns and shortened versions are supported, if they uniquely identify an item- Specified by:
getItemByPatternin interfaceItemRegistry- Parameters:
name- the item name, a part of the item name or a search pattern- Returns:
- the uniquely identified item
- Throws:
ItemNotFoundException- if no item matches the inputItemNotUniqueException- if multiply items match the input
-
getItems
Description copied from interface:ItemRegistryThis method retrieves all items that are currently available in the registry- Specified by:
getItemsin interfaceItemRegistry- Returns:
- a collection of all available items
-
getItemsOfType
Description copied from interface:ItemRegistryThis method retrieves all items with the given type- Specified by:
getItemsOfTypein interfaceItemRegistry- Parameters:
type- item type as defined byItemFactorys- Returns:
- a collection of all items of the given type
-
getItems
Description copied from interface:ItemRegistryThis method retrieves all items that match a given search pattern- Specified by:
getItemsin interfaceItemRegistry- Returns:
- a collection of all items matching the search pattern
-
getItemsByTag
Description copied from interface:ItemRegistryReturns list of items which contains all of the given tags.- Specified by:
getItemsByTagin interfaceItemRegistry- Parameters:
tags- array of tags to be present on the returned items.- Returns:
- list of items which contains all of the given tags.
-
getItemsByTagAndType
Description copied from interface:ItemRegistryReturns list of items with a certain type containing all of the given tags.- Specified by:
getItemsByTagAndTypein interfaceItemRegistry- Parameters:
type- item type as defined byItemFactorystags- array of tags to be present on the returned items.- Returns:
- list of items which contains all of the given tags.
-
getItemsByTag
Description copied from interface:ItemRegistryReturns list of items which contains all of the given tags.- Specified by:
getItemsByTagin interfaceItemRegistry- Parameters:
typeFilter- subclass ofGenericItemto filter the resulting list for.tags- array of tags to be present on the returned items.- Returns:
- list of items which contains all of the given tags, which is filtered by the given type filter.
-
remove
- Specified by:
removein interfaceItemRegistry- See Also:
-
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
-