]> git.basschouten.com Git - openhab-addons.git/blob
b86653a863589c70edc9409f784c7b77cbb54771
[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.homeconnect.internal.client.model;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * Option model
20  *
21  * @author Jonas BrĂ¼stel - Initial contribution
22  *
23  */
24 @NonNullByDefault
25 public class Option {
26
27     private final @Nullable String key;
28     private final @Nullable String value;
29     private final @Nullable String unit;
30
31     public Option(@Nullable String key, @Nullable String value, @Nullable String unit) {
32         this.key = key;
33         this.value = value;
34         this.unit = unit;
35     }
36
37     public @Nullable String getKey() {
38         return key;
39     }
40
41     public @Nullable String getValue() {
42         return value;
43     }
44
45     public boolean getValueAsBoolean() {
46         return Boolean.parseBoolean(value);
47     }
48
49     public int getValueAsInt() {
50         @Nullable
51         String stringValue = value;
52         return stringValue != null ? Integer.parseInt(stringValue) : 0;
53     }
54
55     public @Nullable String getUnit() {
56         return unit;
57     }
58
59     @Override
60     public String toString() {
61         return "Option [key=" + key + ", value=" + value + ", unit=" + unit + "]";
62     }
63 }