]> git.basschouten.com Git - openhab-addons.git/blob
d7026e20f1093617b31b0b564ae61600d2fd1fa7
[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     @Override
71     public boolean equals(@Nullable Object obj) {
72         if (this == obj) {
73             return true;
74         }
75         if (!super.equals(obj)) {
76             return false;
77         }
78         if (obj == null) {
79             return false;
80         }
81         if (getClass() != obj.getClass()) {
82             return false;
83         }
84         VerisureMiceDetectionDTO other = (VerisureMiceDetectionDTO) obj;
85         String localTemperatureTimestamp = temperatureTimestamp;
86         if (localTemperatureTimestamp == null) {
87             if (other.temperatureTimestamp != null) {
88                 return false;
89             }
90         } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
91             return false;
92         }
93         if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
94             return false;
95         }
96         return true;
97     }
98
99     @Override
100     public String toString() {
101         return "VerisureMiceDetectionDTO [temperatureValue=" + temperatureValue + ", temperatureTimestamp="
102                 + temperatureTimestamp + "]";
103     }
104
105     public static class Mouse {
106
107         private Device device = new Device();
108         private @Nullable Object type;
109         private List<Detection> detections = new ArrayList<>();
110         private @Nullable String typename;
111
112         public Device getDevice() {
113             return device;
114         }
115
116         public @Nullable Object getType() {
117             return type;
118         }
119
120         public List<Detection> getDetections() {
121             return detections;
122         }
123
124         public @Nullable String getTypename() {
125             return typename;
126         }
127
128         @Override
129         public int hashCode() {
130             final int prime = 31;
131             int result = 1;
132             result = prime * result + detections.hashCode();
133             result = prime * result + device.hashCode();
134             Object localType = type;
135             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
136             String localTypeName = typename;
137             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
138             return result;
139         }
140
141         @Override
142         public boolean equals(@Nullable Object obj) {
143             if (this == obj) {
144                 return true;
145             }
146             if (obj == null) {
147                 return false;
148             }
149             if (getClass() != obj.getClass()) {
150                 return false;
151             }
152             Mouse other = (Mouse) obj;
153             if (!detections.equals(other.detections)) {
154                 return false;
155             }
156             if (!device.equals(other.device)) {
157                 return false;
158             }
159             Object localType = type;
160             if (localType == null) {
161                 if (other.type != null) {
162                     return false;
163                 }
164             } else if (!localType.equals(other.type)) {
165                 return false;
166             }
167             String localTypeName = typename;
168             if (localTypeName == null) {
169                 if (other.typename != null) {
170                     return false;
171                 }
172             } else if (!localTypeName.equals(other.typename)) {
173                 return false;
174             }
175             return true;
176         }
177
178         @Override
179         public String toString() {
180             return "Mouse [device=" + device + ", type=" + type + ", detections=" + detections + ", typename="
181                     + typename + "]";
182         }
183     }
184
185     public static class Detection {
186
187         private int count;
188         private @Nullable String gatewayTime;
189         private @Nullable String nodeTime;
190         private int duration;
191         private @Nullable String typename;
192
193         public int getCount() {
194             return count;
195         }
196
197         public @Nullable String getGatewayTime() {
198             return gatewayTime;
199         }
200
201         public @Nullable String getNodeTime() {
202             return nodeTime;
203         }
204
205         public int getDuration() {
206             return duration;
207         }
208
209         public @Nullable String getTypename() {
210             return typename;
211         }
212
213         @Override
214         public int hashCode() {
215             final int prime = 31;
216             int result = 1;
217             result = prime * result + count;
218             result = prime * result + duration;
219             String localGatewayTime = gatewayTime;
220             result = prime * result + ((localGatewayTime == null) ? 0 : localGatewayTime.hashCode());
221             String localNodeTime = nodeTime;
222             result = prime * result + ((localNodeTime == null) ? 0 : localNodeTime.hashCode());
223             String localTypeName = typename;
224             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
225             return result;
226         }
227
228         @Override
229         public boolean equals(@Nullable Object obj) {
230             if (this == obj) {
231                 return true;
232             }
233             if (obj == null) {
234                 return false;
235             }
236             if (getClass() != obj.getClass()) {
237                 return false;
238             }
239             Detection other = (Detection) obj;
240             if (count != other.count) {
241                 return false;
242             }
243             if (duration != other.duration) {
244                 return false;
245             }
246             String localGatewayTime = gatewayTime;
247             if (localGatewayTime == null) {
248                 if (other.gatewayTime != null) {
249                     return false;
250                 }
251             } else if (!localGatewayTime.equals(other.gatewayTime)) {
252                 return false;
253             }
254             String localNodeTime = nodeTime;
255             if (localNodeTime == null) {
256                 if (other.nodeTime != null) {
257                     return false;
258                 }
259             } else if (!localNodeTime.equals(other.nodeTime)) {
260                 return false;
261             }
262             String localTypeName = typename;
263             if (localTypeName == null) {
264                 if (other.typename != null) {
265                     return false;
266                 }
267             } else if (!localTypeName.equals(other.typename)) {
268                 return false;
269             }
270             return true;
271         }
272
273         @Override
274         public String toString() {
275             return "Detection [count=" + count + ", gatewayTime=" + gatewayTime + ", nodeTime=" + nodeTime
276                     + ", duration=" + duration + ", typename=" + typename + "]";
277         }
278     }
279 }