]> git.basschouten.com Git - openhab-addons.git/blob
f90cfd20715699f4d7d1b36b43b2d23936c3480c
[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.mielecloud.internal.webservice.api.json;
14
15 import java.util.Objects;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * Immutable POJO representing the amount of water and energy used by the current running program up to the present
23  * moment. Queried from the Miele REST API.
24  *
25  * @author Björn Lange - Initial contribution
26  */
27 @NonNullByDefault
28 public class EcoFeedback {
29     @Nullable
30     private WaterConsumption currentWaterConsumption;
31     @Nullable
32     private EnergyConsumption currentEnergyConsumption;
33     @Nullable
34     private Double waterForecast;
35     @Nullable
36     private Double energyForecast;
37
38     public Optional<WaterConsumption> getCurrentWaterConsumption() {
39         return Optional.ofNullable(currentWaterConsumption);
40     }
41
42     public Optional<EnergyConsumption> getCurrentEnergyConsumption() {
43         return Optional.ofNullable(currentEnergyConsumption);
44     }
45
46     /**
47      * Gets the relative water usage for the selected program from 0 to 1.
48      */
49     public Optional<Double> getWaterForecast() {
50         return Optional.ofNullable(waterForecast);
51     }
52
53     /**
54      * Gets the relative energy usage for the selected program from 0 to 1.
55      */
56     public Optional<Double> getEnergyForecast() {
57         return Optional.ofNullable(energyForecast);
58     }
59
60     @Override
61     public int hashCode() {
62         return Objects.hash(currentWaterConsumption, currentEnergyConsumption, waterForecast, energyForecast);
63     }
64
65     @Override
66     public boolean equals(@Nullable Object obj) {
67         if (this == obj) {
68             return true;
69         }
70         if (obj == null) {
71             return false;
72         }
73         if (getClass() != obj.getClass()) {
74             return false;
75         }
76         EcoFeedback other = (EcoFeedback) obj;
77         return Objects.equals(currentWaterConsumption, other.currentWaterConsumption)
78                 && Objects.equals(currentEnergyConsumption, other.currentEnergyConsumption)
79                 && Objects.equals(waterForecast, other.waterForecast)
80                 && Objects.equals(energyForecast, other.energyForecast);
81     }
82
83     @Override
84     public String toString() {
85         return "EcoFeedback [currentWaterConsumption=" + currentWaterConsumption + ", currentEnergyConsumption="
86                 + currentEnergyConsumption + ", waterForecast=" + waterForecast + ", energyForecast=" + energyForecast
87                 + "]";
88     }
89 }