]> git.basschouten.com Git - openhab-addons.git/blob
6bbc8aeb38b1781fba6df30b6f96ba5742f6d142
[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     @Override
44     public boolean equals(@Nullable Object obj) {
45         if (this == obj) {
46             return true;
47         }
48         if (!super.equals(obj)) {
49             return false;
50         }
51         if (obj == null) {
52             return false;
53         }
54         if (getClass() != obj.getClass()) {
55             return false;
56         }
57         return true;
58     }
59
60     public static class ArmState {
61
62         private @Nullable String type;
63         private @Nullable String statusType;
64         private @Nullable String date;
65         private @Nullable String name;
66         private @Nullable String changedVia;
67         private boolean allowedForFirstLine;
68         private boolean allowed;
69         private List<Object> errorCodes = new ArrayList<>();
70         private @Nullable String typename;
71
72         public @Nullable String getType() {
73             return type;
74         }
75
76         public @Nullable String getStatusType() {
77             return statusType;
78         }
79
80         public void setStatusType(@Nullable String statusType) {
81             this.statusType = statusType;
82         }
83
84         public @Nullable String getDate() {
85             return date;
86         }
87
88         public @Nullable String getName() {
89             return name;
90         }
91
92         public @Nullable String getChangedVia() {
93             return changedVia;
94         }
95
96         public boolean getAllowedForFirstLine() {
97             return allowedForFirstLine;
98         }
99
100         public boolean getAllowed() {
101             return allowed;
102         }
103
104         public List<Object> getErrorCodes() {
105             return errorCodes;
106         }
107
108         public @Nullable String getTypename() {
109             return typename;
110         }
111
112         @Override
113         public int hashCode() {
114             final int prime = 31;
115             int result = 1;
116             result = prime * result + (allowed ? 1231 : 1237);
117             result = prime * result + (allowedForFirstLine ? 1231 : 1237);
118             String localChangedVia = changedVia;
119             result = prime * result + ((localChangedVia == null) ? 0 : localChangedVia.hashCode());
120             String localDate = date;
121             result = prime * result + ((localDate == null) ? 0 : localDate.hashCode());
122             result = prime * result + errorCodes.hashCode();
123             String localName = name;
124             result = prime * result + ((localName == null) ? 0 : localName.hashCode());
125             String localStatusType = statusType;
126             result = prime * result + ((localStatusType == null) ? 0 : localStatusType.hashCode());
127             String localType = type;
128             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
129             String localTypeName = typename;
130             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
131             return result;
132         }
133
134         @Override
135         public boolean equals(@Nullable Object obj) {
136             if (this == obj) {
137                 return true;
138             }
139             if (obj == null) {
140                 return false;
141             }
142             if (getClass() != obj.getClass()) {
143                 return false;
144             }
145             ArmState other = (ArmState) obj;
146             if (allowed != other.allowed) {
147                 return false;
148             }
149             if (allowedForFirstLine != other.allowedForFirstLine) {
150                 return false;
151             }
152             String localChangedVia = changedVia;
153             if (localChangedVia == null) {
154                 if (other.changedVia != null) {
155                     return false;
156                 }
157             } else if (!localChangedVia.equals(other.changedVia)) {
158                 return false;
159             }
160             String localdate = date;
161             if (localdate == null) {
162                 if (other.date != null) {
163                     return false;
164                 }
165             } else if (!localdate.equals(other.date)) {
166                 return false;
167             }
168             if (!errorCodes.equals(other.errorCodes)) {
169                 return false;
170             }
171             String localName = name;
172             if (localName == null) {
173                 if (other.name != null) {
174                     return false;
175                 }
176             } else if (!localName.equals(other.name)) {
177                 return false;
178             }
179             String localStatusType = statusType;
180             if (localStatusType == null) {
181                 if (other.statusType != null) {
182                     return false;
183                 }
184             } else if (!localStatusType.equals(other.statusType)) {
185                 return false;
186             }
187             String localType = type;
188             if (localType == null) {
189                 if (other.type != null) {
190                     return false;
191                 }
192             } else if (!localType.equals(other.type)) {
193                 return false;
194             }
195             String localTypeName = typename;
196             if (localTypeName == null) {
197                 if (other.typename != null) {
198                     return false;
199                 }
200             } else if (!localTypeName.equals(other.typename)) {
201                 return false;
202             }
203             return true;
204         }
205
206         @Override
207         public String toString() {
208             return "ArmState [type=" + type + ", statusType=" + statusType + ", date=" + date + ", name=" + name
209                     + ", changedVia=" + changedVia + ", allowedForFirstLine=" + allowedForFirstLine + ", allowed="
210                     + allowed + ", errorCodes=" + errorCodes + ", typename=" + typename + "]";
211         }
212     }
213 }