]> git.basschouten.com Git - openhab-addons.git/blob
6af2379dfdb9f399c1cc256a126ea64ecd428f8d
[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.pentair.internal;
14
15 import static org.openhab.binding.pentair.internal.PentairBindingConstants.*;
16
17 import org.openhab.binding.pentair.internal.handler.PentairEasyTouchHandler;
18 import org.openhab.binding.pentair.internal.handler.PentairIPBridgeHandler;
19 import org.openhab.binding.pentair.internal.handler.PentairIntelliChlorHandler;
20 import org.openhab.binding.pentair.internal.handler.PentairIntelliFloHandler;
21 import org.openhab.binding.pentair.internal.handler.PentairSerialBridgeHandler;
22 import org.openhab.core.thing.Bridge;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingTypeUID;
25 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
26 import org.openhab.core.thing.binding.ThingHandler;
27 import org.openhab.core.thing.binding.ThingHandlerFactory;
28 import org.osgi.service.component.annotations.Component;
29
30 /**
31  * The {@link PentairHandlerFactory} is responsible for creating things and thing
32  * handlers.
33  *
34  * @author Jeff James - Initial contribution
35  */
36 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.pentair")
37 public class PentairHandlerFactory extends BaseThingHandlerFactory {
38     @Override
39     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
40         return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
41     }
42
43     @Override
44     protected ThingHandler createHandler(Thing thing) {
45         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
46
47         if (thingTypeUID.equals(IP_BRIDGE_THING_TYPE)) {
48             return new PentairIPBridgeHandler((Bridge) thing);
49         } else if (thingTypeUID.equals(SERIAL_BRIDGE_THING_TYPE)) {
50             return new PentairSerialBridgeHandler((Bridge) thing);
51         } else if (thingTypeUID.equals(EASYTOUCH_THING_TYPE)) {
52             return new PentairEasyTouchHandler(thing);
53         } else if (thingTypeUID.equals(INTELLIFLO_THING_TYPE)) {
54             return new PentairIntelliFloHandler(thing);
55         } else if (thingTypeUID.equals(INTELLICHLOR_THING_TYPE)) {
56             return new PentairIntelliChlorHandler(thing);
57         }
58
59         return null;
60     }
61 }