]> git.basschouten.com Git - openhab-addons.git/blob
2735df38f92c0b89bf43122840aba94dd303a594
[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.nest.internal.wwn.dto;
14
15 import java.util.Date;
16 import java.util.List;
17 import java.util.Map;
18
19 import org.openhab.binding.nest.internal.wwn.dto.WWNSmokeDetector.AlarmState;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The WWN structure details.
25  *
26  * @author David Bennett - Initial contribution
27  * @author Wouter Born - Add equals and hashCode methods
28  */
29 public class WWNStructure implements WWNIdentifiable {
30
31     private String structureId;
32     private List<String> thermostats;
33     private List<String> smokeCoAlarms;
34     private List<String> cameras;
35     private String countryCode;
36     private String postalCode;
37     private Date peakPeriodStartTime;
38     private Date peakPeriodEndTime;
39     private String timeZone;
40     private Date etaBegin;
41     private WWNSmokeDetector.AlarmState coAlarmState;
42     private WWNSmokeDetector.AlarmState smokeAlarmState;
43     private Boolean rhrEnrollment;
44     private Map<String, WWNWhere> wheres;
45     private HomeAwayState away;
46     private String name;
47     private WWNETA eta;
48     private SecurityState wwnSecurityState;
49
50     @Override
51     public String getId() {
52         return structureId;
53     }
54
55     public HomeAwayState getAway() {
56         return away;
57     }
58
59     public void setAway(HomeAwayState away) {
60         this.away = away;
61     }
62
63     public String getStructureId() {
64         return structureId;
65     }
66
67     public List<String> getThermostats() {
68         return thermostats;
69     }
70
71     public List<String> getSmokeCoAlarms() {
72         return smokeCoAlarms;
73     }
74
75     public List<String> getCameras() {
76         return cameras;
77     }
78
79     public String getCountryCode() {
80         return countryCode;
81     }
82
83     public String getPostalCode() {
84         return postalCode;
85     }
86
87     public Date getPeakPeriodStartTime() {
88         return peakPeriodStartTime;
89     }
90
91     public Date getPeakPeriodEndTime() {
92         return peakPeriodEndTime;
93     }
94
95     public String getTimeZone() {
96         return timeZone;
97     }
98
99     public Date getEtaBegin() {
100         return etaBegin;
101     }
102
103     public AlarmState getCoAlarmState() {
104         return coAlarmState;
105     }
106
107     public AlarmState getSmokeAlarmState() {
108         return smokeAlarmState;
109     }
110
111     public Boolean isRhrEnrollment() {
112         return rhrEnrollment;
113     }
114
115     public Map<String, WWNWhere> getWheres() {
116         return wheres;
117     }
118
119     public WWNETA getEta() {
120         return eta;
121     }
122
123     public String getName() {
124         return name;
125     }
126
127     public SecurityState getWwnSecurityState() {
128         return wwnSecurityState;
129     }
130
131     public enum HomeAwayState {
132         @SerializedName("home")
133         HOME,
134         @SerializedName("away")
135         AWAY,
136         @SerializedName("unknown")
137         UNKNOWN
138     }
139
140     public enum SecurityState {
141         @SerializedName("ok")
142         OK,
143         @SerializedName("deter")
144         DETER
145     }
146
147     @Override
148     public boolean equals(Object obj) {
149         if (this == obj) {
150             return true;
151         }
152         if (obj == null) {
153             return false;
154         }
155         if (getClass() != obj.getClass()) {
156             return false;
157         }
158         WWNStructure other = (WWNStructure) obj;
159         if (away != other.away) {
160             return false;
161         }
162         if (cameras == null) {
163             if (other.cameras != null) {
164                 return false;
165             }
166         } else if (!cameras.equals(other.cameras)) {
167             return false;
168         }
169         if (coAlarmState != other.coAlarmState) {
170             return false;
171         }
172         if (countryCode == null) {
173             if (other.countryCode != null) {
174                 return false;
175             }
176         } else if (!countryCode.equals(other.countryCode)) {
177             return false;
178         }
179         if (eta == null) {
180             if (other.eta != null) {
181                 return false;
182             }
183         } else if (!eta.equals(other.eta)) {
184             return false;
185         }
186         if (etaBegin == null) {
187             if (other.etaBegin != null) {
188                 return false;
189             }
190         } else if (!etaBegin.equals(other.etaBegin)) {
191             return false;
192         }
193         if (name == null) {
194             if (other.name != null) {
195                 return false;
196             }
197         } else if (!name.equals(other.name)) {
198             return false;
199         }
200         if (peakPeriodEndTime == null) {
201             if (other.peakPeriodEndTime != null) {
202                 return false;
203             }
204         } else if (!peakPeriodEndTime.equals(other.peakPeriodEndTime)) {
205             return false;
206         }
207         if (peakPeriodStartTime == null) {
208             if (other.peakPeriodStartTime != null) {
209                 return false;
210             }
211         } else if (!peakPeriodStartTime.equals(other.peakPeriodStartTime)) {
212             return false;
213         }
214         if (postalCode == null) {
215             if (other.postalCode != null) {
216                 return false;
217             }
218         } else if (!postalCode.equals(other.postalCode)) {
219             return false;
220         }
221         if (rhrEnrollment == null) {
222             if (other.rhrEnrollment != null) {
223                 return false;
224             }
225         } else if (!rhrEnrollment.equals(other.rhrEnrollment)) {
226             return false;
227         }
228         if (smokeAlarmState != other.smokeAlarmState) {
229             return false;
230         }
231         if (smokeCoAlarms == null) {
232             if (other.smokeCoAlarms != null) {
233                 return false;
234             }
235         } else if (!smokeCoAlarms.equals(other.smokeCoAlarms)) {
236             return false;
237         }
238         if (structureId == null) {
239             if (other.structureId != null) {
240                 return false;
241             }
242         } else if (!structureId.equals(other.structureId)) {
243             return false;
244         }
245         if (thermostats == null) {
246             if (other.thermostats != null) {
247                 return false;
248             }
249         } else if (!thermostats.equals(other.thermostats)) {
250             return false;
251         }
252         if (timeZone == null) {
253             if (other.timeZone != null) {
254                 return false;
255             }
256         } else if (!timeZone.equals(other.timeZone)) {
257             return false;
258         }
259         if (wheres == null) {
260             if (other.wheres != null) {
261                 return false;
262             }
263         } else if (!wheres.equals(other.wheres)) {
264             return false;
265         }
266         return wwnSecurityState == other.wwnSecurityState;
267     }
268
269     @Override
270     public int hashCode() {
271         final int prime = 31;
272         int result = 1;
273         result = prime * result + ((away == null) ? 0 : away.hashCode());
274         result = prime * result + ((cameras == null) ? 0 : cameras.hashCode());
275         result = prime * result + ((coAlarmState == null) ? 0 : coAlarmState.hashCode());
276         result = prime * result + ((countryCode == null) ? 0 : countryCode.hashCode());
277         result = prime * result + ((eta == null) ? 0 : eta.hashCode());
278         result = prime * result + ((etaBegin == null) ? 0 : etaBegin.hashCode());
279         result = prime * result + ((name == null) ? 0 : name.hashCode());
280         result = prime * result + ((peakPeriodEndTime == null) ? 0 : peakPeriodEndTime.hashCode());
281         result = prime * result + ((peakPeriodStartTime == null) ? 0 : peakPeriodStartTime.hashCode());
282         result = prime * result + ((postalCode == null) ? 0 : postalCode.hashCode());
283         result = prime * result + ((rhrEnrollment == null) ? 0 : rhrEnrollment.hashCode());
284         result = prime * result + ((smokeAlarmState == null) ? 0 : smokeAlarmState.hashCode());
285         result = prime * result + ((smokeCoAlarms == null) ? 0 : smokeCoAlarms.hashCode());
286         result = prime * result + ((structureId == null) ? 0 : structureId.hashCode());
287         result = prime * result + ((thermostats == null) ? 0 : thermostats.hashCode());
288         result = prime * result + ((timeZone == null) ? 0 : timeZone.hashCode());
289         result = prime * result + ((wheres == null) ? 0 : wheres.hashCode());
290         result = prime * result + ((wwnSecurityState == null) ? 0 : wwnSecurityState.hashCode());
291         return result;
292     }
293
294     @Override
295     public String toString() {
296         StringBuilder builder = new StringBuilder();
297         builder.append("Structure [structureId=").append(structureId).append(", thermostats=").append(thermostats)
298                 .append(", smokeCoAlarms=").append(smokeCoAlarms).append(", cameras=").append(cameras)
299                 .append(", countryCode=").append(countryCode).append(", postalCode=").append(postalCode)
300                 .append(", peakPeriodStartTime=").append(peakPeriodStartTime).append(", peakPeriodEndTime=")
301                 .append(peakPeriodEndTime).append(", timeZone=").append(timeZone).append(", etaBegin=").append(etaBegin)
302                 .append(", coAlarmState=").append(coAlarmState).append(", smokeAlarmState=").append(smokeAlarmState)
303                 .append(", rhrEnrollment=").append(rhrEnrollment).append(", wheres=").append(wheres).append(", away=")
304                 .append(away).append(", name=").append(name).append(", eta=").append(eta).append(", wwnSecurityState=")
305                 .append(wwnSecurityState).append("]");
306         return builder.toString();
307     }
308 }