]> git.basschouten.com Git - openhab-addons.git/blob
03217a6d79d482d085c6f38e3077bb80828c4ade
[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 bluetooth.
17  *
18  * @author Gregory Moyer - Initial contribution
19  */
20 public class Bluetooth {
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 Boolean discoverable;
35     private String name;
36     private Boolean pairable;
37
38     public Boolean isActive() {
39         return active;
40     }
41
42     public void setActive(Boolean active) {
43         this.active = active;
44     }
45
46     public Bluetooth withActive(Boolean active) {
47         this.active = active;
48         return this;
49     }
50
51     public String getMac() {
52         return mac == null ? address : mac;
53     }
54
55     public void setMac(String mac) {
56         this.mac = mac;
57         this.address = mac;
58     }
59
60     public Bluetooth withMac(String mac) {
61         setMac(mac);
62         return this;
63     }
64
65     public Boolean isAvailable() {
66         return available;
67     }
68
69     public void setAvailable(Boolean available) {
70         this.available = available;
71     }
72
73     public Bluetooth withAvailable(Boolean available) {
74         this.available = available;
75         return this;
76     }
77
78     public Boolean isDiscoverable() {
79         return discoverable;
80     }
81
82     public void setDiscoverable(Boolean discoverable) {
83         this.discoverable = discoverable;
84     }
85
86     public Bluetooth withDiscoverable(Boolean discoverable) {
87         this.discoverable = discoverable;
88         return this;
89     }
90
91     public String getName() {
92         return name;
93     }
94
95     public void setName(String name) {
96         this.name = name;
97     }
98
99     public Bluetooth withName(String name) {
100         this.name = name;
101         return this;
102     }
103
104     public Boolean isPairable() {
105         return pairable;
106     }
107
108     public void setPairable(Boolean pairable) {
109         this.pairable = pairable;
110     }
111
112     public Bluetooth withPairable(Boolean pairable) {
113         this.pairable = pairable;
114         return this;
115     }
116
117     @Override
118     public String toString() {
119         StringBuilder builder = new StringBuilder();
120         builder.append("Bluetooth [active=");
121         builder.append(active);
122         builder.append(", mac=");
123         builder.append(getMac());
124         builder.append(", available=");
125         builder.append(available);
126         builder.append(", discoverable=");
127         builder.append(discoverable);
128         builder.append(", name=");
129         builder.append(name);
130         builder.append(", pairable=");
131         builder.append(pairable);
132         builder.append("]");
133         return builder.toString();
134     }
135 }