]> git.basschouten.com Git - openhab-addons.git/blob
4b695c1662e91f83942f0f64437ec207d4702ed1
[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.bsblan.internal.api.dto;
14
15 import com.google.gson.annotations.SerializedName;
16
17 /**
18  * The {@link BsbLanApiParameterSetRequestDTO} reflects the request sent
19  * when setting a parameter.
20  *
21  * @author Peter Schraffl - Initial contribution
22  */
23 public class BsbLanApiParameterSetRequestDTO implements BsbLanApiContentDTO {
24
25     public enum Type {
26         @SerializedName("0")
27         INF("INF"),
28         @SerializedName("1")
29         SET("SET");
30
31         private final String value;
32
33         Type(String value) {
34             this.value = value;
35         }
36
37         public String getValue() {
38             return value;
39         }
40
41         public static Type getTypeWithFallback(String value) {
42             if (value != null) {
43                 for (Type t : Type.values()) {
44                     if (t.value.toLowerCase().equals(value.toLowerCase())) {
45                         return t;
46                     }
47                 }
48             }
49             // fallback to SET
50             return Type.SET;
51         }
52     }
53
54     // Although specifying the parameter as int (which would be nicer) also seems to work,
55     // we use a String here as this is the way it is noted in the documentation.
56     @SerializedName("Parameter")
57     public String parameter;
58
59     @SerializedName("Value")
60     public String value;
61
62     @SerializedName("Type")
63     public Type type;
64 }