]> git.basschouten.com Git - openhab-addons.git/blob
81a3d91172a2fb56a6f8f28cd360c1c3df0d2e84
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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_DOORWINDOW;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.ThingTypeUID;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The door and window devices of the Verisure System.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class VerisureDoorWindowsDTO extends VerisureBaseThingDTO {
31
32     private @Nullable VerisureBatteryStatusDTO batteryStatus;
33
34     public @Nullable VerisureBatteryStatusDTO getBatteryStatus() {
35         return batteryStatus;
36     }
37
38     public void setBatteryStatus(@Nullable VerisureBatteryStatusDTO batteryStatus) {
39         this.batteryStatus = batteryStatus;
40     }
41
42     @Override
43     public ThingTypeUID getThingTypeUID() {
44         return THING_TYPE_DOORWINDOW;
45     }
46
47     @Override
48     public int hashCode() {
49         return super.hashCode();
50     }
51
52     @Override
53     public boolean equals(@Nullable Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (!super.equals(obj)) {
58             return false;
59         }
60         if (obj == null) {
61             return false;
62         }
63         if (getClass() != obj.getClass()) {
64             return false;
65         }
66         VerisureDoorWindowsDTO other = (VerisureDoorWindowsDTO) obj;
67         VerisureBatteryStatusDTO localBatteryStatusJSON = batteryStatus;
68         if (localBatteryStatusJSON == null) {
69             if (other.batteryStatus != null) {
70                 return false;
71             }
72         } else if (!localBatteryStatusJSON.equals(other.batteryStatus)) {
73             return false;
74         }
75         return true;
76     }
77
78     public static class DoorWindow {
79
80         private Device device = new Device();
81         private @Nullable String type;
82         private @Nullable String state;
83         private boolean wired;
84         private @Nullable String reportTime;
85         @SerializedName("__typename")
86         private @Nullable String typename;
87
88         public Device getDevice() {
89             return device;
90         }
91
92         public @Nullable String getType() {
93             return type;
94         }
95
96         public @Nullable String getState() {
97             return state;
98         }
99
100         public boolean getWired() {
101             return wired;
102         }
103
104         public @Nullable String getReportTime() {
105             return reportTime;
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 + device.hashCode();
117             String localReportTime = reportTime;
118             result = prime * result + ((localReportTime == null) ? 0 : localReportTime.hashCode());
119             String localState = state;
120             result = prime * result + ((localState == null) ? 0 : localState.hashCode());
121             String localType = type;
122             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
123             String localTypeName = typename;
124             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
125             result = prime * result + (wired ? 1231 : 1237);
126             return result;
127         }
128
129         @Override
130         public boolean equals(@Nullable Object obj) {
131             if (this == obj) {
132                 return true;
133             }
134             if (obj == null) {
135                 return false;
136             }
137             if (getClass() != obj.getClass()) {
138                 return false;
139             }
140             DoorWindow other = (DoorWindow) obj;
141             if (!device.equals(other.device)) {
142                 return false;
143             }
144             String localReportTime = reportTime;
145             if (localReportTime == null) {
146                 if (other.reportTime != null) {
147                     return false;
148                 }
149             } else if (!localReportTime.equals(other.reportTime)) {
150                 return false;
151             }
152             String localState = state;
153             if (localState == null) {
154                 if (other.state != null) {
155                     return false;
156                 }
157             } else if (!localState.equals(other.state)) {
158                 return false;
159             }
160             String localType = type;
161             if (localType == null) {
162                 if (other.type != null) {
163                     return false;
164                 }
165             } else if (!localType.equals(other.type)) {
166                 return false;
167             }
168             String localTypeName = typename;
169             if (localTypeName == null) {
170                 if (other.typename != null) {
171                     return false;
172                 }
173             } else if (!localTypeName.equals(other.typename)) {
174                 return false;
175             }
176             if (wired != other.wired) {
177                 return false;
178             }
179             return true;
180         }
181
182         @Override
183         public String toString() {
184             return "DoorWindow [device=" + device + ", type=" + type + ", state=" + state + ", wired=" + wired
185                     + ", reportTime=" + reportTime + ", typename=" + typename + "]";
186         }
187     }
188 }