]> git.basschouten.com Git - openhab-addons.git/blob
3820fd8c968ca773d404ddb5f0318bd723e09b99
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.fronius.internal.api;
14
15 import org.openhab.binding.fronius.internal.math.KilowattConverter;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * The {@link InverterRealtimeResponse} is responsible for storing
21  * a value
22  *
23  * @author Thomas Rokohl - Initial contribution
24  */
25 public class ValueUnit {
26     @SerializedName("Value")
27     private double value;
28     @SerializedName("Unit")
29     private String unit;
30
31     public double getValue() {
32         return value;
33     }
34
35     public void setValue(double value) {
36         this.value = value;
37     }
38
39     public String getUnit() {
40         if (unit == null) {
41             unit = "";
42         }
43         return unit;
44     }
45
46     public void setUnit(String unit) {
47         this.setValue(KilowattConverter.convertTo(this.getValue(), this.getUnit(), unit));
48         this.unit = unit;
49     }
50 }