]> git.basschouten.com Git - openhab-addons.git/blob
0005e50a047dc37751300064ccd1d428d63c6c56
[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 #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
27  * be started.<br>
28  * <br>
29  * To handle the {@link EventItem} the method {@link #handleEvent(EventItem)} has to be implemented.
30  *
31  * @author Michael Ochel - Initial contribution
32  * @author Matthias Siegele - Initial contribution
33  */
34 public interface EventHandler {
35
36     /**
37      * Handles an {@link EventItem} e.g. which was detected by the {@link EventListener}.
38      *
39      * @param eventItem to handle
40      */
41     void handleEvent(EventItem eventItem);
42
43     /**
44      * Returns a {@link List} that contains the supported events.
45      *
46      * @return supported events
47      */
48     List<String> getSupportedEvents();
49
50     /**
51      * Returns true, if the {@link EventHandler} supports the given event.
52      *
53      * @param eventName to check
54      * @return true, if event is supported, otherwise false
55      */
56     boolean supportsEvent(String eventName);
57
58     /**
59      * Returns the unique id of the {@link EventHandler}.
60      *
61      * @return uid of the EventHandler
62      */
63     String getUID();
64
65     /**
66      * Sets an {@link EventListener} to this {@link EventHandler}.
67      *
68      * @param eventListener to set
69      */
70     void setEventListener(EventListener eventListener);
71
72     /**
73      * Unsets an {@link EventListener} to this {@link EventHandler}.
74      *
75      * @param eventListener to unset
76      */
77     void unsetEventListener(EventListener eventListener);
78 }