Package org.openhab.core.common.registry
Interface Registry<E extends Identifiable<K>,K>
- Type Parameters:
E- type of the elements in the registry
- All Known Subinterfaces:
ItemRegistry,ItemUIRegistry,MetadataRegistry,ModuleTypeRegistry,PersistenceServiceConfigurationRegistry,RuleRegistry,SemanticTagRegistry,TemplateRegistry<E>,ThingRegistry,TransformationRegistry,UIComponentRegistry,UserRegistry
- All Known Implementing Classes:
AbstractLinkRegistry,AbstractRegistry,ItemChannelLinkRegistry,ProviderItemChannelLinkRegistry,ProviderItemRegistryDelegate,ProviderMetadataRegistryDelegate,ProviderThingRegistryDelegate,RuleSupportRuleRegistryDelegate
The
Registry interface represents a registry for elements of the type
E. The concrete sub interfaces are registered as OSGi services.- Author:
- Dennis Nobel - Initial contribution, Victor Toni - provide elements as
Stream, Kai Kreuzer - added null annotations
-
Method Summary
Modifier and TypeMethodDescriptionAdds the given element to the accordingManagedProvider.voidaddRegistryChangeListener(RegistryChangeListener<@NonNull E> listener) Adds aRegistryChangeListenerto the registry.@Nullable EThis method retrieves a single element from the registry.getAll()Returns a collection of all elements in the registry.@Nullable ERemoves the given element from the accordingManagedProvider.voidremoveRegistryChangeListener(RegistryChangeListener<@NonNull E> listener) Removes aRegistryChangeListenerfrom the registry.stream()Returns a stream of all elements in the registry.@Nullable EUpdates the given element at the accordingManagedProvider.
-
Method Details
-
addRegistryChangeListener
Adds aRegistryChangeListenerto the registry.- Parameters:
listener- registry change listener
-
getAll
Collection<E> getAll()Returns a collection of all elements in the registry.- Returns:
- collection of all elements in the registry
-
stream
Returns a stream of all elements in the registry.- Returns:
- stream of all elements in the registry
-
get
This method retrieves a single element from the registry.- Parameters:
key- key of the element- Returns:
- element or null if no element was found
-
removeRegistryChangeListener
Removes aRegistryChangeListenerfrom the registry.- Parameters:
listener- registry change listener
-
add
Adds the given element to the accordingManagedProvider.- Parameters:
element- element to be added (must not be null)- Returns:
- the added element or newly created object of the same type
- Throws:
IllegalStateException- if no ManagedProvider is available
-
update
Updates the given element at the accordingManagedProvider.- 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
- Throws:
IllegalStateException- if no ManagedProvider is available
-
remove
Removes the given element from the accordingManagedProvider.- 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
- Throws:
IllegalStateException- if no ManagedProvider is available
-