]> git.basschouten.com Git - openhab-addons.git/blob
6e89743ad2bd43c8912b1f4949f4c26b9f024b87
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.dmx.internal;
14
15 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
16
17 import org.openhab.binding.dmx.internal.handler.ArtnetBridgeHandler;
18 import org.openhab.binding.dmx.internal.handler.ChaserThingHandler;
19 import org.openhab.binding.dmx.internal.handler.ColorThingHandler;
20 import org.openhab.binding.dmx.internal.handler.DimmerThingHandler;
21 import org.openhab.binding.dmx.internal.handler.Lib485BridgeHandler;
22 import org.openhab.binding.dmx.internal.handler.SacnBridgeHandler;
23 import org.openhab.binding.dmx.internal.handler.TunableWhiteThingHandler;
24 import org.openhab.core.thing.Bridge;
25 import org.openhab.core.thing.Thing;
26 import org.openhab.core.thing.ThingTypeUID;
27 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
28 import org.openhab.core.thing.binding.ThingHandler;
29 import org.openhab.core.thing.binding.ThingHandlerFactory;
30 import org.osgi.service.component.annotations.Component;
31
32 /**
33  * The {@link DmxHandlerFactory} is responsible for creating things and thing
34  * handlers.
35  *
36  * @author Jan N. Klug - Initial contribution
37  */
38 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.dmx")
39 public class DmxHandlerFactory extends BaseThingHandlerFactory {
40
41     @Override
42     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
43         return DmxBindingConstants.SUPPORTED_THING_TYPES.contains(thingTypeUID);
44     }
45
46     @Override
47     protected ThingHandler createHandler(Thing thing) {
48         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
49         if (thingTypeUID.equals(THING_TYPE_ARTNET_BRIDGE)) {
50             ArtnetBridgeHandler handler = new ArtnetBridgeHandler((Bridge) thing);
51             return handler;
52         } else if (thingTypeUID.equals(THING_TYPE_LIB485_BRIDGE)) {
53             Lib485BridgeHandler handler = new Lib485BridgeHandler((Bridge) thing);
54             return handler;
55         } else if (thingTypeUID.equals(THING_TYPE_SACN_BRIDGE)) {
56             SacnBridgeHandler handler = new SacnBridgeHandler((Bridge) thing);
57             return handler;
58         } else if (thingTypeUID.equals(THING_TYPE_DIMMER)) {
59             DimmerThingHandler handler = new DimmerThingHandler(thing);
60             return handler;
61         } else if (thingTypeUID.equals(THING_TYPE_COLOR)) {
62             ColorThingHandler handler = new ColorThingHandler(thing);
63             return handler;
64         } else if (thingTypeUID.equals(THING_TYPE_TUNABLEWHITE)) {
65             TunableWhiteThingHandler handler = new TunableWhiteThingHandler(thing);
66             return handler;
67         } else if (thingTypeUID.equals(THING_TYPE_CHASER)) {
68             ChaserThingHandler handler = new ChaserThingHandler(thing);
69             return handler;
70         }
71         return null;
72     }
73 }