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.verisure.internal.dto;
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.THING_TYPE_MICE_DETECTION;
17 import java.util.ArrayList;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.thing.ThingTypeUID;
25 * The Mice detection status of the Verisure System.
27 * @author Jan Gustafsson - Initial contribution
31 public class VerisureMiceDetectionDTO extends VerisureBaseThingDTO {
33 public static final int UNDEFINED = -1;
34 private double temperatureValue = UNDEFINED;
35 private @Nullable String temperatureTimestamp;
37 public double getTemperatureValue() {
38 return temperatureValue;
41 public void setTemperatureValue(double temperatureValue) {
42 this.temperatureValue = temperatureValue;
45 public @Nullable String getTemperatureTime() {
46 return temperatureTimestamp;
49 public void setTemperatureTime(@Nullable String temperatureTimestamp) {
50 this.temperatureTimestamp = temperatureTimestamp;
54 public ThingTypeUID getThingTypeUID() {
55 return THING_TYPE_MICE_DETECTION;
59 public int hashCode() {
61 int result = super.hashCode();
62 String localTemperatureTimestamp = temperatureTimestamp;
63 result = prime * result + ((localTemperatureTimestamp == null) ? 0 : localTemperatureTimestamp.hashCode());
65 temp = Double.doubleToLongBits(temperatureValue);
66 result = prime * result + (int) (temp ^ (temp >>> 32));
70 @SuppressWarnings("PMD.SimplifyBooleanReturns")
72 public boolean equals(@Nullable Object obj) {
76 if (!super.equals(obj)) {
82 if (getClass() != obj.getClass()) {
85 VerisureMiceDetectionDTO other = (VerisureMiceDetectionDTO) obj;
86 String localTemperatureTimestamp = temperatureTimestamp;
87 if (localTemperatureTimestamp == null) {
88 if (other.temperatureTimestamp != null) {
91 } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
94 if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
101 public String toString() {
102 return "VerisureMiceDetectionDTO [temperatureValue=" + temperatureValue + ", temperatureTimestamp="
103 + temperatureTimestamp + "]";
106 public static class Mouse {
108 private Device device = new Device();
109 private @Nullable Object type;
110 private List<Detection> detections = new ArrayList<>();
111 private @Nullable String typename;
113 public Device getDevice() {
117 public @Nullable Object getType() {
121 public List<Detection> getDetections() {
125 public @Nullable String getTypename() {
130 public int hashCode() {
131 final int prime = 31;
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());
143 public boolean equals(@Nullable Object obj) {
150 if (getClass() != obj.getClass()) {
153 Mouse other = (Mouse) obj;
154 if (!detections.equals(other.detections)) {
157 if (!device.equals(other.device)) {
160 Object localType = type;
161 if (localType == null) {
162 if (other.type != null) {
165 } else if (!localType.equals(other.type)) {
168 String localTypeName = typename;
169 if (localTypeName == null) {
170 if (other.typename != null) {
173 } else if (!localTypeName.equals(other.typename)) {
180 public String toString() {
181 return "Mouse [device=" + device + ", type=" + type + ", detections=" + detections + ", typename="
186 public static class Detection {
189 private @Nullable String gatewayTime;
190 private @Nullable String nodeTime;
191 private int duration;
192 private @Nullable String typename;
194 public int getCount() {
198 public @Nullable String getGatewayTime() {
202 public @Nullable String getNodeTime() {
206 public int getDuration() {
210 public @Nullable String getTypename() {
215 public int hashCode() {
216 final int prime = 31;
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());
230 public boolean equals(@Nullable Object obj) {
237 if (getClass() != obj.getClass()) {
240 Detection other = (Detection) obj;
241 if (count != other.count) {
244 if (duration != other.duration) {
247 String localGatewayTime = gatewayTime;
248 if (localGatewayTime == null) {
249 if (other.gatewayTime != null) {
252 } else if (!localGatewayTime.equals(other.gatewayTime)) {
255 String localNodeTime = nodeTime;
256 if (localNodeTime == null) {
257 if (other.nodeTime != null) {
260 } else if (!localNodeTime.equals(other.nodeTime)) {
263 String localTypeName = typename;
264 if (localTypeName == null) {
265 if (other.typename != null) {
268 } else if (!localTypeName.equals(other.typename)) {
275 public String toString() {
276 return "Detection [count=" + count + ", gatewayTime=" + gatewayTime + ", nodeTime=" + nodeTime
277 + ", duration=" + duration + ", typename=" + typename + "]";