]> git.basschouten.com Git - openhab-addons.git/blob
f5b3860bf6f1b13cf95b73013d05281fcb8ba3cb
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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     @Override
33     public ThingTypeUID getThingTypeUID() {
34         return THING_TYPE_DOORWINDOW;
35     }
36
37     @Override
38     public int hashCode() {
39         return super.hashCode();
40     }
41
42     @Override
43     public boolean equals(@Nullable Object obj) {
44         if (this == obj) {
45             return true;
46         }
47         if (!super.equals(obj)) {
48             return false;
49         }
50         if (obj == null) {
51             return false;
52         }
53         if (getClass() != obj.getClass()) {
54             return false;
55         }
56         return true;
57     }
58
59     public static class DoorWindow {
60
61         private Device device = new Device();
62         private @Nullable String type;
63         private @Nullable String state;
64         private boolean wired;
65         private @Nullable String reportTime;
66         @SerializedName("__typename")
67         private @Nullable String typename;
68
69         public Device getDevice() {
70             return device;
71         }
72
73         public @Nullable String getType() {
74             return type;
75         }
76
77         public @Nullable String getState() {
78             return state;
79         }
80
81         public boolean getWired() {
82             return wired;
83         }
84
85         public @Nullable String getReportTime() {
86             return reportTime;
87         }
88
89         public @Nullable String getTypename() {
90             return typename;
91         }
92
93         @Override
94         public int hashCode() {
95             final int prime = 31;
96             int result = 1;
97             result = prime * result + device.hashCode();
98             String localReportTime = reportTime;
99             result = prime * result + ((localReportTime == null) ? 0 : localReportTime.hashCode());
100             String localState = state;
101             result = prime * result + ((localState == null) ? 0 : localState.hashCode());
102             String localType = type;
103             result = prime * result + ((localType == null) ? 0 : localType.hashCode());
104             String localTypeName = typename;
105             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
106             result = prime * result + (wired ? 1231 : 1237);
107             return result;
108         }
109
110         @Override
111         public boolean equals(@Nullable Object obj) {
112             if (this == obj) {
113                 return true;
114             }
115             if (obj == null) {
116                 return false;
117             }
118             if (getClass() != obj.getClass()) {
119                 return false;
120             }
121             DoorWindow other = (DoorWindow) obj;
122             if (!device.equals(other.device)) {
123                 return false;
124             }
125             String localReportTime = reportTime;
126             if (localReportTime == null) {
127                 if (other.reportTime != null) {
128                     return false;
129                 }
130             } else if (!localReportTime.equals(other.reportTime)) {
131                 return false;
132             }
133             String localState = state;
134             if (localState == null) {
135                 if (other.state != null) {
136                     return false;
137                 }
138             } else if (!localState.equals(other.state)) {
139                 return false;
140             }
141             String localType = type;
142             if (localType == null) {
143                 if (other.type != null) {
144                     return false;
145                 }
146             } else if (!localType.equals(other.type)) {
147                 return false;
148             }
149             String localTypeName = typename;
150             if (localTypeName == null) {
151                 if (other.typename != null) {
152                     return false;
153                 }
154             } else if (!localTypeName.equals(other.typename)) {
155                 return false;
156             }
157             if (wired != other.wired) {
158                 return false;
159             }
160             return true;
161         }
162
163         @Override
164         public String toString() {
165             return "DoorWindow [device=" + device + ", type=" + type + ", state=" + state + ", wired=" + wired
166                     + ", reportTime=" + reportTime + ", typename=" + typename + "]";
167         }
168     }
169 }