]> git.basschouten.com Git - openhab-addons.git/blob
e8d8d663a452e3e190e266fb14fa14507fbf1c5d
[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.verisure.internal.dto;
14
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.THING_TYPE_ALARM;
16
17 import java.util.ArrayList;
18 import java.util.List;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.thing.ThingTypeUID;
23
24 /**
25  * The alarms of the Verisure System.
26  *
27  * @author Jan Gustafsson - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class VerisureAlarmsDTO extends VerisureBaseThingDTO {
32
33     @Override
34     public ThingTypeUID getThingTypeUID() {
35         return THING_TYPE_ALARM;
36     }
37
38     @Override
39     public int hashCode() {
40         return super.hashCode();
41     }
42
43     @SuppressWarnings("PMD.SimplifyBooleanReturns")
44     @Override
45     public boolean equals(@Nullable Object obj) {
46         if (this == obj) {
47             return true;
48         }
49         if (!super.equals(obj)) {
50             return false;
51         }
52         if (obj == null) {
53             return false;
54         }
55         if (getClass() != obj.getClass()) {
56             return false;
57         }
58         return true;
59     }
60
61     public static class ArmState {
62
63         private @Nullable String type;
64         private @Nullable String statusType;
65         private @Nullable String date;
66         private @Nullable String name;
67         private @Nullable String changedVia;
68         private boolean allowedForFirstLine;
69         private boolean allowed;
70         private List<Object> errorCodes = new ArrayList<>();
71         private @Nullable String typename;
72
73         public @Nullable String getType() {
74             return type;
75         }
76
77         public @Nullable String getStatusType() {
78             return statusType;
79         }
80
81         public void setStatusType(@Nullable String statusType) {
82             this.statusType = statusType;
83         }
84
85         public @Nullable String getDate() {
86             return date;
87         }
88
89         public @Nullable String getName() {
90             return name;
91         }
92
93         public @Nullable String getChangedVia() {
94             return changedVia;
95         }
96
97         public boolean getAllowedForFirstLine() {
98             return allowedForFirstLine;
99         }
100
101         public boolean getAllowed() {
102             return allowed;
103         }
104
105         public List<Object> getErrorCodes() {
106             return errorCodes;
107         }
108
109         public @Nullable String getTypename() {
110             return typename;
111         }
112
113         @Override
114         public int hashCode() {
115             final int prime = 31;
116             int result = 1;
117             result = prime * result + (allowed ? 1231 : 1237);
118             result = prime * result + (allowedForFirstLine ? 1231 : 1237);
119             String localChangedVia = changedVia;
120             result = prime * result + ((localChangedVia == null) ? 0 : localChangedVia.hashCode());
121             String localDate = date;
122             result = prime * result + ((localDate == null) ? 0 : localDate.hashCode());
123             result = prime * result + errorCodes.hashCode();
124             String localName = name;
125             result = prime * result + ((localName == null) ? 0 : localName.hashCode());
126             String localStatusType = statusType;
127             result = prime * result + ((localStatusType == null) ? 0 : localStatusType.hashCode());
128             String localType = type;
129             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
130             String localTypeName = typename;
131             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
132             return result;
133         }
134
135         @Override
136         public boolean equals(@Nullable Object obj) {
137             if (this == obj) {
138                 return true;
139             }
140             if (obj == null) {
141                 return false;
142             }
143             if (getClass() != obj.getClass()) {
144                 return false;
145             }
146             ArmState other = (ArmState) obj;
147             if (allowed != other.allowed) {
148                 return false;
149             }
150             if (allowedForFirstLine != other.allowedForFirstLine) {
151                 return false;
152             }
153             String localChangedVia = changedVia;
154             if (localChangedVia == null) {
155                 if (other.changedVia != null) {
156                     return false;
157                 }
158             } else if (!localChangedVia.equals(other.changedVia)) {
159                 return false;
160             }
161             String localdate = date;
162             if (localdate == null) {
163                 if (other.date != null) {
164                     return false;
165                 }
166             } else if (!localdate.equals(other.date)) {
167                 return false;
168             }
169             if (!errorCodes.equals(other.errorCodes)) {
170                 return false;
171             }
172             String localName = name;
173             if (localName == null) {
174                 if (other.name != null) {
175                     return false;
176                 }
177             } else if (!localName.equals(other.name)) {
178                 return false;
179             }
180             String localStatusType = statusType;
181             if (localStatusType == null) {
182                 if (other.statusType != null) {
183                     return false;
184                 }
185             } else if (!localStatusType.equals(other.statusType)) {
186                 return false;
187             }
188             String localType = type;
189             if (localType == null) {
190                 if (other.type != null) {
191                     return false;
192                 }
193             } else if (!localType.equals(other.type)) {
194                 return false;
195             }
196             String localTypeName = typename;
197             if (localTypeName == null) {
198                 if (other.typename != null) {
199                     return false;
200                 }
201             } else if (!localTypeName.equals(other.typename)) {
202                 return false;
203             }
204             return true;
205         }
206
207         @Override
208         public String toString() {
209             return "ArmState [type=" + type + ", statusType=" + statusType + ", date=" + date + ", name=" + name
210                     + ", changedVia=" + changedVia + ", allowedForFirstLine=" + allowedForFirstLine + ", allowed="
211                     + allowed + ", errorCodes=" + errorCodes + ", typename=" + typename + "]";
212         }
213     }
214 }