]> git.basschouten.com Git - openhab-addons.git/blob
fef529fe76b3903ed77966b2801d34c27bd7d2ad
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.amazonechocontrol.internal.jsons;
14
15 import org.apache.commons.lang.StringUtils;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.openhab.binding.amazonechocontrol.internal.jsons.JsonDevices.Device;
19
20 /**
21  * The {@link JsonBluetoothStates} encapsulate the GSON data of bluetooth state
22  *
23  * @author Michael Geramb - Initial contribution
24  */
25 @NonNullByDefault
26 public class JsonBluetoothStates {
27
28     public @Nullable BluetoothState findStateByDevice(@Nullable Device device) {
29         if (device == null) {
30             return null;
31         }
32         @Nullable
33         BluetoothState @Nullable [] bluetoothStates = this.bluetoothStates;
34         if (bluetoothStates == null) {
35             return null;
36         }
37         for (BluetoothState state : bluetoothStates) {
38             if (state != null && StringUtils.equals(state.deviceSerialNumber, device.serialNumber)) {
39                 return state;
40             }
41         }
42         return null;
43     }
44
45     public @Nullable BluetoothState @Nullable [] bluetoothStates;
46
47     public static class PairedDevice {
48         public @Nullable String address;
49         public boolean connected;
50         public @Nullable String deviceClass;
51         public @Nullable String friendlyName;
52         public @Nullable String @Nullable [] profiles;
53     }
54
55     public static class BluetoothState {
56         public @Nullable String deviceSerialNumber;
57         public @Nullable String deviceType;
58         public @Nullable String friendlyName;
59         public boolean gadgetPaired;
60         public boolean online;
61         public @Nullable PairedDevice @Nullable [] pairedDeviceList;
62     }
63 }