]> git.basschouten.com Git - openhab-addons.git/blob
b32af3c885bafe08915d8f40d1c380facdecad5a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * Immutable POJO representing the type of a device. Queried from the Miele REST API.
25  *
26  * @author Björn Lange - Initial contribution
27  */
28 @NonNullByDefault
29 public class Type {
30     @SerializedName("key_localized")
31     @Nullable
32     private String keyLocalized;
33     @SerializedName("value_raw")
34     @Nullable
35     private DeviceType valueRaw;
36     @SerializedName("value_localized")
37     @Nullable
38     private String valueLocalized;
39
40     public Optional<String> getKeyLocalized() {
41         return Optional.ofNullable(keyLocalized);
42     }
43
44     public DeviceType getValueRaw() {
45         return Optional.ofNullable(valueRaw).orElse(DeviceType.UNKNOWN);
46     }
47
48     public Optional<String> getValueLocalized() {
49         return Optional.ofNullable(valueLocalized);
50     }
51
52     @Override
53     public int hashCode() {
54         return Objects.hash(keyLocalized, valueLocalized, valueRaw);
55     }
56
57     @Override
58     public boolean equals(@Nullable Object obj) {
59         if (this == obj) {
60             return true;
61         }
62         if (obj == null) {
63             return false;
64         }
65         if (getClass() != obj.getClass()) {
66             return false;
67         }
68         Type other = (Type) obj;
69         return Objects.equals(keyLocalized, other.keyLocalized) && Objects.equals(valueLocalized, other.valueLocalized)
70                 && valueRaw == other.valueRaw;
71     }
72
73     @Override
74     public String toString() {
75         return "Type [keyLocalized=" + keyLocalized + ", valueRaw=" + valueRaw + ", valueLocalized=" + valueLocalized
76                 + "]";
77     }
78 }