]> git.basschouten.com Git - openhab-addons.git/blob
7c5c1d7a3e065e311b6128ea2f517c0936f421c2
[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 device identification queried from the Miele REST API.
23  *
24  * @author Björn Lange - Initial contribution
25  */
26 @NonNullByDefault
27 public class Ident {
28     @Nullable
29     private Type type;
30     @Nullable
31     private String deviceName;
32     @Nullable
33     private DeviceIdentLabel deviceIdentLabel;
34     @Nullable
35     private XkmIdentLabel xkmIdentLabel;
36
37     public Optional<Type> getType() {
38         return Optional.ofNullable(type);
39     }
40
41     public Optional<String> getDeviceName() {
42         return Optional.ofNullable(deviceName);
43     }
44
45     public Optional<DeviceIdentLabel> getDeviceIdentLabel() {
46         return Optional.ofNullable(deviceIdentLabel);
47     }
48
49     public Optional<XkmIdentLabel> getXkmIdentLabel() {
50         return Optional.ofNullable(xkmIdentLabel);
51     }
52
53     @Override
54     public int hashCode() {
55         return Objects.hash(deviceIdentLabel, deviceName, type, xkmIdentLabel);
56     }
57
58     @Override
59     public boolean equals(@Nullable Object obj) {
60         if (this == obj) {
61             return true;
62         }
63         if (obj == null) {
64             return false;
65         }
66         if (getClass() != obj.getClass()) {
67             return false;
68         }
69         Ident other = (Ident) obj;
70         return Objects.equals(deviceIdentLabel, other.deviceIdentLabel) && Objects.equals(deviceName, other.deviceName)
71                 && Objects.equals(type, other.type) && Objects.equals(xkmIdentLabel, other.xkmIdentLabel);
72     }
73
74     @Override
75     public String toString() {
76         return "Ident [type=" + type + ", deviceName=" + deviceName + ", deviceIdentLabel=" + deviceIdentLabel
77                 + ", xkmIdentLabel=" + xkmIdentLabel + "]";
78     }
79 }