]> git.basschouten.com Git - openhab-addons.git/blob
e482f255a92dc270c9ea936611c91db283584810
[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.unifi.internal.api.dto;
14
15 import org.openhab.binding.unifi.internal.api.cache.UniFiControllerCache;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * @author Hilbrand Bouwkamp - Initial contribution
21  */
22 public class UniFiWlan implements HasId {
23
24     protected final transient UniFiControllerCache cache;
25
26     @SerializedName("_id")
27     private String id;
28
29     private String name;
30
31     private boolean enabled;
32
33     private String security; // ": "wpapsk",
34     private String wlanBand; // ": "both",
35     private String wpaEnc; // ": "ccmp",
36     private String wpaMode;// ": "wpa2",
37     private String xPassphrase; // : "1234",
38     private Boolean hideSsid;
39     private String siteId;
40
41     public UniFiWlan(final UniFiControllerCache cache) {
42         this.cache = cache;
43     }
44
45     @Override
46     public String getId() {
47         return id;
48     }
49
50     public String getName() {
51         return name;
52     }
53
54     public boolean isEnabled() {
55         return enabled;
56     }
57
58     public UniFiSite getSite() {
59         return cache.getSite(siteId);
60     }
61
62     public String getSecurity() {
63         return security;
64     }
65
66     public String getWlanBand() {
67         return wlanBand;
68     }
69
70     public String getWpaEnc() {
71         return wpaEnc;
72     }
73
74     public String getWpaMode() {
75         return wpaMode;
76     }
77
78     public String getXPassphrase() {
79         return xPassphrase;
80     }
81
82     public boolean isHideSsid() {
83         return Boolean.TRUE.equals(hideSsid);
84     }
85
86     @Override
87     public String toString() {
88         final String xPassphraseString = xPassphrase == null ? ""
89                 : (xPassphrase.substring(0, Math.min(5, xPassphrase.length())) + "*".repeat(10));
90
91         return String.format(
92                 "UniFiWlan{id: '%s', name: '%s', enable: '%b', security: '%s', wlanBand: '%s', wpaEnc: '%s', wpaMode: '%s', xPassphrase: '%s', hideSsid: '%b', site: '%s'}",
93                 id, name, enabled, security, wlanBand, wpaEnc, wpaMode, xPassphraseString, hideSsid, getSite());
94     }
95 }