]> git.basschouten.com Git - openhab-addons.git/blob
d2735f4c41677ebd1cb59f8de5e90a91d852d355
[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_BROADBAND_CONNECTION;
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 broadband connections of the Verisure System.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class VerisureBroadbandConnectionsDTO extends VerisureBaseThingDTO {
31
32     @Override
33     public ThingTypeUID getThingTypeUID() {
34         return THING_TYPE_BROADBAND_CONNECTION;
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 Broadband {
61
62         private @Nullable String testDate;
63         private boolean isBroadbandConnected;
64         @SerializedName("__typename")
65         private @Nullable String typename;
66
67         public @Nullable String getTestDate() {
68             return testDate;
69         }
70
71         public boolean isBroadbandConnected() {
72             return isBroadbandConnected;
73         }
74
75         public @Nullable String getTypename() {
76             return typename;
77         }
78
79         @Override
80         public int hashCode() {
81             final int prime = 31;
82             int result = 1;
83             result = prime * result + (isBroadbandConnected ? 1231 : 1237);
84             String localTestDate = testDate;
85             result = prime * result + ((localTestDate == null) ? 0 : localTestDate.hashCode());
86             String localTypeName = typename;
87             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
88             return result;
89         }
90
91         @Override
92         public boolean equals(@Nullable Object obj) {
93             if (this == obj) {
94                 return true;
95             }
96             if (obj == null) {
97                 return false;
98             }
99             if (getClass() != obj.getClass()) {
100                 return false;
101             }
102             Broadband other = (Broadband) obj;
103             if (isBroadbandConnected != other.isBroadbandConnected) {
104                 return false;
105             }
106             String localTestDate = testDate;
107             if (localTestDate == null) {
108                 if (other.testDate != null) {
109                     return false;
110                 }
111             } else if (!localTestDate.equals(other.testDate)) {
112                 return false;
113             }
114             String localTypeName = typename;
115             if (localTypeName == null) {
116                 if (other.typename != null) {
117                     return false;
118                 }
119             } else if (!localTypeName.equals(other.typename)) {
120                 return false;
121             }
122             return true;
123         }
124
125         @Override
126         public String toString() {
127             return "Broadband [testDate=" + testDate + ", isBroadbandConnected=" + isBroadbandConnected + ", typename="
128                     + typename + "]";
129         }
130     }
131 }