2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.amazonechocontrol.internal.jsons;
15 import java.util.List;
16 import java.util.Objects;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.amazonechocontrol.internal.jsons.JsonDevices.Device;
23 * The {@link JsonBluetoothStates} encapsulate the GSON data of bluetooth state
25 * @author Michael Geramb - Initial contribution
28 public class JsonBluetoothStates {
30 public @Nullable BluetoothState findStateByDevice(@Nullable Device device) {
35 BluetoothState @Nullable [] bluetoothStates = this.bluetoothStates;
36 if (bluetoothStates == null) {
39 for (BluetoothState state : bluetoothStates) {
40 if (state != null && Objects.equals(state.deviceSerialNumber, device.serialNumber)) {
47 public @Nullable BluetoothState @Nullable [] bluetoothStates;
49 public static class PairedDevice {
50 public @Nullable String address;
51 public boolean connected;
52 public @Nullable String deviceClass;
53 public @Nullable String friendlyName;
54 public @Nullable List<String> profiles;
57 public static class BluetoothState {
58 public @Nullable String deviceSerialNumber;
59 public @Nullable String deviceType;
60 public @Nullable String friendlyName;
61 public boolean gadgetPaired;
62 public boolean online;
63 public @Nullable List<PairedDevice> pairedDeviceList;
65 public List<PairedDevice> getPairedDeviceList() {
66 return Objects.requireNonNullElse(pairedDeviceList, List.of());