]> git.basschouten.com Git - openhab-addons.git/blob
3fa70307e9f047b5a0e0f8546d85920c804889fb
[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.Collections;
16 import java.util.List;
17 import java.util.Objects;
18 import java.util.Optional;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22
23 /**
24  * Immutable POJO representing the full device identification queried from the Miele REST API.
25  *
26  * @author Björn Lange - Initial contribution
27  */
28 @NonNullByDefault
29 public class DeviceIdentLabel {
30     @Nullable
31     private String fabNumber;
32     @Nullable
33     private String fabIndex;
34     @Nullable
35     private String techType;
36     @Nullable
37     private String matNumber;
38     @Nullable
39     private final List<String> swids = null;
40
41     public Optional<String> getFabNumber() {
42         return Optional.ofNullable(fabNumber);
43     }
44
45     public Optional<String> getFabIndex() {
46         return Optional.ofNullable(fabIndex);
47     }
48
49     public Optional<String> getTechType() {
50         return Optional.ofNullable(techType);
51     }
52
53     public Optional<String> getMatNumber() {
54         return Optional.ofNullable(matNumber);
55     }
56
57     public List<String> getSwids() {
58         if (swids == null) {
59             return Collections.emptyList();
60         }
61
62         return Collections.unmodifiableList(swids);
63     }
64
65     @Override
66     public int hashCode() {
67         return Objects.hash(fabIndex, fabNumber, matNumber, swids, techType);
68     }
69
70     @Override
71     public boolean equals(@Nullable Object obj) {
72         if (this == obj) {
73             return true;
74         }
75         if (obj == null) {
76             return false;
77         }
78         if (getClass() != obj.getClass()) {
79             return false;
80         }
81         DeviceIdentLabel other = (DeviceIdentLabel) obj;
82         return Objects.equals(fabIndex, other.fabIndex) && Objects.equals(fabNumber, other.fabNumber)
83                 && Objects.equals(matNumber, other.matNumber) && Objects.equals(swids, other.swids)
84                 && Objects.equals(techType, other.techType);
85     }
86
87     @Override
88     public String toString() {
89         return "DeviceIdentLabel [fabNumber=" + fabNumber + ", fabIndex=" + fabIndex + ", techType=" + techType
90                 + ", matNumber=" + matNumber + ", swids=" + swids + "]";
91     }
92 }