[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

@@ -43,7 +43,10 @@ public class SensorId {
* - characters are case-insensitive
* - hubs ("1F.xxxxxxxxxxxx/aux/") may be repeated
*/
public SensorId(String fullPath) {
public SensorId(@Nullable String fullPath) {
if (fullPath == null) {
throw new IllegalArgumentException();
}
Matcher matcher = SENSOR_ID_PATTERN.matcher(fullPath);
if (matcher.matches() && matcher.groupCount() == 2) {
path = matcher.group(1) == null ? "" : matcher.group(1);

View File

@@ -118,8 +118,8 @@ public class OwDiscoveryItem {
* @return ThingTypeUID if mapping successful
*/
public ThingTypeUID getThingTypeUID() throws OwException {
if (THING_TYPE_MAP.containsKey(sensorType)) {
thingTypeUID = THING_TYPE_MAP.get(sensorType);
ThingTypeUID thingTypeUID = THING_TYPE_MAP.get(sensorType);
if (thingTypeUID != null) {
return thingTypeUID;
} else {
throw new OwException(sensorType + " cannot be mapped to thing type");

View File

@@ -90,17 +90,20 @@ public class AdvancedMultisensorThingHandler extends OwBaseThingHandler {
return;
}
hwRevision = Integer.valueOf(properties.get(PROPERTY_HW_REVISION));
hwRevision = Integer.valueOf(properties.getOrDefault(PROPERTY_HW_REVISION, "0"));
sensors.add(new DS2438(sensorId, this));
sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this));
if (THING_TYPE_AMS.equals(thingType)) {
sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this));
sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this));
digitalRefreshInterval = configuration.digitalRefresh * 1000;
digitalLastRefresh = 0;
try {
sensors.add(new DS2438(sensorId, this));
sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this));
if (THING_TYPE_AMS.equals(thingType)) {
sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this));
sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this));
digitalRefreshInterval = configuration.digitalRefresh * 1000;
digitalLastRefresh = 0;
}
} catch (IllegalArgumentException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "properties invalid");
}
scheduler.execute(() -> {
configureThingChannels();
});