]> git.basschouten.com Git - openhab-addons.git/blob
616051993f7b822dc72a1a5ae1fcaa81ed76b4c8
[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.lametrictime.internal.api.local.dto;
14
15 /**
16  * Pojo for wifi.
17  *
18  * @author Gregory Moyer - Initial contribution
19  */
20 public class Wifi {
21     private Boolean active;
22
23     /*
24      * API sometimes calls this field 'mac' and other times calls it 'address'.
25      * Additionally, Gson uses fields only (not methods). Therefore, if use the
26      * same instance of this class to read one value and then try to write the
27      * other without calling the setter, it won't work (the other value will be
28      * null).
29      */
30     private String mac;
31     private String address;
32
33     private Boolean available;
34     private String encryption;
35
36     /*
37      * API sometimes calls this field 'ssid' and other times calls it 'essid'.
38      * Additionally, Gson uses fields only (not methods). Therefore, if use the
39      * same instance of this class to read one value and then try to write the
40      * other without calling the setter, it won't work (the other value will be
41      * null).
42      */
43     private String ssid;
44     private String essid;
45
46     /*
47      * API sometimes calls this field 'ip' and other times calls it 'ipv4'.
48      * Additionally, Gson uses fields only (not methods). Therefore, if use the
49      * same instance of this class to read one value and then try to write the
50      * other without calling the setter, it won't work (the other value will be
51      * null).
52      */
53     private String ip;
54     private String ipv4;
55
56     private String mode;
57     private String netmask;
58
59     /*
60      * API sometimes calls this field 'signal_strength' and other times calls it
61      * 'strength'. Additionally, Gson uses fields only (not methods). Therefore,
62      * if use the same instance of this class to read one value and then try to
63      * write the other without calling the setter, it won't work (the other
64      * value will be null).
65      */
66     private Integer signalStrength;
67     private Integer strength;
68
69     public Boolean isActive() {
70         return active;
71     }
72
73     public void setActive(Boolean active) {
74         this.active = active;
75     }
76
77     public Wifi withActive(Boolean active) {
78         this.active = active;
79         return this;
80     }
81
82     public String getMac() {
83         return mac == null ? address : mac;
84     }
85
86     public void setMac(String mac) {
87         this.mac = mac;
88         this.address = mac;
89     }
90
91     public Wifi withMac(String mac) {
92         setMac(mac);
93         return this;
94     }
95
96     public Boolean isAvailable() {
97         return available;
98     }
99
100     public void setAvailable(Boolean available) {
101         this.available = available;
102     }
103
104     public Wifi withAvailable(Boolean available) {
105         this.available = available;
106         return this;
107     }
108
109     public String getEncryption() {
110         return encryption;
111     }
112
113     public void setEncryption(String encryption) {
114         this.encryption = encryption;
115     }
116
117     public Wifi withEncryption(String encryption) {
118         this.encryption = encryption;
119         return this;
120     }
121
122     public String getSsid() {
123         return ssid == null ? essid : ssid;
124     }
125
126     public void setSsid(String ssid) {
127         this.ssid = ssid;
128         this.essid = ssid;
129     }
130
131     public Wifi withSsid(String ssid) {
132         setSsid(ssid);
133         return this;
134     }
135
136     public String getIp() {
137         return ip == null ? ipv4 : ip;
138     }
139
140     public void setIp(String ip) {
141         this.ip = ip;
142         this.ipv4 = ip;
143     }
144
145     public Wifi withIp(String ip) {
146         setIp(ip);
147         return this;
148     }
149
150     public String getMode() {
151         return mode;
152     }
153
154     public void setMode(String mode) {
155         this.mode = mode;
156     }
157
158     public Wifi withMode(String mode) {
159         this.mode = mode;
160         return this;
161     }
162
163     public String getNetmask() {
164         return netmask;
165     }
166
167     public void setNetmask(String netmask) {
168         this.netmask = netmask;
169     }
170
171     public Wifi withNetmask(String netmask) {
172         this.netmask = netmask;
173         return this;
174     }
175
176     public Integer getSignalStrength() {
177         return signalStrength == null ? strength : signalStrength;
178     }
179
180     public void setSignalStrength(Integer signalStrength) {
181         this.signalStrength = signalStrength;
182         this.strength = signalStrength;
183     }
184
185     public Wifi withSignalStrength(Integer signalStrength) {
186         setSignalStrength(signalStrength);
187         return this;
188     }
189
190     @Override
191     public String toString() {
192         StringBuilder builder = new StringBuilder();
193         builder.append("Wifi [active=");
194         builder.append(active);
195         builder.append(", mac=");
196         builder.append(getMac());
197         builder.append(", available=");
198         builder.append(available);
199         builder.append(", encryption=");
200         builder.append(encryption);
201         builder.append(", ssid=");
202         builder.append(getSsid());
203         builder.append(", ip=");
204         builder.append(getIp());
205         builder.append(", mode=");
206         builder.append(mode);
207         builder.append(", netmask=");
208         builder.append(netmask);
209         builder.append(", signalStrength=");
210         builder.append(getSignalStrength());
211         builder.append("]");
212         return builder.toString();
213     }
214 }