Package org.openhab.core.items
Interface ItemRegistry
- All Known Subinterfaces:
ItemUIRegistry
The ItemRegistry is the central place, where items are kept in memory and their state
is permanently tracked. So any code that requires the current state of items should use
this service (instead of trying to keep their own local copy of the items).
Items are registered by
ItemProvider
s, which can provision them from any source
they like and also dynamically remove or add items.- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRegistryHook
(RegistryHook<Item> hook) Add a hook to be informed before adding/after removing items.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 Item
void
removeRegistryHook
(RegistryHook<Item> hook) Remove the hook again.Methods inherited from interface org.openhab.core.common.registry.Registry
add, addRegistryChangeListener, get, getAll, remove, removeRegistryChangeListener, stream, update
-
Method Details
-
getItem
This method retrieves a single item from the registry.- Parameters:
name
- the item name- Returns:
- the uniquely identified item
- Throws:
ItemNotFoundException
- if no item matches the input
-
getItemByPattern
This method retrieves a single item from the registry. Search patterns and shortened versions are supported, if they uniquely identify an item- 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
Collection<Item> getItems()This method retrieves all items that are currently available in the registry- Returns:
- a collection of all available items
-
getItemsOfType
This method retrieves all items with the given type- Parameters:
type
- item type as defined byItemFactory
s- Returns:
- a collection of all items of the given type
-
getItems
This method retrieves all items that match a given search pattern- Returns:
- a collection of all items matching the search pattern
-
getItemsByTag
Returns list of items which contains all of the given tags.- Parameters:
tags
- array of tags to be present on the returned items.- Returns:
- list of items which contains all of the given tags.
-
getItemsByTagAndType
Returns list of items with a certain type containing all of the given tags.- Parameters:
type
- item type as defined byItemFactory
stags
- array of tags to be present on the returned items.- Returns:
- list of items which contains all of the given tags.
-
getItemsByTag
Returns list of items which contains all of the given tags.- Parameters:
typeFilter
- subclass ofGenericItem
to 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
- See Also:
-
addRegistryHook
Add a hook to be informed before adding/after removing items.- Parameters:
hook
-
-
removeRegistryHook
Remove the hook again.- Parameters:
hook
-
-