]> git.basschouten.com Git - openhab-addons.git/blob
dfd68b33ac03b2f98ca4be464f3919e3e907d704
[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.gardena.internal.model;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.gardena.internal.exception.GardenaException;
17 import org.openhab.binding.gardena.internal.model.dto.api.*;
18
19 /**
20  * Creates the dataItem object based on the device type.
21  *
22  * @author Gerhard Riegler - Initial contribution
23  */
24 @NonNullByDefault
25 public class DataItemFactory {
26     public static Class<? extends DataItem<?>> create(String type) throws GardenaException {
27         switch (type) {
28             case "LOCATION":
29                 return LocationDataItem.class;
30             case "DEVICE":
31                 return DeviceDataItem.class;
32             case "COMMON":
33                 return CommonServiceDataItem.class;
34             case "MOWER":
35                 return MowerServiceDataItem.class;
36             case "POWER_SOCKET":
37                 return PowerSocketServiceDataItem.class;
38             case "VALVE":
39                 return ValveServiceDataItem.class;
40             case "VALVE_SET":
41                 return ValveSetServiceDataItem.class;
42             case "SENSOR":
43                 return SensorServiceDataItem.class;
44             default:
45                 throw new GardenaException("Unknown DataItem type: " + type);
46         }
47     }
48 }