2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.digitalstrom.internal.lib.event;
15 import java.util.List;
17 import org.openhab.binding.digitalstrom.internal.lib.event.types.EventItem;
20 * The {@link EventHandler} can be implemented to get informed by {@link EventItem}'s through the {@link EventListener}.
22 * For that the {@link #getSupportedEvents()} and
23 * {@link #supportsEvent(String)} methods have to be implemented, so that
24 * the {@link EventListener} knows whitch events it has to subscribe at the digitalSTROM-server and which handler has
25 * to be informed. <br>
26 * The implementation of the {@link EventHandler} also has to be registered through
27 * {@link EventListener#addEventHandler(EventHandler)} to the {@link EventListener} and the {@link EventListener} has to
30 * To handle the {@link EventItem} the method {@link #handleEvent(EventItem)} has to be implemented.
32 * @author Michael Ochel - Initial contribution
33 * @author Matthias Siegele - Initial contribution
35 public interface EventHandler {
38 * Handles an {@link EventItem} e.g. which was detected by the {@link EventListener}.
40 * @param eventItem to handle
42 void handleEvent(EventItem eventItem);
45 * Returns a {@link List} that contains the supported events.
47 * @return supported events
49 List<String> getSupportedEvents();
52 * Returns true, if the {@link EventHandler} supports the given event.
54 * @param eventName to check
55 * @return true, if event is supported, otherwise false
57 boolean supportsEvent(String eventName);
60 * Returns the unique id of the {@link EventHandler}.
62 * @return uid of the EventHandler
67 * Sets an {@link EventListener} to this {@link EventHandler}.
69 * @param eventListener to set
71 void setEventListener(EventListener eventListener);
74 * Unsets an {@link EventListener} to this {@link EventHandler}.
76 * @param eventListener to unset
78 void unsetEventListener(EventListener eventListener);