Package org.openhab.core.events
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
-
Field Summary
Fields inherited from interface org.openhab.core.events.EventSubscriber
ALL_EVENT_TYPES
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractTypedEventSubscriber
(String eventType) Constructs a new typed event subscriber. -
Method Summary
Modifier and TypeMethodDescriptionGets the event types to which the event subscriber is subscribed to.void
Callback method for receivingEvent
s from the openHAB event bus.protected abstract void
receiveTypedEvent
(T event) Callback method for receiving typed events of type T.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openhab.core.events.EventSubscriber
getEventFilter
-
Constructor Details
-
AbstractTypedEventSubscriber
Constructs a new typed event subscriber. Must be called in the subclass.- Parameters:
eventType
- the event type
-
-
Method Details
-
getSubscribedEventTypes
Description copied from interface:EventSubscriber
Gets the event types to which the event subscriber is subscribed to.- Specified by:
getSubscribedEventTypes
in interfaceEventSubscriber
- Returns:
- subscribed event types (not null)
-
receive
Description copied from interface:EventSubscriber
Callback method for receivingEvent
s 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 interfaceEventSubscriber
- Parameters:
event
- the received event (not null)
-
receiveTypedEvent
Callback method for receiving typed events of type T.- Parameters:
event
- the received event
-