]> git.basschouten.com Git - openhab-addons.git/blob
55340a41d1fba1acd817471414e6578ba00eea97
[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.velux.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.thing.ChannelUID;
18 import org.openhab.core.types.Command;
19 import org.openhab.core.types.State;
20
21 /**
22  * <B>Channel-specific retrieval and modification.</B>
23  * <P>
24  * This class implements the Channel <B>VShutter</B> :
25  * <UL>
26  * <LI><I>Velux</I> <B>bridge</B> &rarr; <B>OpenHAB</B>:
27  * <P>
28  * Information retrieval by method {@link #handleRefresh}.</LI>
29  * </UL>
30  * <UL>
31  * <LI><B>OpenHAB</B> Event Bus &rarr; <I>Velux</I> <B>bridge</B>
32  * <P>
33  * Sending commands and value updates by method {@link #handleCommand}.</LI>
34  * </UL>
35  *
36  * @author Guenther Schreiner - Initial contribution.
37  */
38 @NonNullByDefault
39 abstract class ChannelHandlerTemplate {
40
41     /**
42      * Communication method to retrieve information to update the channel value.
43      *
44      * @param channelUID The item passed as type {@link ChannelUID} for which a refresh is intended.
45      * @param channelId The same item passed as type {@link String} for which a refresh is intended.
46      * @param thisBridgeHandler The Velux bridge handler with a specific communication protocol which provides
47      *            information for this channel.
48      * @return <B>newValue</B> The value retrieved for the passed channel, or <I>null</I> in case if there is no (new)
49      *         value.
50      */
51     static @Nullable State handleRefresh(ChannelUID channelUID, String channelId,
52             VeluxBridgeHandler thisBridgeHandler) {
53         throw new IllegalStateException("handleRefresh hasn't been set up in the subclass");
54     }
55
56     /**
57      * Communication method to update the real world according to the passed channel value (or command).
58      *
59      * @param channelUID The item passed as type {@link ChannelUID} for which to following command is addressed to.
60      * @param channelId The same item passed as type {@link String} for which a refresh is intended.
61      * @param command The command passed as type {@link Command} for the mentioned item.
62      * @param thisBridgeHandler The Velux bridge handler with a specific communication protocol which provides
63      *            information for this channel.
64      * @return <B>newValue</B> value to be assigned to the channel by BaseThingHandler.postUpdate, or <I>null</I>, if
65      *         not desired.
66      */
67     static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command,
68             VeluxBridgeHandler thisBridgeHandler) {
69         throw new IllegalStateException("handleRefresh hasn't been set up in the subclass");
70     }
71 }