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;
22 * Immutable POJO representing an amount of consumed energy. Queried from the Miele REST API.
24 * @author Björn Lange - Initial contribution
27 public class EnergyConsumption {
34 * Gets the measurement unit which represents energy.
36 public Optional<String> getUnit() {
37 return Optional.ofNullable(unit);
41 * Gets the amount of energy.
43 public Optional<Double> getValue() {
44 return Optional.ofNullable(value);
48 public int hashCode() {
49 return Objects.hash(unit, value);
53 public boolean equals(@Nullable Object obj) {
60 if (getClass() != obj.getClass()) {
63 EnergyConsumption other = (EnergyConsumption) obj;
64 return Objects.equals(unit, other.unit) && Objects.equals(value, other.value);
68 public String toString() {
69 return "EnergyConsumption [unit=" + unit + ", value=" + value + "]";