| ");
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AmazonEchoDynamicStateDescriptionProvider.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AmazonEchoDynamicStateDescriptionProvider.java
index e99141f13..f753873dd 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AmazonEchoDynamicStateDescriptionProvider.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AmazonEchoDynamicStateDescriptionProvider.java
@@ -14,11 +14,7 @@ package org.openhab.binding.amazonechocontrol.internal;
import static org.openhab.binding.amazonechocontrol.internal.AmazonEchoControlBindingConstants.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -106,17 +102,13 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
if (bluetoothState == null) {
return null;
}
- PairedDevice[] pairedDeviceList = bluetoothState.pairedDeviceList;
- if (pairedDeviceList == null) {
+ List pairedDeviceList = bluetoothState.getPairedDeviceList();
+ if (pairedDeviceList.isEmpty()) {
return null;
}
-
List options = new ArrayList<>();
options.add(new StateOption("", ""));
for (PairedDevice device : pairedDeviceList) {
- if (device == null) {
- continue;
- }
final String value = device.address;
if (value != null && device.friendlyName != null) {
options.add(new StateOption(value, device.friendlyName));
@@ -160,8 +152,8 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
return null;
}
- JsonNotificationSound[] notificationSounds = handler.findAlarmSounds();
- if (notificationSounds == null) {
+ List notificationSounds = handler.findAlarmSounds();
+ if (notificationSounds.isEmpty()) {
return null;
}
@@ -169,9 +161,8 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
options.add(new StateOption("", ""));
for (JsonNotificationSound notificationSound : notificationSounds) {
- if (notificationSound != null && notificationSound.folder == null
- && notificationSound.providerId != null && notificationSound.id != null
- && notificationSound.displayName != null) {
+ if (notificationSound.folder == null && notificationSound.providerId != null
+ && notificationSound.id != null && notificationSound.displayName != null) {
String providerSoundId = notificationSound.providerId + ":" + notificationSound.id;
options.add(new StateOption(providerSoundId, notificationSound.displayName));
}
@@ -197,8 +188,7 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
options.add(new StateOption("", ""));
for (Device device : devices) {
final String value = device.serialNumber;
- if (value != null && device.capabilities != null
- && Arrays.asList(device.capabilities).contains("FLASH_BRIEFING")) {
+ if (value != null && device.getCapabilities().contains("FLASH_BRIEFING")) {
options.add(new StateOption(value, device.accountName));
}
}
@@ -210,7 +200,7 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
return null;
}
List musicProviders = handler.findMusicProviders();
- if (musicProviders == null) {
+ if (musicProviders.isEmpty()) {
return null;
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java
index a1197d17c..b3fb362f3 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java
@@ -53,7 +53,6 @@ import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAscendingAlarm;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAscendingAlarm.AscendingAlarmModel;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAutomation;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAutomation.Payload;
-import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAutomation.Trigger;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonBluetoothStates;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonBootstrapResult;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonBootstrapResult.Authentication;
@@ -483,15 +482,13 @@ public class Connection {
try {
String bootstrapResultJson = convertStream(connection);
JsonBootstrapResult result = parseJson(bootstrapResultJson, JsonBootstrapResult.class);
- if (result != null) {
- Authentication authentication = result.authentication;
- if (authentication != null && authentication.authenticated) {
- this.customerName = authentication.customerName;
- if (this.accountCustomerId == null) {
- this.accountCustomerId = authentication.customerId;
- }
- return authentication;
+ Authentication authentication = result.authentication;
+ if (authentication != null && authentication.authenticated) {
+ this.customerName = authentication.customerName;
+ if (this.accountCustomerId == null) {
+ this.accountCustomerId = authentication.customerId;
}
+ return authentication;
}
} catch (JsonSyntaxException | IllegalStateException e) {
logger.info("No valid json received", e);
@@ -726,11 +723,8 @@ public class Connection {
webSiteCookies.add(new JsonWebSiteCookie(cookie.getName(), cookie.getValue()));
}
- JsonWebSiteCookie[] webSiteCookiesArray = new JsonWebSiteCookie[webSiteCookies.size()];
- webSiteCookiesArray = webSiteCookies.toArray(webSiteCookiesArray);
-
JsonRegisterAppRequest registerAppRequest = new JsonRegisterAppRequest(serial, accessToken, frc,
- webSiteCookiesArray);
+ webSiteCookies);
String registerAppRequestJson = gson.toJson(registerAppRequest);
HashMap registerHeaders = new HashMap<>();
@@ -740,9 +734,6 @@ public class Connection {
registerAppRequestJson, true, registerHeaders);
JsonRegisterAppResponse registerAppResponse = parseJson(registerAppResultJson, JsonRegisterAppResponse.class);
- if (registerAppResponse == null) {
- throw new ConnectionException("Error: No response received from register application");
- }
Response response = registerAppResponse.response;
if (response == null) {
throw new ConnectionException("Error: No response received from register application");
@@ -770,9 +761,6 @@ public class Connection {
String usersMeResponseJson = makeRequestAndReturnString("GET",
"https://alexa.amazon.com/api/users/me?platform=ios&version=2.2.223830.0", null, false, null);
JsonUsersMeResponse usersMeResponse = parseJson(usersMeResponseJson, JsonUsersMeResponse.class);
- if (usersMeResponse == null) {
- throw new IllegalArgumentException("Received no response on me-request");
- }
URI uri = new URI(usersMeResponse.marketPlaceDomainName);
String host = uri.getHost();
@@ -928,6 +916,7 @@ public class Connection {
}
}
+ @SuppressWarnings("null") // current value in compute can be null
private void replaceTimer(TimerType type, @Nullable ScheduledFuture> newTimer) {
timers.compute(type, (timerType, oldTimer) -> {
if (oldTimer != null) {
@@ -967,9 +956,10 @@ public class Connection {
}
// parser
- private @Nullable T parseJson(String json, Class type) throws JsonSyntaxException, IllegalStateException {
+ private T parseJson(String json, Class type) throws JsonSyntaxException, IllegalStateException {
try {
- return gson.fromJson(json, type);
+ // gson.fromJson is always non-null if json is non-null
+ return Objects.requireNonNull(gson.fromJson(json, type));
} catch (JsonParseException | IllegalStateException e) {
logger.warn("Parsing json failed: {}", json, e);
throw e;
@@ -977,21 +967,16 @@ public class Connection {
}
// commands and states
- public WakeWord[] getWakeWords() {
+ public List getWakeWords() {
String json;
try {
json = makeRequestAndReturnString(alexaServer + "/api/wake-word?cached=true");
JsonWakeWords wakeWords = parseJson(json, JsonWakeWords.class);
- if (wakeWords != null) {
- WakeWord[] result = wakeWords.wakeWords;
- if (result != null) {
- return result;
- }
- }
+ return Objects.requireNonNullElse(wakeWords.wakeWords, List.of());
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.info("getting wakewords failed", e);
}
- return new WakeWord[0];
+ return List.of();
}
public List getSmarthomeDeviceList()
@@ -1001,9 +986,6 @@ public class Connection {
logger.debug("getSmartHomeDevices result: {}", json);
JsonNetworkDetails networkDetails = parseJson(json, JsonNetworkDetails.class);
- if (networkDetails == null) {
- throw new IllegalArgumentException("received no response on network detail request");
- }
Object jsonObject = gson.fromJson(networkDetails.networkDetail, Object.class);
List result = new ArrayList<>();
searchSmartHomeDevicesRecursive(jsonObject, result);
@@ -1023,15 +1005,11 @@ public class Connection {
// device node found, create type element and add it to the results
JsonElement element = gson.toJsonTree(jsonNode);
SmartHomeDevice shd = parseJson(element.toString(), SmartHomeDevice.class);
- if (shd != null) {
- devices.add(shd);
- }
+ devices.add(shd);
} else if (map.containsKey("applianceGroupName")) {
JsonElement element = gson.toJsonTree(jsonNode);
SmartHomeGroup shg = parseJson(element.toString(), SmartHomeGroup.class);
- if (shg != null) {
- devices.add(shg);
- }
+ devices.add(shg);
} else {
map.values().forEach(value -> searchSmartHomeDevicesRecursive(value, devices));
}
@@ -1062,8 +1040,10 @@ public class Connection {
String applianceId = device.findId();
if (applianceId != null) {
JsonObject stateRequest;
- if (device instanceof SmartHomeDevice && !((SmartHomeDevice) device).mergedApplianceIds.isEmpty()) {
- for (String idToMerge : ((SmartHomeDevice) device).mergedApplianceIds) {
+ if (device instanceof SmartHomeDevice && ((SmartHomeDevice) device).mergedApplianceIds != null) {
+ List mergedApplianceIds = Objects
+ .requireNonNullElse(((SmartHomeDevice) device).mergedApplianceIds, List.of());
+ for (String idToMerge : mergedApplianceIds) {
mergedApplianceMap.put(idToMerge, applianceId);
stateRequest = new JsonObject();
stateRequest.addProperty("entityId", idToMerge);
@@ -1125,22 +1105,16 @@ public class Connection {
return mediaState;
}
- public Activity[] getActivities(int number, @Nullable Long startTime) {
- String json;
+ public List getActivities(int number, @Nullable Long startTime) {
try {
- json = makeRequestAndReturnString(alexaServer + "/api/activities?startTime="
+ String json = makeRequestAndReturnString(alexaServer + "/api/activities?startTime="
+ (startTime != null ? startTime : "") + "&size=" + number + "&offset=1");
JsonActivities activities = parseJson(json, JsonActivities.class);
- if (activities != null) {
- Activity[] activiesArray = activities.activities;
- if (activiesArray != null) {
- return activiesArray;
- }
- }
+ return Objects.requireNonNullElse(activities.activities, List.of());
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.info("getting activities failed", e);
}
- return new Activity[0];
+ return List.of();
}
public @Nullable JsonBluetoothStates getBluetoothConnectionStates() {
@@ -1211,17 +1185,16 @@ public class Connection {
String resultBody = makeRequestAndReturnString("PUT", url, requestBody, true, null);
logger.trace("Request '{}' resulted in '{}", requestBody, resultBody);
JsonObject result = parseJson(resultBody, JsonObject.class);
- if (result != null) {
- JsonElement errors = result.get("errors");
- if (errors != null && errors.isJsonArray()) {
- JsonArray errorList = errors.getAsJsonArray();
- if (errorList.size() > 0) {
- logger.warn("Smart home device command failed. The request '{}' resulted in error(s): {}",
- requestBody, StreamSupport.stream(errorList.spliterator(), false)
- .map(JsonElement::toString).collect(Collectors.joining(" / ")));
- }
+ JsonElement errors = result.get("errors");
+ if (errors != null && errors.isJsonArray()) {
+ JsonArray errorList = errors.getAsJsonArray();
+ if (errorList.size() > 0) {
+ logger.warn("Smart home device command failed. The request '{}' resulted in error(s): {}",
+ requestBody, StreamSupport.stream(errorList.spliterator(), false).map(JsonElement::toString)
+ .collect(Collectors.joining(" / ")));
}
}
+
} catch (URISyntaxException e) {
logger.warn("URL '{}' has invalid format for request '{}': {}", url, requestBody, e.getMessage());
}
@@ -1245,38 +1218,28 @@ public class Connection {
makeRequest("PUT", url, command, true, true, null, 0);
}
- public DeviceNotificationState[] getDeviceNotificationStates() {
- String json;
+ public List getDeviceNotificationStates() {
try {
- json = makeRequestAndReturnString(alexaServer + "/api/device-notification-state");
+ String json = makeRequestAndReturnString(alexaServer + "/api/device-notification-state");
JsonDeviceNotificationState result = parseJson(json, JsonDeviceNotificationState.class);
- if (result != null) {
- DeviceNotificationState[] deviceNotificationStates = result.deviceNotificationStates;
- if (deviceNotificationStates != null) {
- return deviceNotificationStates;
- }
- }
+ return Objects.requireNonNullElse(result.deviceNotificationStates, List.of());
+
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.info("Error getting device notification states", e);
}
- return new DeviceNotificationState[0];
+ return List.of();
}
- public AscendingAlarmModel[] getAscendingAlarm() {
+ public List getAscendingAlarm() {
String json;
try {
json = makeRequestAndReturnString(alexaServer + "/api/ascending-alarm");
JsonAscendingAlarm result = parseJson(json, JsonAscendingAlarm.class);
- if (result != null) {
- AscendingAlarmModel[] ascendingAlarmModelList = result.ascendingAlarmModelList;
- if (ascendingAlarmModelList != null) {
- return ascendingAlarmModelList;
- }
- }
+ return Objects.requireNonNullElse(result.ascendingAlarmModelList, List.of());
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.info("Error getting device notification states", e);
}
- return new AscendingAlarmModel[0];
+ return List.of();
}
public void bluetooth(Device device, @Nullable String address)
@@ -1630,6 +1593,7 @@ public class Connection {
logger.debug("added {} device {}", queueObject.hashCode(), serialNumbers);
}
+ @SuppressWarnings("null") // peek can return null
private void handleExecuteSequenceNode() {
Lock lock = Objects.requireNonNull(locks.computeIfAbsent(TimerType.DEVICES, k -> new ReentrantLock()));
if (lock.tryLock()) {
@@ -1853,12 +1817,9 @@ public class Connection {
}
for (JsonAutomation routine : routines) {
if (routine != null) {
- Trigger[] triggers = routine.triggers;
- if (triggers != null && routine.sequence != null) {
+ if (routine.sequence != null) {
+ List triggers = Objects.requireNonNullElse(routine.triggers, List.of());
for (JsonAutomation.Trigger trigger : triggers) {
- if (trigger == null) {
- continue;
- }
Payload payload = trigger.payload;
if (payload == null) {
continue;
@@ -1921,20 +1882,13 @@ public class Connection {
return result;
}
- public JsonFeed[] getEnabledFlashBriefings() throws IOException, URISyntaxException, InterruptedException {
+ public List getEnabledFlashBriefings() throws IOException, URISyntaxException, InterruptedException {
String json = makeRequestAndReturnString(alexaServer + "/api/content-skills/enabled-feeds");
JsonEnabledFeeds result = parseJson(json, JsonEnabledFeeds.class);
- if (result == null) {
- return new JsonFeed[0];
- }
- JsonFeed[] enabledFeeds = result.enabledFeeds;
- if (enabledFeeds != null) {
- return enabledFeeds;
- }
- return new JsonFeed[0];
+ return Objects.requireNonNullElse(result.enabledFeeds, List.of());
}
- public void setEnabledFlashBriefings(JsonFeed[] enabledFlashBriefing)
+ public void setEnabledFlashBriefings(List enabledFlashBriefing)
throws IOException, URISyntaxException, InterruptedException {
JsonEnabledFeeds enabled = new JsonEnabledFeeds();
enabled.enabledFeeds = enabledFlashBriefing;
@@ -1942,33 +1896,19 @@ public class Connection {
makeRequest("POST", alexaServer + "/api/content-skills/enabled-feeds", json, true, true, null, 0);
}
- public JsonNotificationSound[] getNotificationSounds(Device device)
+ public List getNotificationSounds(Device device)
throws IOException, URISyntaxException, InterruptedException {
String json = makeRequestAndReturnString(
alexaServer + "/api/notification/sounds?deviceSerialNumber=" + device.serialNumber + "&deviceType="
+ device.deviceType + "&softwareVersion=" + device.softwareVersion);
JsonNotificationSounds result = parseJson(json, JsonNotificationSounds.class);
- if (result == null) {
- return new JsonNotificationSound[0];
- }
- JsonNotificationSound[] notificationSounds = result.notificationSounds;
- if (notificationSounds != null) {
- return notificationSounds;
- }
- return new JsonNotificationSound[0];
+ return Objects.requireNonNullElse(result.notificationSounds, List.of());
}
- public JsonNotificationResponse[] notifications() throws IOException, URISyntaxException, InterruptedException {
+ public List notifications() throws IOException, URISyntaxException, InterruptedException {
String response = makeRequestAndReturnString(alexaServer + "/api/notifications");
JsonNotificationsResponse result = parseJson(response, JsonNotificationsResponse.class);
- if (result == null) {
- return new JsonNotificationResponse[0];
- }
- JsonNotificationResponse[] notifications = result.notifications;
- if (notifications == null) {
- return new JsonNotificationResponse[0];
- }
- return notifications;
+ return Objects.requireNonNullElse(result.notifications, List.of());
}
public @Nullable JsonNotificationResponse notification(Device device, String type, @Nullable String label,
@@ -2019,8 +1959,8 @@ public class Connection {
String response = makeRequestAndReturnString("GET",
alexaServer + "/api/behaviors/entities?skillId=amzn1.ask.1p.music", null, true, headers);
if (!response.isEmpty()) {
- JsonMusicProvider[] result = parseJson(response, JsonMusicProvider[].class);
- return Arrays.asList(result);
+ JsonMusicProvider[] musicProviders = parseJson(response, JsonMusicProvider[].class);
+ return Arrays.asList(musicProviders);
}
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.warn("getMusicProviders fails: {}", e.getMessage());
@@ -2050,12 +1990,10 @@ public class Connection {
if (!validateResultJson.isEmpty()) {
JsonPlayValidationResult validationResult = parseJson(validateResultJson, JsonPlayValidationResult.class);
- if (validationResult != null) {
- JsonPlaySearchPhraseOperationPayload validatedOperationPayload = validationResult.operationPayload;
- if (validatedOperationPayload != null) {
- payload.sanitizedSearchPhrase = validatedOperationPayload.sanitizedSearchPhrase;
- payload.searchPhrase = validatedOperationPayload.searchPhrase;
- }
+ JsonPlaySearchPhraseOperationPayload validatedOperationPayload = validationResult.operationPayload;
+ if (validatedOperationPayload != null) {
+ payload.sanitizedSearchPhrase = validatedOperationPayload.sanitizedSearchPhrase;
+ payload.searchPhrase = validatedOperationPayload.searchPhrase;
}
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java
index 2a0ec2e35..410f0312a 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java
@@ -73,9 +73,7 @@ public class WebSocketConnection {
IWebSocketCommandHandler webSocketCommandHandler) throws IOException {
this.webSocketCommandHandler = webSocketCommandHandler;
amazonEchoControlWebSocket = new AmazonEchoControlWebSocket();
-
- SslContextFactory sslContextFactory = new SslContextFactory();
- webSocketClient = new WebSocketClient(sslContextFactory);
+ webSocketClient = new WebSocketClient(new SslContextFactory.Client());
try {
String host;
if (amazonSite.equalsIgnoreCase("amazon.com")) {
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java
index 8e4c07652..d69a041a5 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java
@@ -22,14 +22,12 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.amazonechocontrol.internal.Connection;
import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler;
import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler;
-import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDeviceAlias;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.DriverIdentity;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice;
@@ -171,25 +169,23 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
continue;
}
- JsonSmartHomeCapabilities.SmartHomeCapability[] capabilities = shd.capabilities;
- if (capabilities == null || Stream.of(capabilities).noneMatch(capability -> capability != null
- && Constants.SUPPORTED_INTERFACES.contains(capability.interfaceName))) {
+ if (shd.getCapabilities().stream()
+ .noneMatch(capability -> Constants.SUPPORTED_INTERFACES.contains(capability.interfaceName))) {
// No supported interface found
continue;
}
thingUID = new ThingUID(THING_TYPE_SMART_HOME_DEVICE, bridgeThingUID, entityId.replace(".", "-"));
- JsonSmartHomeDeviceAlias[] aliases = shd.aliases;
+ List aliases = shd.aliases;
if ("Amazon".equals(shd.manufacturerName) && driverIdentity != null
&& "SonarCloudService".equals(driverIdentity.identifier)) {
deviceName = "Alexa Guard on " + shd.friendlyName;
} else if ("Amazon".equals(shd.manufacturerName) && driverIdentity != null
&& "OnGuardSmartHomeBridgeService".equals(driverIdentity.identifier)) {
deviceName = "Alexa Guard";
- } else if (aliases != null && aliases.length > 0 && aliases[0] != null
- && aliases[0].friendlyName != null) {
- deviceName = aliases[0].friendlyName;
+ } else if (aliases != null && !aliases.isEmpty() && aliases.get(0).friendlyName != null) {
+ deviceName = aliases.get(0).friendlyName;
} else {
deviceName = shd.friendlyName;
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java
index 277b67083..19077a583 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java
@@ -17,15 +17,7 @@ import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.time.ZonedDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledFuture;
@@ -44,7 +36,6 @@ import org.openhab.binding.amazonechocontrol.internal.WebSocketConnection;
import org.openhab.binding.amazonechocontrol.internal.channelhandler.ChannelHandler;
import org.openhab.binding.amazonechocontrol.internal.channelhandler.ChannelHandlerSendMessage;
import org.openhab.binding.amazonechocontrol.internal.channelhandler.IAmazonThingHandler;
-import org.openhab.binding.amazonechocontrol.internal.jsons.JsonActivities.Activity.SourceDeviceId;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonAscendingAlarm.AscendingAlarmModel;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonBluetoothStates;
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonBluetoothStates.BluetoothState;
@@ -473,18 +464,17 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
if (!currentConnection.getIsLoggedIn()) {
return;
}
- JsonNotificationResponse[] notifications;
+
ZonedDateTime timeStamp = ZonedDateTime.now();
try {
- notifications = currentConnection.notifications();
+ List notifications = currentConnection.notifications();
+ ZonedDateTime timeStampNow = ZonedDateTime.now();
+ echoHandlers.forEach(echoHandler -> echoHandler.updateNotifications(timeStamp, timeStampNow, pushPayload,
+ notifications));
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.debug("refreshNotifications failed", e);
return;
}
- ZonedDateTime timeStampNow = ZonedDateTime.now();
-
- echoHandlers.forEach(
- echoHandler -> echoHandler.updateNotifications(timeStamp, timeStampNow, pushPayload, notifications));
}
private void refreshData() {
@@ -509,8 +499,8 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
updateSmartHomeDeviceList(false);
updateFlashBriefingHandlers();
- DeviceNotificationState[] deviceNotificationStates = null;
- AscendingAlarmModel[] ascendingAlarmModels = null;
+ List deviceNotificationStates = List.of();
+ List ascendingAlarmModels = List.of();
JsonBluetoothStates states = null;
List musicProviders = null;
if (currentConnection.getIsLoggedIn()) {
@@ -536,7 +526,7 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
for (EchoHandler child : echoHandlers) {
Device device = findDeviceJson(child.findSerialNumber());
- JsonNotificationSound[] notificationSounds = null;
+ List notificationSounds = List.of();
JsonPlaylists playlists = null;
if (device != null && currentConnection.getIsLoggedIn()) {
// update notification sounds
@@ -562,17 +552,12 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
if (device != null) {
final String serialNumber = device.serialNumber;
if (serialNumber != null) {
- if (ascendingAlarmModels != null) {
- ascendingAlarmModel = Arrays.stream(ascendingAlarmModels).filter(Objects::nonNull)
- .filter(current -> serialNumber.equals(current.deviceSerialNumber)).findFirst()
- .orElse(null);
- }
- if (deviceNotificationStates != null) {
- deviceNotificationState = Arrays.stream(deviceNotificationStates)
- .filter(Objects::nonNull)
- .filter(current -> serialNumber.equals(current.deviceSerialNumber)).findFirst()
- .orElse(null);
- }
+ ascendingAlarmModel = ascendingAlarmModels.stream()
+ .filter(current -> serialNumber.equals(current.deviceSerialNumber)).findFirst()
+ .orElse(null);
+ deviceNotificationState = deviceNotificationStates.stream()
+ .filter(current -> serialNumber.equals(current.deviceSerialNumber)).findFirst()
+ .orElse(null);
}
}
child.updateState(this, device, state, deviceNotificationState, ascendingAlarmModel, playlists,
@@ -631,19 +616,13 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
.collect(Collectors.toMap(d -> Objects.requireNonNull(d.serialNumber), d -> d));
}
- WakeWord[] wakeWords = currentConnection.getWakeWords();
+ List wakeWords = currentConnection.getWakeWords();
// update handlers
for (EchoHandler echoHandler : echoHandlers) {
String serialNumber = echoHandler.findSerialNumber();
- String deviceWakeWord = null;
- for (WakeWord wakeWord : wakeWords) {
- if (wakeWord != null) {
- if (serialNumber.equals(wakeWord.deviceSerialNumber)) {
- deviceWakeWord = wakeWord.wakeWord;
- break;
- }
- }
- }
+ String deviceWakeWord = wakeWords.stream()
+ .filter(wakeWord -> serialNumber.equals(wakeWord.deviceSerialNumber)).findFirst()
+ .map(wakeWord -> wakeWord.wakeWord).orElse(null);
echoHandler.setDeviceAndUpdateThingState(this, findDeviceJson(serialNumber), deviceWakeWord);
}
@@ -658,7 +637,7 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
JsonFeed[] feeds = gson.fromJson(flashBriefingJson, JsonFeed[].class);
if (currentConnection != null && feeds != null) {
try {
- currentConnection.setEnabledFlashBriefings(feeds);
+ currentConnection.setEnabledFlashBriefings(Arrays.asList(feeds));
} catch (IOException | URISyntaxException | InterruptedException e) {
logger.warn("Set flashbriefing profile failed", e);
}
@@ -707,17 +686,9 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
private void updateFlashBriefingProfiles(Connection currentConnection) {
try {
- JsonFeed[] feeds = currentConnection.getEnabledFlashBriefings();
// Make a copy and remove changeable parts
- JsonFeed[] forSerializer = new JsonFeed[feeds.length];
- for (int i = 0; i < feeds.length; i++) {
- JsonFeed source = feeds[i];
- JsonFeed copy = new JsonFeed();
- copy.feedId = source.feedId;
- copy.skillId = source.skillId;
- // Do not copy imageUrl here, because it will change
- forSerializer[i] = copy;
- }
+ JsonFeed[] forSerializer = currentConnection.getEnabledFlashBriefings().stream()
+ .map(source -> new JsonFeed(source.feedId, source.skillId)).toArray(JsonFeed[]::new);
this.currentFlashBriefingJson = gson.toJson(forSerializer);
} catch (HttpException | JsonSyntaxException | IOException | URISyntaxException | ConnectionException
| InterruptedException e) {
@@ -796,17 +767,12 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
}
String search = key.registeredUserId + "#" + key.entryId;
- Arrays.stream(connection.getActivities(10, pushActivity.timestamp))
- .filter(activity -> activity != null && search.equals(activity.id)).findFirst()
- .ifPresent(currentActivity -> {
- SourceDeviceId[] sourceDeviceIds = currentActivity.sourceDeviceIds;
- if (sourceDeviceIds != null) {
- Arrays.stream(sourceDeviceIds).filter(Objects::nonNull)
- .map(sourceDeviceId -> findEchoHandlerBySerialNumber(sourceDeviceId.serialNumber))
- .filter(Objects::nonNull).forEach(echoHandler -> Objects.requireNonNull(echoHandler)
- .handlePushActivity(currentActivity));
- }
- });
+ connection.getActivities(10, pushActivity.timestamp).stream().filter(activity -> search.equals(activity.id))
+ .findFirst()
+ .ifPresent(currentActivity -> currentActivity.getSourceDeviceIds().stream()
+ .map(sourceDeviceId -> findEchoHandlerBySerialNumber(sourceDeviceId.serialNumber))
+ .filter(Objects::nonNull).forEach(echoHandler -> Objects.requireNonNull(echoHandler)
+ .handlePushActivity(currentActivity)));
}
void refreshAfterCommand() {
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java
index 40db31184..342ecb323 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java
@@ -24,8 +24,6 @@ import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -122,8 +120,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
private @Nullable Integer notificationVolumeLevel;
private @Nullable Boolean ascendingAlarm;
private @Nullable JsonPlaylists playLists;
- private @Nullable JsonNotificationSound @Nullable [] alarmSounds;
- private @Nullable List musicProviders;
+ private List alarmSounds = List.of();
+ private List musicProviders = List.of();
private List channelHandlers = new ArrayList<>();
private @Nullable JsonNotificationResponse currentNotification;
@@ -163,10 +161,7 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
return false;
}
this.device = device;
- String[] capabilities = device.capabilities;
- if (capabilities != null) {
- this.capabilities = Stream.of(capabilities).filter(Objects::nonNull).collect(Collectors.toSet());
- }
+ this.capabilities = device.getCapabilities();
if (!device.online) {
updateStatus(ThingStatus.OFFLINE);
return false;
@@ -204,11 +199,11 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
return this.playLists;
}
- public @Nullable JsonNotificationSound @Nullable [] findAlarmSounds() {
+ public List findAlarmSounds() {
return this.alarmSounds;
}
- public @Nullable List findMusicProviders() {
+ public List findMusicProviders() {
return this.musicProviders;
}
@@ -444,17 +439,11 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
String bluetoothId = lastKnownBluetoothMAC;
BluetoothState state = bluetoothState;
if (state != null && (bluetoothId == null || bluetoothId.isEmpty())) {
- PairedDevice[] pairedDeviceList = state.pairedDeviceList;
- if (pairedDeviceList != null) {
- for (PairedDevice paired : pairedDeviceList) {
- if (paired == null) {
- continue;
- }
- String pairedAddress = paired.address;
- if (pairedAddress != null && !pairedAddress.isEmpty()) {
- lastKnownBluetoothMAC = pairedAddress;
- break;
- }
+ for (PairedDevice paired : state.getPairedDeviceList()) {
+ String pairedAddress = paired.address;
+ if (pairedAddress != null && !pairedAddress.isEmpty()) {
+ lastKnownBluetoothMAC = pairedAddress;
+ break;
}
}
}
@@ -806,8 +795,7 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
public void updateState(AccountHandler accountHandler, @Nullable Device device,
@Nullable BluetoothState bluetoothState, @Nullable DeviceNotificationState deviceNotificationState,
@Nullable AscendingAlarmModel ascendingAlarmModel, @Nullable JsonPlaylists playlists,
- @Nullable JsonNotificationSound @Nullable [] alarmSounds,
- @Nullable List musicProviders) {
+ @Nullable List alarmSounds, @Nullable List musicProviders) {
try {
this.logger.debug("Handle updateState {}", this.getThing().getUID());
@@ -974,24 +962,19 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
boolean bluetoothIsConnected = false;
if (bluetoothState != null) {
this.bluetoothState = bluetoothState;
- PairedDevice[] pairedDeviceList = bluetoothState.pairedDeviceList;
- if (pairedDeviceList != null) {
- for (PairedDevice paired : pairedDeviceList) {
- if (paired == null) {
- continue;
- }
- String pairedAddress = paired.address;
- if (paired.connected && pairedAddress != null) {
- bluetoothIsConnected = true;
- bluetoothMAC = pairedAddress;
- bluetoothDeviceName = paired.friendlyName;
- if (bluetoothDeviceName == null || bluetoothDeviceName.isEmpty()) {
- bluetoothDeviceName = pairedAddress;
- }
- break;
+ for (PairedDevice paired : bluetoothState.getPairedDeviceList()) {
+ String pairedAddress = paired.address;
+ if (paired.connected && pairedAddress != null) {
+ bluetoothIsConnected = true;
+ bluetoothMAC = pairedAddress;
+ bluetoothDeviceName = paired.friendlyName;
+ if (bluetoothDeviceName == null || bluetoothDeviceName.isEmpty()) {
+ bluetoothDeviceName = pairedAddress;
}
+ break;
}
}
+
}
if (!bluetoothMAC.isEmpty()) {
lastKnownBluetoothMAC = bluetoothMAC;
@@ -1036,22 +1019,21 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
}
}
if (mediaState != null) {
- QueueEntry[] queueEntries = mediaState.queue;
- if (queueEntries != null && queueEntries.length > 0) {
- QueueEntry entry = queueEntries[0];
- if (entry != null) {
- if (isRadio) {
- if ((imageUrl == null || imageUrl.isEmpty()) && entry.imageURL != null) {
- imageUrl = entry.imageURL;
- }
- if ((subTitle1 == null || subTitle1.isEmpty()) && entry.radioStationSlogan != null) {
- subTitle1 = entry.radioStationSlogan;
- }
- if ((subTitle2 == null || subTitle2.isEmpty()) && entry.radioStationLocation != null) {
- subTitle2 = entry.radioStationLocation;
- }
+ List queueEntries = Objects.requireNonNullElse(mediaState.queue, List.of());
+ if (!queueEntries.isEmpty()) {
+ QueueEntry entry = queueEntries.get(0);
+ if (isRadio) {
+ if ((imageUrl == null || imageUrl.isEmpty()) && entry.imageURL != null) {
+ imageUrl = entry.imageURL;
+ }
+ if ((subTitle1 == null || subTitle1.isEmpty()) && entry.radioStationSlogan != null) {
+ subTitle1 = entry.radioStationSlogan;
+ }
+ if ((subTitle2 == null || subTitle2.isEmpty()) && entry.radioStationLocation != null) {
+ subTitle2 = entry.radioStationLocation;
}
}
+
}
}
@@ -1287,7 +1269,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
}
public void updateNotifications(ZonedDateTime currentTime, ZonedDateTime now,
- @Nullable JsonCommandPayloadPushNotificationChange pushPayload, JsonNotificationResponse[] notifications) {
+ @Nullable JsonCommandPayloadPushNotificationChange pushPayload,
+ List notifications) {
Device device = this.device;
if (device == null) {
return;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java
index 594215abf..c2bba5ad7 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java
@@ -16,7 +16,7 @@ import static org.openhab.binding.amazonechocontrol.internal.AmazonEchoControlBi
import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.SUPPORTED_INTERFACES;
import java.util.*;
-import java.util.function.Supplier;
+import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -93,15 +93,15 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
if (handler != null) {
unusedHandlers.remove(interfaceName);
} else {
- Supplier creator = Constants.HANDLER_FACTORY.get(interfaceName);
+ Function creator = Constants.HANDLER_FACTORY.get(interfaceName);
if (creator != null) {
- handler = creator.get();
+ handler = creator.apply(this);
handlers.put(interfaceName, handler);
}
}
if (handler != null) {
- Collection required = handler.initialize(this,
- capabilities.getOrDefault(interfaceName, Collections.emptyList()));
+ Collection required = handler
+ .initialize(capabilities.getOrDefault(interfaceName, List.of()));
for (ChannelInfo channelInfo : required) {
unusedChannels.remove(channelInfo.channelId);
if (addChannelToDevice(thingBuilder, channelInfo.channelId, channelInfo.itemType,
@@ -289,13 +289,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
if (entityId == null) {
continue;
}
- SmartHomeCapability[] capabilities = shd.capabilities;
- if (capabilities == null) {
- logger.debug("capabilities is null in {}", thing.getUID());
- return;
- }
accountHandler.forceDelayedSmartHomeStateUpdate(getId()); // block updates
- if (handlerBase.handleCommand(connection, shd, entityId, capabilities, channelUID.getId(),
+ if (handlerBase.handleCommand(connection, shd, entityId, shd.getCapabilities(), channelUID.getId(),
command)) {
accountHandler.forceDelayedSmartHomeStateUpdate(getId()); // force update again to restart
// update timer
@@ -312,11 +307,7 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
SmartHomeBaseDevice device) {
if (device instanceof SmartHomeDevice) {
SmartHomeDevice shd = (SmartHomeDevice) device;
- SmartHomeCapability[] capabilities = shd.capabilities;
- if (capabilities == null) {
- return;
- }
- for (SmartHomeCapability capability : capabilities) {
+ for (SmartHomeCapability capability : shd.getCapabilities()) {
String interfaceName = capability.interfaceName;
if (interfaceName != null) {
Objects.requireNonNull(result.computeIfAbsent(interfaceName, name -> new ArrayList<>()))
@@ -340,12 +331,10 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
Set result = new HashSet<>();
if (baseDevice instanceof SmartHomeDevice) {
SmartHomeDevice shd = (SmartHomeDevice) baseDevice;
- SmartHomeCapability[] capabilities = shd.capabilities;
- if (capabilities != null) {
- if (Arrays.stream(capabilities).map(capability -> capability.interfaceName)
- .anyMatch(SUPPORTED_INTERFACES::contains)) {
- result.add(shd);
- }
+ if (shd.getCapabilities().stream().map(capability -> capability.interfaceName)
+ .anyMatch(SUPPORTED_INTERFACES::contains)) {
+ result.add(shd);
+
}
} else {
SmartHomeGroup shg = (SmartHomeGroup) baseDevice;
@@ -356,13 +345,12 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
if (tags != null) {
JsonSmartHomeGroupIdentity.SmartHomeGroupIdentity tagNameToValueSetMap = tags.tagNameToValueSetMap;
JsonSmartHomeGroupIdentifiers.SmartHomeGroupIdentifier applianceGroupIdentifier = shg.applianceGroupIdentifier;
- if (tagNameToValueSetMap != null && tagNameToValueSetMap.groupIdentity != null
- && applianceGroupIdentifier != null && applianceGroupIdentifier.value != null
- && Arrays.asList(tagNameToValueSetMap.groupIdentity)
- .contains(applianceGroupIdentifier.value)) {
- SmartHomeCapability[] capabilities = shd.capabilities;
- if (capabilities != null) {
- if (Arrays.stream(capabilities).map(capability -> capability.interfaceName)
+ if (tagNameToValueSetMap != null) {
+ List groupIdentity = Objects.requireNonNullElse(tagNameToValueSetMap.groupIdentity,
+ List.of());
+ if (applianceGroupIdentifier != null && applianceGroupIdentifier.value != null
+ && groupIdentity.contains(applianceGroupIdentifier.value)) {
+ if (shd.getCapabilities().stream().map(capability -> capability.interfaceName)
.anyMatch(SUPPORTED_INTERFACES::contains)) {
result.add(shd);
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonActivities.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonActivities.java
index 0ad4f2363..c4cb88d90 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonActivities.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonActivities.java
@@ -12,6 +12,9 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
+import java.util.Objects;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -26,7 +29,7 @@ import com.google.gson.JsonSyntaxException;
@NonNullByDefault
public class JsonActivities {
- public @Nullable Activity @Nullable [] activities;
+ public @Nullable List activities;
public static class Activity {
public @Nullable String activityStatus;
@@ -40,10 +43,14 @@ public class JsonActivities {
public @Nullable String providerInfoDescription;
public @Nullable String registeredCustomerId;
public @Nullable Object sourceActiveUsers;
- public @Nullable SourceDeviceId @Nullable [] sourceDeviceIds;
+ public @Nullable List sourceDeviceIds;
public @Nullable String utteranceId;
public @Nullable Long version;
+ public List getSourceDeviceIds() {
+ return Objects.requireNonNullElse(sourceDeviceIds, List.of());
+ }
+
public static class SourceDeviceId {
public @Nullable String deviceAccountId;
public @Nullable String deviceType;
@@ -51,7 +58,6 @@ public class JsonActivities {
}
public static class Description {
-
public @Nullable String summary;
public @Nullable String firstUtteranceId;
public @Nullable String firstStreamId;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAscendingAlarm.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAscendingAlarm.java
index 0ff74be87..265678b93 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAscendingAlarm.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAscendingAlarm.java
@@ -12,6 +12,8 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -23,7 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
@NonNullByDefault
public class JsonAscendingAlarm {
- public @Nullable AscendingAlarmModel @Nullable [] ascendingAlarmModelList;
+ public @Nullable List ascendingAlarmModelList;
public static class AscendingAlarmModel {
public @Nullable Boolean ascendingAlarmEnabled;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAutomation.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAutomation.java
index cb8f29167..02c3b92db 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAutomation.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonAutomation.java
@@ -12,6 +12,7 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
import java.util.TreeMap;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -26,7 +27,7 @@ import org.eclipse.jdt.annotation.Nullable;
public class JsonAutomation {
public @Nullable String automationId;
public @Nullable String name;
- public @Nullable Trigger @Nullable [] triggers;
+ public @Nullable List triggers;
public @Nullable TreeMap sequence;
public @Nullable String status;
public long creationTimeEpochMillis;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonBluetoothStates.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonBluetoothStates.java
index 9d41e6032..d6007d27d 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonBluetoothStates.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonBluetoothStates.java
@@ -12,6 +12,7 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
import java.util.Objects;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -50,7 +51,7 @@ public class JsonBluetoothStates {
public boolean connected;
public @Nullable String deviceClass;
public @Nullable String friendlyName;
- public @Nullable String @Nullable [] profiles;
+ public @Nullable List profiles;
}
public static class BluetoothState {
@@ -59,6 +60,10 @@ public class JsonBluetoothStates {
public @Nullable String friendlyName;
public boolean gadgetPaired;
public boolean online;
- public @Nullable PairedDevice @Nullable [] pairedDeviceList;
+ public @Nullable List pairedDeviceList;
+
+ public List getPairedDeviceList() {
+ return Objects.requireNonNullElse(pairedDeviceList, List.of());
+ }
}
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDeviceNotificationState.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDeviceNotificationState.java
index 07c15a27d..87ff2649f 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDeviceNotificationState.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDeviceNotificationState.java
@@ -12,6 +12,8 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -23,7 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
@NonNullByDefault
public class JsonDeviceNotificationState {
- public @Nullable DeviceNotificationState @Nullable [] deviceNotificationStates;
+ public @Nullable List deviceNotificationStates;
public static class DeviceNotificationState {
public @Nullable String deviceSerialNumber;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDevices.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDevices.java
index 332854a32..96353c06c 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDevices.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonDevices.java
@@ -12,8 +12,9 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
-import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
+import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -35,7 +36,11 @@ public class JsonDevices {
public @Nullable String deviceType;
public @Nullable String softwareVersion;
public boolean online;
- public @Nullable String @Nullable [] capabilities;
+ public @Nullable Set capabilities;
+
+ public Set getCapabilities() {
+ return Objects.requireNonNullElse(capabilities, Set.of());
+ }
@Override
public String toString() {
@@ -43,7 +48,7 @@ public class JsonDevices {
+ ", deviceOwnerCustomerId='" + deviceOwnerCustomerId + '\'' + ", deviceAccountId='"
+ deviceAccountId + '\'' + ", deviceFamily='" + deviceFamily + '\'' + ", deviceType='" + deviceType
+ '\'' + ", softwareVersion='" + softwareVersion + '\'' + ", online=" + online + ", capabilities="
- + Arrays.toString(capabilities) + '}';
+ + capabilities + '}';
}
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEnabledFeeds.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEnabledFeeds.java
index 0807f15ae..5f21bb03e 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEnabledFeeds.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEnabledFeeds.java
@@ -12,6 +12,8 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -22,5 +24,5 @@ import org.eclipse.jdt.annotation.Nullable;
*/
@NonNullByDefault
public class JsonEnabledFeeds {
- public @Nullable JsonFeed @Nullable [] enabledFeeds;
+ public @Nullable List enabledFeeds;
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEqualizer.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEqualizer.java
index 405a2c585..f69e6a2e5 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEqualizer.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonEqualizer.java
@@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
- * The {@link JsonActivity} encapsulate the GSON data of the get equalizer command
+ * The {@link JsonEqualizer} encapsulate the GSON data of the get equalizer command
*
* @author Michael Geramb - Initial contribution
*/
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonFeed.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonFeed.java
index 55b273662..d99abfbdf 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonFeed.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonFeed.java
@@ -26,4 +26,9 @@ public class JsonFeed {
public @Nullable String name;
public @Nullable String skillId;
public @Nullable String imageUrl;
+
+ public JsonFeed(@Nullable Object feedId, @Nullable String skillId) {
+ this.feedId = feedId;
+ this.skillId = skillId;
+ }
}
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMediaState.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMediaState.java
index 4bbe4a38e..bd6aaca54 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMediaState.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMediaState.java
@@ -12,6 +12,8 @@
*/
package org.openhab.binding.amazonechocontrol.internal.jsons;
+import java.util.List;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -36,7 +38,7 @@ public class JsonMediaState {
public @Nullable String programId;
public int progressSeconds;
public @Nullable String providerId;
- public @Nullable QueueEntry @Nullable [] queue;
+ public @Nullable List queue;
public @Nullable String queueId;
public @Nullable Integer queueSize;
public @Nullable String radioStationId;
@@ -48,7 +50,6 @@ public class JsonMediaState {
public int volume;
public static class QueueEntry {
-
public @Nullable String album;
public @Nullable String albumAsin;
public @Nullable String artist;
diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMusicProvider.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMusicProvider.java
index 99ee115c6..08ce275b1 100644
--- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMusicProvider.java
+++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonMusicProvider.java
@@ -25,7 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
@NonNullByDefault
public class JsonMusicProvider {
public @Nullable String displayName;
- public @Nullable List |