]> git.basschouten.com Git - openhab-addons.git/blob
4d58ebe773a935c9f23fd420bdf27a81606af42a
[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_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         @SuppressWarnings("PMD.SimplifyBooleanReturns")
130         @Override
131         public boolean equals(@Nullable Object obj) {
132             if (this == obj) {
133                 return true;
134             }
135             if (obj == null) {
136                 return false;
137             }
138             if (getClass() != obj.getClass()) {
139                 return false;
140             }
141             DoorWindow other = (DoorWindow) obj;
142             if (!device.equals(other.device)) {
143                 return false;
144             }
145             String localReportTime = reportTime;
146             if (localReportTime == null) {
147                 if (other.reportTime != null) {
148                     return false;
149                 }
150             } else if (!localReportTime.equals(other.reportTime)) {
151                 return false;
152             }
153             String localState = state;
154             if (localState == null) {
155                 if (other.state != null) {
156                     return false;
157                 }
158             } else if (!localState.equals(other.state)) {
159                 return false;
160             }
161             String localType = type;
162             if (localType == null) {
163                 if (other.type != null) {
164                     return false;
165                 }
166             } else if (!localType.equals(other.type)) {
167                 return false;
168             }
169             String localTypeName = typename;
170             if (localTypeName == null) {
171                 if (other.typename != null) {
172                     return false;
173                 }
174             } else if (!localTypeName.equals(other.typename)) {
175                 return false;
176             }
177             if (wired != other.wired) {
178                 return false;
179             }
180             return true;
181         }
182
183         @Override
184         public String toString() {
185             return "DoorWindow [device=" + device + ", type=" + type + ", state=" + state + ", wired=" + wired
186                     + ", reportTime=" + reportTime + ", typename=" + typename + "]";
187         }
188     }
189 }