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