]> git.basschouten.com Git - openhab-addons.git/blob
394a57773963e6f95a736bf91615dd056ebca231
[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_MICE_DETECTION;
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 Mice detection status of the Verisure System.
26  *
27  * @author Jan Gustafsson - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class VerisureMiceDetectionDTO extends VerisureBaseThingDTO {
32
33     public static final int UNDEFINED = -1;
34     private double temperatureValue = UNDEFINED;
35     private @Nullable String temperatureTimestamp;
36
37     public double getTemperatureValue() {
38         return temperatureValue;
39     }
40
41     public void setTemperatureValue(double temperatureValue) {
42         this.temperatureValue = temperatureValue;
43     }
44
45     public @Nullable String getTemperatureTime() {
46         return temperatureTimestamp;
47     }
48
49     public void setTemperatureTime(@Nullable String temperatureTimestamp) {
50         this.temperatureTimestamp = temperatureTimestamp;
51     }
52
53     @Override
54     public ThingTypeUID getThingTypeUID() {
55         return THING_TYPE_MICE_DETECTION;
56     }
57
58     @Override
59     public int hashCode() {
60         final int prime = 31;
61         int result = super.hashCode();
62         String localTemperatureTimestamp = temperatureTimestamp;
63         result = prime * result + ((localTemperatureTimestamp == null) ? 0 : localTemperatureTimestamp.hashCode());
64         long temp;
65         temp = Double.doubleToLongBits(temperatureValue);
66         result = prime * result + (int) (temp ^ (temp >>> 32));
67         return result;
68     }
69
70     @SuppressWarnings("PMD.SimplifyBooleanReturns")
71     @Override
72     public boolean equals(@Nullable Object obj) {
73         if (this == obj) {
74             return true;
75         }
76         if (!super.equals(obj)) {
77             return false;
78         }
79         if (obj == null) {
80             return false;
81         }
82         if (getClass() != obj.getClass()) {
83             return false;
84         }
85         VerisureMiceDetectionDTO other = (VerisureMiceDetectionDTO) obj;
86         String localTemperatureTimestamp = temperatureTimestamp;
87         if (localTemperatureTimestamp == null) {
88             if (other.temperatureTimestamp != null) {
89                 return false;
90             }
91         } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
92             return false;
93         }
94         if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
95             return false;
96         }
97         return true;
98     }
99
100     @Override
101     public String toString() {
102         return "VerisureMiceDetectionDTO [temperatureValue=" + temperatureValue + ", temperatureTimestamp="
103                 + temperatureTimestamp + "]";
104     }
105
106     public static class Mouse {
107
108         private Device device = new Device();
109         private @Nullable Object type;
110         private List<Detection> detections = new ArrayList<>();
111         private @Nullable String typename;
112
113         public Device getDevice() {
114             return device;
115         }
116
117         public @Nullable Object getType() {
118             return type;
119         }
120
121         public List<Detection> getDetections() {
122             return detections;
123         }
124
125         public @Nullable String getTypename() {
126             return typename;
127         }
128
129         @Override
130         public int hashCode() {
131             final int prime = 31;
132             int result = 1;
133             result = prime * result + detections.hashCode();
134             result = prime * result + device.hashCode();
135             Object localType = type;
136             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
137             String localTypeName = typename;
138             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
139             return result;
140         }
141
142         @Override
143         public boolean equals(@Nullable Object obj) {
144             if (this == obj) {
145                 return true;
146             }
147             if (obj == null) {
148                 return false;
149             }
150             if (getClass() != obj.getClass()) {
151                 return false;
152             }
153             Mouse other = (Mouse) obj;
154             if (!detections.equals(other.detections)) {
155                 return false;
156             }
157             if (!device.equals(other.device)) {
158                 return false;
159             }
160             Object 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             return true;
177         }
178
179         @Override
180         public String toString() {
181             return "Mouse [device=" + device + ", type=" + type + ", detections=" + detections + ", typename="
182                     + typename + "]";
183         }
184     }
185
186     public static class Detection {
187
188         private int count;
189         private @Nullable String gatewayTime;
190         private @Nullable String nodeTime;
191         private int duration;
192         private @Nullable String typename;
193
194         public int getCount() {
195             return count;
196         }
197
198         public @Nullable String getGatewayTime() {
199             return gatewayTime;
200         }
201
202         public @Nullable String getNodeTime() {
203             return nodeTime;
204         }
205
206         public int getDuration() {
207             return duration;
208         }
209
210         public @Nullable String getTypename() {
211             return typename;
212         }
213
214         @Override
215         public int hashCode() {
216             final int prime = 31;
217             int result = 1;
218             result = prime * result + count;
219             result = prime * result + duration;
220             String localGatewayTime = gatewayTime;
221             result = prime * result + ((localGatewayTime == null) ? 0 : localGatewayTime.hashCode());
222             String localNodeTime = nodeTime;
223             result = prime * result + ((localNodeTime == null) ? 0 : localNodeTime.hashCode());
224             String localTypeName = typename;
225             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
226             return result;
227         }
228
229         @Override
230         public boolean equals(@Nullable Object obj) {
231             if (this == obj) {
232                 return true;
233             }
234             if (obj == null) {
235                 return false;
236             }
237             if (getClass() != obj.getClass()) {
238                 return false;
239             }
240             Detection other = (Detection) obj;
241             if (count != other.count) {
242                 return false;
243             }
244             if (duration != other.duration) {
245                 return false;
246             }
247             String localGatewayTime = gatewayTime;
248             if (localGatewayTime == null) {
249                 if (other.gatewayTime != null) {
250                     return false;
251                 }
252             } else if (!localGatewayTime.equals(other.gatewayTime)) {
253                 return false;
254             }
255             String localNodeTime = nodeTime;
256             if (localNodeTime == null) {
257                 if (other.nodeTime != null) {
258                     return false;
259                 }
260             } else if (!localNodeTime.equals(other.nodeTime)) {
261                 return false;
262             }
263             String localTypeName = typename;
264             if (localTypeName == null) {
265                 if (other.typename != null) {
266                     return false;
267                 }
268             } else if (!localTypeName.equals(other.typename)) {
269                 return false;
270             }
271             return true;
272         }
273
274         @Override
275         public String toString() {
276             return "Detection [count=" + count + ", gatewayTime=" + gatewayTime + ", nodeTime=" + nodeTime
277                     + ", duration=" + duration + ", typename=" + typename + "]";
278         }
279     }
280 }