]> git.basschouten.com Git - openhab-addons.git/blob
b05774678736b1b642b8e7812d51a52b11c140d5
[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.qbus.internal;
14
15 import static org.openhab.binding.qbus.internal.QbusBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.qbus.internal.handler.QbusBistabielHandler;
20 import org.openhab.binding.qbus.internal.handler.QbusCO2Handler;
21 import org.openhab.binding.qbus.internal.handler.QbusDimmerHandler;
22 import org.openhab.binding.qbus.internal.handler.QbusRolHandler;
23 import org.openhab.binding.qbus.internal.handler.QbusSceneHandler;
24 import org.openhab.binding.qbus.internal.handler.QbusThermostatHandler;
25 import org.openhab.core.thing.Bridge;
26 import org.openhab.core.thing.Thing;
27 import org.openhab.core.thing.ThingTypeUID;
28 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
29 import org.openhab.core.thing.binding.ThingHandler;
30 import org.openhab.core.thing.binding.ThingHandlerFactory;
31 import org.osgi.service.component.annotations.Component;
32
33 /**
34  * The {@link qbusHandlerFactory} is responsible for creating things and thing
35  * handlers.
36  *
37  * @author Koen Schockaert - Initial Contribution
38  */
39
40 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.qbus")
41 @NonNullByDefault
42 public class QbusHandlerFactory extends BaseThingHandlerFactory {
43
44     @Override
45     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
46         return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID) || BRIDGE_THING_TYPES_UIDS.contains(thingTypeUID);
47     }
48
49     @Override
50     protected @Nullable ThingHandler createHandler(Thing thing) {
51         if (BRIDGE_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
52             QbusBridgeHandler handler = new QbusBridgeHandler((Bridge) thing);
53             return handler;
54         } else if (SCENE_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
55             return new QbusSceneHandler(thing);
56         } else if (BISTABIEL_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
57             return new QbusBistabielHandler(thing);
58         } else if (THERMOSTAT_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
59             return new QbusThermostatHandler(thing);
60         } else if (DIMMER_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
61             return new QbusDimmerHandler(thing);
62         } else if (CO2_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
63             return new QbusCO2Handler(thing);
64         } else if (ROLLERSHUTTER_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
65             return new QbusRolHandler(thing);
66         } else if (ROLLERSHUTTER_SLATS_THING_TYPES_UIDS.contains(thing.getThingTypeUID())) {
67             return new QbusRolHandler(thing);
68         }
69
70         return null;
71     }
72 }