2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.nest.internal.wwn.dto;
15 import java.util.Date;
16 import java.util.List;
19 import org.openhab.binding.nest.internal.wwn.dto.WWNSmokeDetector.AlarmState;
21 import com.google.gson.annotations.SerializedName;
24 * The WWN structure details.
26 * @author David Bennett - Initial contribution
27 * @author Wouter Born - Add equals and hashCode methods
29 public class WWNStructure implements WWNIdentifiable {
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;
48 private SecurityState wwnSecurityState;
51 public String getId() {
55 public HomeAwayState getAway() {
59 public void setAway(HomeAwayState away) {
63 public String getStructureId() {
67 public List<String> getThermostats() {
71 public List<String> getSmokeCoAlarms() {
75 public List<String> getCameras() {
79 public String getCountryCode() {
83 public String getPostalCode() {
87 public Date getPeakPeriodStartTime() {
88 return peakPeriodStartTime;
91 public Date getPeakPeriodEndTime() {
92 return peakPeriodEndTime;
95 public String getTimeZone() {
99 public Date getEtaBegin() {
103 public AlarmState getCoAlarmState() {
107 public AlarmState getSmokeAlarmState() {
108 return smokeAlarmState;
111 public Boolean isRhrEnrollment() {
112 return rhrEnrollment;
115 public Map<String, WWNWhere> getWheres() {
119 public WWNETA getEta() {
123 public String getName() {
127 public SecurityState getWwnSecurityState() {
128 return wwnSecurityState;
131 public enum HomeAwayState {
132 @SerializedName("home")
134 @SerializedName("away")
136 @SerializedName("unknown")
140 public enum SecurityState {
141 @SerializedName("ok")
143 @SerializedName("deter")
148 public boolean equals(Object obj) {
155 if (getClass() != obj.getClass()) {
158 WWNStructure other = (WWNStructure) obj;
159 if (away != other.away) {
162 if (cameras == null) {
163 if (other.cameras != null) {
166 } else if (!cameras.equals(other.cameras)) {
169 if (coAlarmState != other.coAlarmState) {
172 if (countryCode == null) {
173 if (other.countryCode != null) {
176 } else if (!countryCode.equals(other.countryCode)) {
180 if (other.eta != null) {
183 } else if (!eta.equals(other.eta)) {
186 if (etaBegin == null) {
187 if (other.etaBegin != null) {
190 } else if (!etaBegin.equals(other.etaBegin)) {
194 if (other.name != null) {
197 } else if (!name.equals(other.name)) {
200 if (peakPeriodEndTime == null) {
201 if (other.peakPeriodEndTime != null) {
204 } else if (!peakPeriodEndTime.equals(other.peakPeriodEndTime)) {
207 if (peakPeriodStartTime == null) {
208 if (other.peakPeriodStartTime != null) {
211 } else if (!peakPeriodStartTime.equals(other.peakPeriodStartTime)) {
214 if (postalCode == null) {
215 if (other.postalCode != null) {
218 } else if (!postalCode.equals(other.postalCode)) {
221 if (rhrEnrollment == null) {
222 if (other.rhrEnrollment != null) {
225 } else if (!rhrEnrollment.equals(other.rhrEnrollment)) {
228 if (smokeAlarmState != other.smokeAlarmState) {
231 if (smokeCoAlarms == null) {
232 if (other.smokeCoAlarms != null) {
235 } else if (!smokeCoAlarms.equals(other.smokeCoAlarms)) {
238 if (structureId == null) {
239 if (other.structureId != null) {
242 } else if (!structureId.equals(other.structureId)) {
245 if (thermostats == null) {
246 if (other.thermostats != null) {
249 } else if (!thermostats.equals(other.thermostats)) {
252 if (timeZone == null) {
253 if (other.timeZone != null) {
256 } else if (!timeZone.equals(other.timeZone)) {
259 if (wheres == null) {
260 if (other.wheres != null) {
263 } else if (!wheres.equals(other.wheres)) {
266 return wwnSecurityState == other.wwnSecurityState;
270 public int hashCode() {
271 final int prime = 31;
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());
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();