]> git.basschouten.com Git - openhab-addons.git/blob
aa95995e64ca1d3b0b55541ca3d248de1dd4dfd3
[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 an amount of consumed water. Queried from the Miele REST API.
23  *
24  * @author Björn Lange - Initial contribution
25  */
26 @NonNullByDefault
27 public class WaterConsumption {
28     @Nullable
29     private String unit;
30     @Nullable
31     private Double value;
32
33     /**
34      * Gets the measurement unit which represents a volume.
35      */
36     public Optional<String> getUnit() {
37         return Optional.ofNullable(unit);
38     }
39
40     /**
41      * Gets the amount of water.
42      */
43     public Optional<Double> getValue() {
44         return Optional.ofNullable(value);
45     }
46
47     @Override
48     public int hashCode() {
49         return Objects.hash(unit, value);
50     }
51
52     @Override
53     public boolean equals(@Nullable Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         WaterConsumption other = (WaterConsumption) obj;
64         return Objects.equals(unit, other.unit) && Objects.equals(value, other.value);
65     }
66
67     @Override
68     public String toString() {
69         return "WaterConsumption [unit=" + unit + ", value=" + value + "]";
70     }
71 }