]> git.basschouten.com Git - openhab-addons.git/blob
695586f93089063badcac9820674e8153870d23a
[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_SMARTLOCK;
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 smart locks of the Verisure System.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class VerisureSmartLocksDTO extends VerisureBaseThingDTO {
31
32     private @Nullable VerisureSmartLockDTO smartLockJSON;
33
34     public @Nullable VerisureSmartLockDTO getSmartLockJSON() {
35         return smartLockJSON;
36     }
37
38     public void setSmartLockJSON(@Nullable VerisureSmartLockDTO smartLockJSON) {
39         this.smartLockJSON = smartLockJSON;
40     }
41
42     @Override
43     public ThingTypeUID getThingTypeUID() {
44         return THING_TYPE_SMARTLOCK;
45     }
46
47     @Override
48     public int hashCode() {
49         final int prime = 31;
50         int result = super.hashCode();
51         VerisureSmartLockDTO localSmartLockJSON = smartLockJSON;
52         result = prime * result + ((localSmartLockJSON == null) ? 0 : localSmartLockJSON.hashCode());
53         return result;
54     }
55
56     @Override
57     public boolean equals(@Nullable Object obj) {
58         if (this == obj) {
59             return true;
60         }
61         if (!super.equals(obj)) {
62             return false;
63         }
64         if (obj == null) {
65             return false;
66         }
67         if (getClass() != obj.getClass()) {
68             return false;
69         }
70         VerisureSmartLocksDTO other = (VerisureSmartLocksDTO) obj;
71         VerisureSmartLockDTO localSmartLockJSON = smartLockJSON;
72         if (localSmartLockJSON == null) {
73             if (other.smartLockJSON != null) {
74                 return false;
75             }
76         } else if (!localSmartLockJSON.equals(other.smartLockJSON)) {
77             return false;
78         }
79         return true;
80     }
81
82     @Override
83     public String toString() {
84         return "VerisureSmartLocksDTO [smartLockJSON=" + smartLockJSON + "]";
85     }
86
87     public static class Doorlock {
88
89         @SerializedName("__typename")
90         private @Nullable String typename;
91         private @Nullable String currentLockState;
92         private @Nullable String eventTime;
93         private @Nullable String method;
94         private @Nullable String userString;
95         private Device device = new Device();
96         private boolean motorJam;
97         private boolean secureModeActive;
98
99         public @Nullable String getTypename() {
100             return typename;
101         }
102
103         public @Nullable String getCurrentLockState() {
104             return currentLockState;
105         }
106
107         public Device getDevice() {
108             return device;
109         }
110
111         public @Nullable String getEventTime() {
112             return eventTime;
113         }
114
115         public @Nullable String getMethod() {
116             return method;
117         }
118
119         public boolean isMotorJam() {
120             return motorJam;
121         }
122
123         public boolean getSecureModeActive() {
124             return secureModeActive;
125         }
126
127         public @Nullable String getUserString() {
128             return userString;
129         }
130
131         @Override
132         public int hashCode() {
133             final int prime = 31;
134             int result = 1;
135             String localCurrentLockState = currentLockState;
136             result = prime * result + ((localCurrentLockState == null) ? 0 : localCurrentLockState.hashCode());
137             result = prime * result + device.hashCode();
138             String localEventTime = eventTime;
139             result = prime * result + ((localEventTime == null) ? 0 : localEventTime.hashCode());
140             String localMethod = method;
141             result = prime * result + ((localMethod == null) ? 0 : localMethod.hashCode());
142             result = prime * result + (motorJam ? 1231 : 1237);
143             result = prime * result + (secureModeActive ? 1231 : 1237);
144             String localTypeName = typename;
145             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
146             String localUserString = userString;
147             result = prime * result + ((localUserString == null) ? 0 : localUserString.hashCode());
148             return result;
149         }
150
151         @Override
152         public boolean equals(@Nullable Object obj) {
153             if (this == obj) {
154                 return true;
155             }
156             if (obj == null) {
157                 return false;
158             }
159             if (getClass() != obj.getClass()) {
160                 return false;
161             }
162             Doorlock other = (Doorlock) obj;
163             String localCurrentLockState = currentLockState;
164             if (localCurrentLockState == null) {
165                 if (other.currentLockState != null) {
166                     return false;
167                 }
168             } else if (!localCurrentLockState.equals(other.currentLockState)) {
169                 return false;
170             }
171             if (!device.equals(other.device)) {
172                 return false;
173             }
174             String localEventTime = eventTime;
175             if (localEventTime == null) {
176                 if (other.eventTime != null) {
177                     return false;
178                 }
179             } else if (!localEventTime.equals(other.eventTime)) {
180                 return false;
181             }
182             String localMethod = method;
183             if (localMethod == null) {
184                 if (other.method != null) {
185                     return false;
186                 }
187             } else if (!localMethod.equals(other.method)) {
188                 return false;
189             }
190             if (motorJam != other.motorJam) {
191                 return false;
192             }
193             if (secureModeActive != other.secureModeActive) {
194                 return false;
195             }
196             String localTypeName = typename;
197             if (localTypeName == null) {
198                 if (other.typename != null) {
199                     return false;
200                 }
201             } else if (!localTypeName.equals(other.typename)) {
202                 return false;
203             }
204             String localUserString = userString;
205             if (localUserString == null) {
206                 if (other.userString != null) {
207                     return false;
208                 }
209             } else if (!localUserString.equals(other.userString)) {
210                 return false;
211             }
212             return true;
213         }
214
215         @Override
216         public String toString() {
217             return "Doorlock [typename=" + typename + ", currentLockState=" + currentLockState + ", eventTime="
218                     + eventTime + ", method=" + method + ", userString=" + userString + ", device=" + device
219                     + ", motorJam=" + motorJam + ", secureModeActive=" + secureModeActive + "]";
220         }
221     }
222 }