]> git.basschouten.com Git - openhab-addons.git/blob
af9adb1b21825b5247d45340bd0109871ae4a2cb
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.digitalstrom.internal.lib.event;
14
15 import java.util.List;
16
17 import org.openhab.binding.digitalstrom.internal.lib.event.types.EventItem;
18
19 /**
20  * The {@link EventHandler} can be implemented to get informed by {@link EventItem}'s through the {@link EventListener}.
21  * <br>
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
28  * be started.<br>
29  * <br>
30  * To handle the {@link EventItem} the method {@link #handleEvent(EventItem)} has to be implemented.
31  *
32  * @author Michael Ochel - Initial contribution
33  * @author Matthias Siegele - Initial contribution
34  */
35 public interface EventHandler {
36
37     /**
38      * Handles an {@link EventItem} e.g. which was detected by the {@link EventListener}.
39      *
40      * @param eventItem to handle
41      */
42     void handleEvent(EventItem eventItem);
43
44     /**
45      * Returns a {@link List} that contains the supported events.
46      *
47      * @return supported events
48      */
49     List<String> getSupportedEvents();
50
51     /**
52      * Returns true, if the {@link EventHandler} supports the given event.
53      *
54      * @param eventName to check
55      * @return true, if event is supported, otherwise false
56      */
57     boolean supportsEvent(String eventName);
58
59     /**
60      * Returns the unique id of the {@link EventHandler}.
61      *
62      * @return uid of the EventHandler
63      */
64     String getUID();
65
66     /**
67      * Sets an {@link EventListener} to this {@link EventHandler}.
68      *
69      * @param eventListener to set
70      */
71     void setEventListener(EventListener eventListener);
72
73     /**
74      * Unsets an {@link EventListener} to this {@link EventHandler}.
75      *
76      * @param eventListener to unset
77      */
78     void unsetEventListener(EventListener eventListener);
79 }