]> git.basschouten.com Git - openhab-addons.git/blob
034c4685680c1940b6c395b51c3bf4da344c5d3c
[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_SMARTPLUG;
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 plugs of the Verisure System.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class VerisureSmartPlugsDTO extends VerisureBaseThingDTO {
31
32     @Override
33     public ThingTypeUID getThingTypeUID() {
34         return THING_TYPE_SMARTPLUG;
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 Smartplug {
60
61         private Device device = new Device();
62         private @Nullable String currentState;
63         private @Nullable String icon;
64         private boolean isHazardous;
65         @SerializedName("__typename")
66         private @Nullable String typename;
67
68         public Device getDevice() {
69             return device;
70         }
71
72         public @Nullable String getCurrentState() {
73             return currentState;
74         }
75
76         public @Nullable String getIcon() {
77             return icon;
78         }
79
80         public boolean isHazardous() {
81             return isHazardous;
82         }
83
84         public @Nullable String getTypename() {
85             return typename;
86         }
87
88         @Override
89         public int hashCode() {
90             final int prime = 31;
91             int result = 1;
92             String localCurrentState = currentState;
93             result = prime * result + ((localCurrentState == null) ? 0 : localCurrentState.hashCode());
94             result = prime * result + device.hashCode();
95             String localIcon = icon;
96             result = prime * result + ((localIcon == null) ? 0 : localIcon.hashCode());
97             result = prime * result + (isHazardous ? 1231 : 1237);
98             String localTypeName = typename;
99             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
100             return result;
101         }
102
103         @Override
104         public boolean equals(@Nullable Object obj) {
105             if (this == obj) {
106                 return true;
107             }
108             if (obj == null) {
109                 return false;
110             }
111             if (getClass() != obj.getClass()) {
112                 return false;
113             }
114             Smartplug other = (Smartplug) obj;
115             String localCurrentState = currentState;
116             if (localCurrentState == null) {
117                 if (other.currentState != null) {
118                     return false;
119                 }
120             } else if (!localCurrentState.equals(other.currentState)) {
121                 return false;
122             }
123             if (!device.equals(other.device)) {
124                 return false;
125             }
126             String localIcon = icon;
127             if (localIcon == null) {
128                 if (other.icon != null) {
129                     return false;
130                 }
131             } else if (!localIcon.equals(other.icon)) {
132                 return false;
133             }
134             if (isHazardous != other.isHazardous) {
135                 return false;
136             }
137             String localTypeName = typename;
138             if (localTypeName == null) {
139                 if (other.typename != null) {
140                     return false;
141                 }
142             } else if (!localTypeName.equals(other.typename)) {
143                 return false;
144             }
145             return true;
146         }
147
148         @Override
149         public String toString() {
150             return "Smartplug [device=" + device + ", currentState=" + currentState + ", icon=" + icon
151                     + ", isHazardous=" + isHazardous + ", typename=" + typename + "]";
152         }
153     }
154 }