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 #getSupportetEvents()} and {@link #supportsEvent(String)} methods have to be implemented, so that
23 * the {@link EventListener} knows whitch events it has to subscribe at the digitalSTROM-server and which handler has
24 * to be informed. <br>
25 * The implementation of the {@link EventHandler} also has to be registered through
26 * {@link EventListener#addEventHandler(EventHandler)} to the {@link EventListener} and the {@link EventListener} has to
29 * To handle the {@link EventItem} the method {@link #handleEvent(EventItem)} has to be implemented.
31 * @author Michael Ochel
32 * @author Matthias Siegele
34 public interface EventHandler {
37 * Handles an {@link EventItem} e.g. which was detected by the {@link EventListener}.
39 * @param eventItem to handle
41 void handleEvent(EventItem eventItem);
44 * Returns a {@link List} that contains the supported events.
46 * @return supported events
48 List<String> getSupportedEvents();
51 * Returns true, if the {@link EventHandler} supports the given event.
53 * @param eventName to check
54 * @return true, if event is supported, otherwise false
56 boolean supportsEvent(String eventName);
59 * Returns the unique id of the {@link EventHandler}.
61 * @return uid of the EventHandler
66 * Sets an {@link EventListener} to this {@link EventHandler}.
68 * @param eventListener to set
70 void setEventListener(EventListener eventListener);
73 * Unsets an {@link EventListener} to this {@link EventHandler}.
75 * @param eventListener to unset
77 void unsetEventListener(EventListener eventListener);