2 * Copyright (c) 2010-2023 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.mielecloud.internal.webservice.api.json;
15 import java.util.Objects;
16 import java.util.Optional;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
21 import com.google.gson.annotations.SerializedName;
24 * Immutable POJO representing a temperature value. Queried from the Miele REST API.
26 * @author Björn Lange - Initial contribution
29 public class Temperature {
30 @SerializedName("value_raw")
32 private Integer valueRaw;
33 @SerializedName("value_localized")
35 private Double valueLocalized;
36 @SerializedName("unit")
40 public Optional<Integer> getValueRaw() {
41 return Optional.ofNullable(valueRaw);
44 public Optional<Integer> getValueLocalized() {
45 return Optional.ofNullable(valueLocalized).map(Double::intValue);
48 public Optional<String> getUnit() {
49 return Optional.ofNullable(unit);
53 public int hashCode() {
54 return Objects.hash(unit, valueLocalized, valueRaw);
58 public boolean equals(@Nullable Object obj) {
65 if (getClass() != obj.getClass()) {
68 Temperature other = (Temperature) obj;
69 return Objects.equals(unit, other.unit) && Objects.equals(valueLocalized, other.valueLocalized)
70 && Objects.equals(valueRaw, other.valueRaw);
74 public String toString() {
75 return "Temperature [valueRaw=" + valueRaw + ", valueLocalized=" + valueLocalized + ", unit=" + unit + "]";