2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.omnilink.internal;
15 import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.omnilink.internal.handler.AudioSourceHandler;
20 import org.openhab.binding.omnilink.internal.handler.AudioZoneHandler;
21 import org.openhab.binding.omnilink.internal.handler.ButtonHandler;
22 import org.openhab.binding.omnilink.internal.handler.ConsoleHandler;
23 import org.openhab.binding.omnilink.internal.handler.HumiditySensorHandler;
24 import org.openhab.binding.omnilink.internal.handler.LockHandler;
25 import org.openhab.binding.omnilink.internal.handler.LuminaAreaHandler;
26 import org.openhab.binding.omnilink.internal.handler.OmniAreaHandler;
27 import org.openhab.binding.omnilink.internal.handler.OmnilinkBridgeHandler;
28 import org.openhab.binding.omnilink.internal.handler.TempSensorHandler;
29 import org.openhab.binding.omnilink.internal.handler.ThermostatHandler;
30 import org.openhab.binding.omnilink.internal.handler.UnitHandler;
31 import org.openhab.binding.omnilink.internal.handler.ZoneHandler;
32 import org.openhab.binding.omnilink.internal.handler.units.DimmableUnitHandler;
33 import org.openhab.binding.omnilink.internal.handler.units.FlagHandler;
34 import org.openhab.binding.omnilink.internal.handler.units.OutputHandler;
35 import org.openhab.binding.omnilink.internal.handler.units.UpbRoomHandler;
36 import org.openhab.binding.omnilink.internal.handler.units.dimmable.UpbUnitHandler;
37 import org.openhab.core.thing.Bridge;
38 import org.openhab.core.thing.Thing;
39 import org.openhab.core.thing.ThingTypeUID;
40 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
41 import org.openhab.core.thing.binding.ThingHandler;
42 import org.openhab.core.thing.binding.ThingHandlerFactory;
43 import org.osgi.service.component.annotations.Component;
46 * The {@link OmnilinkHandlerFactory} is responsible for creating things and thing
49 * @author Craig Hamilton - Initial contribution
50 * @author Ethan Dye - openHAB3 rewrite
53 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.omnilink")
54 public class OmnilinkHandlerFactory extends BaseThingHandlerFactory {
57 public boolean supportsThingType(ThingTypeUID thingTypeUID) {
58 return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
62 protected @Nullable ThingHandler createHandler(Thing thing) {
63 ThingTypeUID thingTypeUID = thing.getThingTypeUID();
65 if (thingTypeUID.equals(THING_TYPE_AUDIO_SOURCE)) {
66 return new AudioSourceHandler(thing);
67 } else if (thingTypeUID.equals(THING_TYPE_AUDIO_ZONE)) {
68 return new AudioZoneHandler(thing);
69 } else if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
70 return new OmnilinkBridgeHandler((Bridge) thing);
71 } else if (thingTypeUID.equals(THING_TYPE_BUTTON)) {
72 return new ButtonHandler(thing);
73 } else if (thingTypeUID.equals(THING_TYPE_CONSOLE)) {
74 return new ConsoleHandler(thing);
75 } else if (thingTypeUID.equals(THING_TYPE_DIMMABLE)) {
76 return new DimmableUnitHandler(thing);
77 } else if (thingTypeUID.equals(THING_TYPE_FLAG)) {
78 return new FlagHandler(thing);
79 } else if (thingTypeUID.equals(THING_TYPE_HUMIDITY_SENSOR)) {
80 return new HumiditySensorHandler(thing);
81 } else if (thingTypeUID.equals(THING_TYPE_LOCK)) {
82 return new LockHandler(thing);
83 } else if (thingTypeUID.equals(THING_TYPE_LUMINA_AREA)) {
84 return new LuminaAreaHandler(thing);
85 } else if (thingTypeUID.equals(THING_TYPE_OMNI_AREA)) {
86 return new OmniAreaHandler(thing);
87 } else if (thingTypeUID.equals(THING_TYPE_OUTPUT)) {
88 return new OutputHandler(thing);
89 } else if (thingTypeUID.equals(THING_TYPE_ROOM)) {
90 return new UpbRoomHandler(thing);
91 } else if (thingTypeUID.equals(THING_TYPE_TEMP_SENSOR)) {
92 return new TempSensorHandler(thing);
93 } else if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
94 return new ThermostatHandler(thing);
95 } else if (thingTypeUID.equals(THING_TYPE_UNIT)) {
96 return new UnitHandler(thing);
97 } else if (thingTypeUID.equals(THING_TYPE_UNIT_UPB)) {
98 return new UpbUnitHandler(thing);
99 } else if (thingTypeUID.equals(THING_TYPE_ZONE)) {
100 return new ZoneHandler(thing);