]> git.basschouten.com Git - openhab-addons.git/blob
c8b4f4645e68764d65b04532986b36881d289cc6
[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     @SuppressWarnings("PMD.SimplifyBooleanReturns")
43     @Override
44     public boolean equals(@Nullable Object obj) {
45         if (this == obj) {
46             return true;
47         }
48         if (!super.equals(obj)) {
49             return false;
50         }
51         if (obj == null) {
52             return false;
53         }
54         if (getClass() != obj.getClass()) {
55             return false;
56         }
57         return true;
58     }
59
60     public static class Smartplug {
61
62         private Device device = new Device();
63         private @Nullable String currentState;
64         private @Nullable String icon;
65         private boolean isHazardous;
66         @SerializedName("__typename")
67         private @Nullable String typename;
68
69         public Device getDevice() {
70             return device;
71         }
72
73         public @Nullable String getCurrentState() {
74             return currentState;
75         }
76
77         public @Nullable String getIcon() {
78             return icon;
79         }
80
81         public boolean isHazardous() {
82             return isHazardous;
83         }
84
85         public @Nullable String getTypename() {
86             return typename;
87         }
88
89         @Override
90         public int hashCode() {
91             final int prime = 31;
92             int result = 1;
93             String localCurrentState = currentState;
94             result = prime * result + ((localCurrentState == null) ? 0 : localCurrentState.hashCode());
95             result = prime * result + device.hashCode();
96             String localIcon = icon;
97             result = prime * result + ((localIcon == null) ? 0 : localIcon.hashCode());
98             result = prime * result + (isHazardous ? 1231 : 1237);
99             String localTypeName = typename;
100             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
101             return result;
102         }
103
104         @Override
105         public boolean equals(@Nullable Object obj) {
106             if (this == obj) {
107                 return true;
108             }
109             if (obj == null) {
110                 return false;
111             }
112             if (getClass() != obj.getClass()) {
113                 return false;
114             }
115             Smartplug other = (Smartplug) obj;
116             String localCurrentState = currentState;
117             if (localCurrentState == null) {
118                 if (other.currentState != null) {
119                     return false;
120                 }
121             } else if (!localCurrentState.equals(other.currentState)) {
122                 return false;
123             }
124             if (!device.equals(other.device)) {
125                 return false;
126             }
127             String localIcon = icon;
128             if (localIcon == null) {
129                 if (other.icon != null) {
130                     return false;
131                 }
132             } else if (!localIcon.equals(other.icon)) {
133                 return false;
134             }
135             if (isHazardous != other.isHazardous) {
136                 return false;
137             }
138             String localTypeName = typename;
139             if (localTypeName == null) {
140                 if (other.typename != null) {
141                     return false;
142                 }
143             } else if (!localTypeName.equals(other.typename)) {
144                 return false;
145             }
146             return true;
147         }
148
149         @Override
150         public String toString() {
151             return "Smartplug [device=" + device + ", currentState=" + currentState + ", icon=" + icon
152                     + ", isHazardous=" + isHazardous + ", typename=" + typename + "]";
153         }
154     }
155 }