Class AbstractTypedEventSubscriber<T extends Event>

java.lang.Object
org.openhab.core.events.AbstractTypedEventSubscriber<T>
Type Parameters:
T - The specific event type this class subscribes to.
All Implemented Interfaces:
EventSubscriber

@NonNullByDefault public abstract class AbstractTypedEventSubscriber<T extends Event> extends Object implements EventSubscriber
The AbstractTypedEventSubscriber is an abstract implementation of the EventSubscriber interface which helps to subscribe to a specific event type. To receive an event - casted to the specific event type - the receiveTypedEvent(T) method must be implemented. This implementation provides no event filter. To filter events based on the topic or some content the EventSubscriber.getEventFilter() method can be overridden.
Author:
Stefan Bußweiler - Initial contribution
  • Constructor Details

    • AbstractTypedEventSubscriber

      protected AbstractTypedEventSubscriber(String eventType)
      Constructs a new typed event subscriber. Must be called in the subclass.
      Parameters:
      eventType - the event type
  • Method Details

    • 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)
    • receiveTypedEvent

      protected abstract void receiveTypedEvent(T event)
      Callback method for receiving typed events of type T.
      Parameters:
      event - the received event