Class AbstractTypedEventSubscriber<T extends Event>

Type Parameters:
T - The specific event type this class subscribes to.
All Implemented Interfaces:

@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.
Stefan Bußweiler - Initial contribution
  • Constructor Details

    • AbstractTypedEventSubscriber

      protected AbstractTypedEventSubscriber(String eventType)
      Constructs a new typed event subscriber. Must be called in the subclass.
      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
      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
      event - the received event (not null)
    • receiveTypedEvent

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