[infrastructure] add external null-annotations (#8848)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K
2020-10-31 00:29:03 +01:00
committed by GitHub
parent 47d05055db
commit bd664ff0c8
162 changed files with 933 additions and 575 deletions

View File

@@ -59,7 +59,7 @@ public class ShellyApiException extends Exception {
}
@Override
public String getMessage() {
public @Nullable String getMessage() {
return isEmpty() ? "" : nonNullString(super.getMessage());
}

View File

@@ -235,7 +235,7 @@ public class ShellyCoIoTProtocol {
Double brightness = -1.0;
Double power = -1.0;
for (CoIotSensor update : allUpdates) {
CoIotDescrSen d = fixDescription(sensorMap.get(update.id), blkMap);
CoIotDescrSen d = fixDescription(sensorMap.getOrDefault(update.id, new CoIotDescrSen()), blkMap);
if (!checkL.isEmpty() && !d.links.equals(checkL)) {
// continue until we find the correct one
continue;

View File

@@ -124,12 +124,13 @@ public class ShellyThingCreator {
}
// Check general mapping
if (!deviceType.isEmpty() && THING_TYPE_MAPPING.containsKey(deviceType)) {
return THING_TYPE_MAPPING.get(deviceType);
if (!deviceType.isEmpty()) {
String str = THING_TYPE_MAPPING.get(deviceType);
if (str != null) {
return str;
}
}
if (THING_TYPE_MAPPING.containsKey(type)) {
return THING_TYPE_MAPPING.get(type);
}
return THING_TYPE_SHELLYUNKNOWN_STR;
return THING_TYPE_MAPPING.getOrDefault(type, THING_TYPE_SHELLYUNKNOWN_STR);
}
}

View File

@@ -120,10 +120,7 @@ public class ShellyChannelCache {
}
public State getValue(String channelId) {
if (channelData.containsKey(channelId)) {
return channelData.get(channelId);
}
return UnDefType.NULL;
return channelData.getOrDefault(channelId, UnDefType.NULL);
}
public void resetChannel(String channelId) {