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