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.webthing.internal.link;
15 import java.util.Locale;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.webthing.internal.client.dto.Property;
22 * The {@link TypeMapping} class defines the mapping of Item types <-> WebThing Property types.
24 * Please consider that changes of 'Item types <-> WebThing Property types' mapping will break the
25 * compatibility to former releases
27 * @author Gregor Roth - Initial contribution
30 public class TypeMapping {
33 * maps a property type to an item type
35 * @param propertyMetadata the property meta data
36 * @return the associated item type
38 public static ItemType toItemType(Property propertyMetadata) {
39 String type = "string";
43 switch (propertyMetadata.typeKeyword) {
45 case "BooleanProperty":
47 case "LockedProperty":
48 case "MotionProperty":
50 case "PushedProperty":
54 case "CurrentProperty":
55 case "FrequencyProperty":
56 case "InstantaneousPowerProperty":
57 case "VoltageProperty":
60 case "HeatingCoolingProperty":
65 case "BrightnessProperty":
66 case "HumidityProperty":
69 case "ColorModeProperty":
77 case "ColorTemperatureProperty":
83 tag = "ContactSensor";
85 case "TargetTemperatureProperty":
87 tag = "TargetTemperature";
89 case "TemperatureProperty":
91 tag = "CurrentTemperature";
93 case "ThermostatModeProperty":
96 if ((propertyMetadata.unit != null)
97 && propertyMetadata.unit.toLowerCase(Locale.ENGLISH).equals("percent")) {
104 switch (propertyMetadata.type.toLowerCase(Locale.ENGLISH)) {
120 return new ItemType(type, tag);
124 * The item type description
126 public static class ItemType {
127 private final String type;
128 private final @Nullable String tag;
130 ItemType(String type, @Nullable String tag) {
135 public String getType() {
139 public @Nullable String getTag() {