]> git.basschouten.com Git - openhab-addons.git/blob
542f603b23e18decf341fbf19996400c0234cff2
[openhab-addons.git] /
1 /**
2  * Copyright 2017-2018 Gregory Moyer and contributors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openhab.binding.lametrictime.api.local.model;
17
18 public class Wifi
19 {
20     private Boolean active;
21
22     /*
23      * API sometimes calls this field 'mac' and other times calls it 'address'.
24      * Additionally, Gson uses fields only (not methods). Therefore, if use the
25      * same instance of this class to read one value and then try to write the
26      * other without calling the setter, it won't work (the other value will be
27      * null).
28      */
29     private String mac;
30     private String address;
31
32     private Boolean available;
33     private String encryption;
34
35     /*
36      * API sometimes calls this field 'ssid' and other times calls it 'essid'.
37      * Additionally, Gson uses fields only (not methods). Therefore, if use the
38      * same instance of this class to read one value and then try to write the
39      * other without calling the setter, it won't work (the other value will be
40      * null).
41      */
42     private String ssid;
43     private String essid;
44
45     /*
46      * API sometimes calls this field 'ip' and other times calls it 'ipv4'.
47      * Additionally, Gson uses fields only (not methods). Therefore, if use the
48      * same instance of this class to read one value and then try to write the
49      * other without calling the setter, it won't work (the other value will be
50      * null).
51      */
52     private String ip;
53     private String ipv4;
54
55     private String mode;
56     private String netmask;
57
58     /*
59      * API sometimes calls this field 'signal_strength' and other times calls it
60      * 'strength'. Additionally, Gson uses fields only (not methods). Therefore,
61      * if use the same instance of this class to read one value and then try to
62      * write the other without calling the setter, it won't work (the other
63      * value will be null).
64      */
65     private Integer signalStrength;
66     private Integer strength;
67
68     public Boolean isActive()
69     {
70         return active;
71     }
72
73     public void setActive(Boolean active)
74     {
75         this.active = active;
76     }
77
78     public Wifi withActive(Boolean active)
79     {
80         this.active = active;
81         return this;
82     }
83
84     public String getMac()
85     {
86         return mac == null ? address : mac;
87     }
88
89     public void setMac(String mac)
90     {
91         this.mac = mac;
92         this.address = mac;
93     }
94
95     public Wifi withMac(String mac)
96     {
97         setMac(mac);
98         return this;
99     }
100
101     public Boolean isAvailable()
102     {
103         return available;
104     }
105
106     public void setAvailable(Boolean available)
107     {
108         this.available = available;
109     }
110
111     public Wifi withAvailable(Boolean available)
112     {
113         this.available = available;
114         return this;
115     }
116
117     public String getEncryption()
118     {
119         return encryption;
120     }
121
122     public void setEncryption(String encryption)
123     {
124         this.encryption = encryption;
125     }
126
127     public Wifi withEncryption(String encryption)
128     {
129         this.encryption = encryption;
130         return this;
131     }
132
133     public String getSsid()
134     {
135         return ssid == null ? essid : ssid;
136     }
137
138     public void setSsid(String ssid)
139     {
140         this.ssid = ssid;
141         this.essid = ssid;
142     }
143
144     public Wifi withSsid(String ssid)
145     {
146         setSsid(ssid);
147         return this;
148     }
149
150     public String getIp()
151     {
152         return ip == null ? ipv4 : ip;
153     }
154
155     public void setIp(String ip)
156     {
157         this.ip = ip;
158         this.ipv4 = ip;
159     }
160
161     public Wifi withIp(String ip)
162     {
163         setIp(ip);
164         return this;
165     }
166
167     public String getMode()
168     {
169         return mode;
170     }
171
172     public void setMode(String mode)
173     {
174         this.mode = mode;
175     }
176
177     public Wifi withMode(String mode)
178     {
179         this.mode = mode;
180         return this;
181     }
182
183     public String getNetmask()
184     {
185         return netmask;
186     }
187
188     public void setNetmask(String netmask)
189     {
190         this.netmask = netmask;
191     }
192
193     public Wifi withNetmask(String netmask)
194     {
195         this.netmask = netmask;
196         return this;
197     }
198
199     public Integer getSignalStrength()
200     {
201         return signalStrength == null ? strength : signalStrength;
202     }
203
204     public void setSignalStrength(Integer signalStrength)
205     {
206         this.signalStrength = signalStrength;
207         this.strength = signalStrength;
208     }
209
210     public Wifi withSignalStrength(Integer signalStrength)
211     {
212         setSignalStrength(signalStrength);
213         return this;
214     }
215
216     @Override
217     public String toString()
218     {
219         StringBuilder builder = new StringBuilder();
220         builder.append("Wifi [active=");
221         builder.append(active);
222         builder.append(", mac=");
223         builder.append(getMac());
224         builder.append(", available=");
225         builder.append(available);
226         builder.append(", encryption=");
227         builder.append(encryption);
228         builder.append(", ssid=");
229         builder.append(getSsid());
230         builder.append(", ip=");
231         builder.append(getIp());
232         builder.append(", mode=");
233         builder.append(mode);
234         builder.append(", netmask=");
235         builder.append(netmask);
236         builder.append(", signalStrength=");
237         builder.append(getSignalStrength());
238         builder.append("]");
239         return builder.toString();
240     }
241 }