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));
71 public boolean equals(@Nullable Object obj) {
75 if (!super.equals(obj)) {
81 if (getClass() != obj.getClass()) {
84 VerisureMiceDetectionDTO other = (VerisureMiceDetectionDTO) obj;
85 String localTemperatureTimestamp = temperatureTimestamp;
86 if (localTemperatureTimestamp == null) {
87 if (other.temperatureTimestamp != null) {
90 } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
93 if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
100 public String toString() {
101 return "VerisureMiceDetectionDTO [temperatureValue=" + temperatureValue + ", temperatureTimestamp="
102 + temperatureTimestamp + "]";
105 public static class Mouse {
107 private Device device = new Device();
108 private @Nullable Object type;
109 private List<Detection> detections = new ArrayList<>();
110 private @Nullable String typename;
112 public Device getDevice() {
116 public @Nullable Object getType() {
120 public List<Detection> getDetections() {
124 public @Nullable String getTypename() {
129 public int hashCode() {
130 final int prime = 31;
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());
142 public boolean equals(@Nullable Object obj) {
149 if (getClass() != obj.getClass()) {
152 Mouse other = (Mouse) obj;
153 if (!detections.equals(other.detections)) {
156 if (!device.equals(other.device)) {
159 Object localType = type;
160 if (localType == null) {
161 if (other.type != null) {
164 } else if (!localType.equals(other.type)) {
167 String localTypeName = typename;
168 if (localTypeName == null) {
169 if (other.typename != null) {
172 } else if (!localTypeName.equals(other.typename)) {
179 public String toString() {
180 return "Mouse [device=" + device + ", type=" + type + ", detections=" + detections + ", typename="
185 public static class Detection {
188 private @Nullable String gatewayTime;
189 private @Nullable String nodeTime;
190 private int duration;
191 private @Nullable String typename;
193 public int getCount() {
197 public @Nullable String getGatewayTime() {
201 public @Nullable String getNodeTime() {
205 public int getDuration() {
209 public @Nullable String getTypename() {
214 public int hashCode() {
215 final int prime = 31;
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());
229 public boolean equals(@Nullable Object obj) {
236 if (getClass() != obj.getClass()) {
239 Detection other = (Detection) obj;
240 if (count != other.count) {
243 if (duration != other.duration) {
246 String localGatewayTime = gatewayTime;
247 if (localGatewayTime == null) {
248 if (other.gatewayTime != null) {
251 } else if (!localGatewayTime.equals(other.gatewayTime)) {
254 String localNodeTime = nodeTime;
255 if (localNodeTime == null) {
256 if (other.nodeTime != null) {
259 } else if (!localNodeTime.equals(other.nodeTime)) {
262 String localTypeName = typename;
263 if (localTypeName == null) {
264 if (other.typename != null) {
267 } else if (!localTypeName.equals(other.typename)) {
274 public String toString() {
275 return "Detection [count=" + count + ", gatewayTime=" + gatewayTime + ", nodeTime=" + nodeTime
276 + ", duration=" + duration + ", typename=" + typename + "]";