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
14 package org.openhab.binding.mielecloud.internal.webservice.api;
16 import java.util.Objects;
17 import java.util.Optional;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
23 * A physical quantity as obtained from the Miele REST API.
25 * @author Björn Lange - Initial contribution
28 public class Quantity {
30 Optional<String> unit;
32 public Quantity(double value, @Nullable String unit) {
34 this.unit = Optional.ofNullable(unit);
37 public double getValue() {
41 public Optional<String> getUnit() {
46 public int hashCode() {
47 return Objects.hash(value, unit);
51 public boolean equals(@Nullable Object obj) {
58 if (getClass() != obj.getClass()) {
61 Quantity other = (Quantity) obj;
62 return Double.doubleToLongBits(value) == Double.doubleToLongBits(other.value)
63 && Objects.equals(unit, other.unit);
67 public String toString() {
68 return "Quantity [value=" + value + ", unit=" + unit + "]";