java.lang.Object
org.openhab.core.common.registry.AbstractProvider<Thing>
org.openhab.core.automation.module.script.providersupport.shared.ScriptedThingProvider
All Implemented Interfaces:
ManagedProvider<Thing,ThingUID>, Provider<Thing>, EventSubscriber, ThingProvider

@NonNullByDefault public class ScriptedThingProvider extends AbstractProvider<Thing> implements ThingProvider, ManagedProvider<Thing,ThingUID>, EventSubscriber
This ThingProvider keeps things provided by scripts during runtime. This ensures that things are not kept on reboot, but have to be provided by the scripts again.
Author:
Florian Hotze - Initial contribution
  • Constructor Details

    • ScriptedThingProvider

      public ScriptedThingProvider()
  • Method Details

    • getAll

      public Collection<Thing> getAll()
      Description copied from interface: Provider
      Returns a collection of all elements.
      Specified by:
      getAll in interface Provider<Thing>
      Returns:
      collection of all elements
    • get

      public @Nullable Thing get(ThingUID uid)
      Description copied from interface: ManagedProvider
      Returns an element for the given key or null if no element for the given key exists.
      Specified by:
      get in interface ManagedProvider<Thing,ThingUID>
      Parameters:
      uid - key
      Returns:
      returns element or null, if no element for the given key exists
    • add

      public void add(Thing thing)
      Description copied from interface: ManagedProvider
      Adds an element.
      Specified by:
      add in interface ManagedProvider<Thing,ThingUID>
      Parameters:
      thing - element to be added
    • update

      public @Nullable Thing update(Thing thing)
      Description copied from interface: ManagedProvider
      Updates an element.
      Specified by:
      update in interface ManagedProvider<Thing,ThingUID>
      Parameters:
      thing - element to be updated
      Returns:
      returns the old element or null if no element with the same key exists
    • remove

      public @Nullable Thing remove(ThingUID uid)
      Description copied from interface: ManagedProvider
      Removes an element and returns the removed element.
      Specified by:
      remove in interface ManagedProvider<Thing,ThingUID>
      Parameters:
      uid - key of the element that should be removed
      Returns:
      element that was removed, or null if no element with the given key exists
    • getSubscribedEventTypes

      public Set<String> getSubscribedEventTypes()
      Description copied from interface: EventSubscriber
      Gets the event types to which the event subscriber is subscribed to.
      Specified by:
      getSubscribedEventTypes in interface EventSubscriber
      Returns:
      subscribed event types (not null)
    • receive

      public void receive(Event event)
      Description copied from interface: EventSubscriber
      Callback method for receiving Events from the openHAB event bus. This method is called for every event where the event subscriber is subscribed to and the event filter applies.
      Specified by:
      receive in interface EventSubscriber
      Parameters:
      event - the received event (not null)