Class ProviderThingRegistryDelegate
java.lang.Object
org.openhab.core.automation.module.script.providersupport.shared.ProviderThingRegistryDelegate
- All Implemented Interfaces:
org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry,Registry<Thing,,ThingUID> ThingRegistry
@NonNullByDefault
public class ProviderThingRegistryDelegate
extends Object
implements ThingRegistry, org.openhab.core.automation.module.script.providersupport.internal.ProviderRegistry
The
ProviderThingRegistryDelegate is wrapping a ThingRegistry to provide a comfortable way to provide
Things from scripts without worrying about the need to remove Things again when the script is unloaded.
Nonetheless, using the addPermanent(Thing) method it is still possible to add Things permanently.
Use a new instance of this class for each ScriptEngine.
- Author:
- Florian Hotze - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionProviderThingRegistryDelegate(ThingRegistry thingRegistry, ScriptedThingProvider scriptedProvider) -
Method Summary
Modifier and TypeMethodDescriptionAdds the given element to the accordingManagedProvider.addPermanent(Thing element) Add a Thing permanently to the registry.voidaddRegistryChangeListener(RegistryChangeListener<Thing> listener) Adds aRegistryChangeListenerto the registry.@Nullable ThingcreateThingOfType(ThingTypeUID thingTypeUID, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID, @Nullable String label, Configuration configuration) Creates a thing based on the given configuration properties@Nullable ThingforceRemove(ThingUID thingUID) @Nullable ThingReturns a thing for a given UID or null if no thing was found.getAll()Returns a collection of all elements in the registry.@Nullable ChannelgetChannel(ChannelUID channelUID) Returns a channel for the given channel UID or null if no channel was found@Nullable ThingvoidRemoves 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 ThingUpdates the given element at the accordingManagedProvider.voidupdateConfiguration(ThingUID thingUID, Map<String, Object> configurationParameters) Updates the configuration of a thing for the given UID.
-
Constructor Details
-
Method Details
-
addRegistryChangeListener
Description copied from interface:RegistryAdds aRegistryChangeListenerto the registry.- Specified by:
addRegistryChangeListenerin interfaceRegistry<Thing,ThingUID> - 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. -
removeRegistryChangeListener
Description copied from interface:RegistryRemoves aRegistryChangeListenerfrom the registry.- Specified by:
removeRegistryChangeListenerin interfaceRegistry<Thing,ThingUID> - Parameters:
listener- registry change listener
-
add
Description copied from interface:RegistryAdds the given element to the accordingManagedProvider. -
addPermanent
Add a Thing permanently to the registry. This Thing will be kept in the registry even if the script is unloaded.- Parameters:
element- the Thing to be added (must not be null)- Returns:
- the added Thing
-
update
Description copied from interface:RegistryUpdates the given element at the accordingManagedProvider. -
get
Description copied from interface:ThingRegistryReturns a thing for a given UID or null if no thing was found. -
getChannel
Description copied from interface:ThingRegistryReturns a channel for the given channel UID or null if no channel was found- Specified by:
getChannelin interfaceThingRegistry- Parameters:
channelUID- channel UID- Returns:
- channel for the given channel UID or null of no channel was found
-
updateConfiguration
Description copied from interface:ThingRegistryUpdates the configuration of a thing for the given UID.- Specified by:
updateConfigurationin interfaceThingRegistry- Parameters:
thingUID- thing UIDconfigurationParameters- configuration parameters
-
remove
Description copied from interface:ThingRegistryInitiates the removal process for theThingspecified by the givenThingUID. Unlike in otherRegistrys,Things don't get removed immediately. Instead, the correspondingThingHandleris given the chance to perform any required removal handling before it actually gets removed.If for any reasons the
Thingshould be removed immediately without any prior processing, useThingRegistry.forceRemove(ThingUID)instead. -
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
-
forceRemove
Description copied from interface:ThingRegistryRemoves theThingspecified by the givenThingUID. If the correspondingThingHandlershould be given the chance to perform any removal operations, useThingRegistry.remove(ThingUID)instead.- Specified by:
forceRemovein interfaceThingRegistry- Parameters:
thingUID- Identificator of theThingto be removed- Returns:
- the
Thingthat was removed, or null if noThingwith the givenThingUIDexists
-
createThingOfType
public @Nullable Thing createThingOfType(ThingTypeUID thingTypeUID, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID, @Nullable String label, Configuration configuration) Description copied from interface:ThingRegistryCreates a thing based on the given configuration properties- Specified by:
createThingOfTypein interfaceThingRegistry- Parameters:
thingTypeUID- thing type unique idthingUID- thing unique id which should be created. This id might be null.bridgeUID- the thing's bridge. Null if there is no bridge or if the thing is a bridge by itself.configuration- the configuration- Returns:
- the created thing
-