]> git.basschouten.com Git - openhab-addons.git/commitdiff
[infrastructure] move infered nullness warnings to error and update EEA (#8949)
authorJ-N-K <J-N-K@users.noreply.github.com>
Thu, 12 Nov 2020 20:07:11 +0000 (21:07 +0100)
committerGitHub <noreply@github.com>
Thu, 12 Nov 2020 20:07:11 +0000 (21:07 +0100)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
155 files changed:
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/channelhandler/ChannelHandlerAnnouncement.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonRegisterAppRequest.java
bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/processor/RemoteSensor.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/util/PropertyUtils.java
bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBluetoothDevice.java
bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java
bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/AbstractBluetoothBridgeHandler.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/MockBluetoothAdapter.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/BsbLanBindingConstants.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/BsbLanHandlerFactory.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account/SmartherAuthorizationServlet.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApi.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/ThingHandlerPanel.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/GroupTypeDeserializer.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightTypeDeserializer.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ResourceTypeDeserializer.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ThermostatModeGsonTypeAdapter.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/handler/DigiplexAreaHandler.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/handler/DigiplexZoneHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/BridgeDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/BridgeMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java
bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/data/DwdWarningsData.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/action/EcobeeActions.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/dto/SelectionDTO.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/TransmitterStick.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/AbstractFMIResponseParsingTest.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiConnector.java
bundles/org.openhab.binding.foobot/src/test/java/org/openhab/binding/foobot/internal/handler/FoobotDeviceHandlerTest.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/FSInternetRadioHandlerJavaTest.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/RadioServiceDummy.java
bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/MessageUtil.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeException.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDiscoveryService.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java
bundles/org.openhab.binding.harmonyhub/src/main/java/org/openhab/binding/harmonyhub/internal/discovery/HarmonyHubDiscoveryService.java
bundles/org.openhab.binding.heos/src/main/java/org/openhab/binding/heos/internal/handler/HeosBridgeHandler.java
bundles/org.openhab.binding.heos/src/main/java/org/openhab/binding/heos/internal/json/HeosJsonParser.java
bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/HueBridge.java
bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/discovery/HueBridgeNupnpDiscovery.java
bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseCloudHandler.java
bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseHandler.java
bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseCloudApiClient.java
bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseLocalApiClient.java
bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/api/IAqualinkClient.java
bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java
bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java
bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DeviceFeature.java
bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DeviceTypeLoader.java
bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonDeviceHandler.java
bundles/org.openhab.binding.jablotron/src/main/java/org/openhab/binding/jablotron/internal/handler/JablotronJa100Handler.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Utils.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200SwitchProgramServiceHandler.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200ThingHandler.java
bundles/org.openhab.binding.kvv/src/main/java/org/openhab/binding/kvv/internal/KVVBridgeHandler.java
bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java
bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/Connection.java
bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/ConnectionStateConnecting.java
bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/command/ServiceCommand.java
bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/command/ServiceSubscription.java
bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java
bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java
bundles/org.openhab.binding.loxone/src/main/java/org/openhab/binding/loxone/internal/LxServerHandler.java
bundles/org.openhab.binding.luftdateninfo/src/main/java/org/openhab/binding/luftdateninfo/internal/handler/HTTPHandler.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/HTTPHandlerEvalTest.java
bundles/org.openhab.binding.luftdateninfo/src/test/java/org/openhab/binding/luftdateninfo/internal/HTTPHandlerValueTest.java
bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/discovery/LeapDeviceDiscoveryService.java
bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/leap/LeapMessageParser.java
bundles/org.openhab.binding.magentatv/src/main/java/org/openhab/binding/magentatv/internal/handler/MagentaTVControl.java
bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java
bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java
bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/handler/ModbusDataThingHandler.java
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/BaseChannelConfiguration.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/ChannelConfigurationTypeAdapterFactory.java
bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java
bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/NeeoBrainApi.java
bundles/org.openhab.binding.neeo/src/main/java/org/openhab/binding/neeo/internal/handler/NeeoBrainHandler.java
bundles/org.openhab.binding.neohub/src/main/java/org/openhab/binding/neohub/internal/NeohubBoolDeserializer.java
bundles/org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/update/NestUpdateHandler.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/webhook/WelcomeWebHookServlet.java
bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc1/NikoHomeControlCommunication1.java
bundles/org.openhab.binding.nikohomecontrol/src/main/java/org/openhab/binding/nikohomecontrol/internal/protocol/nhc2/NikoHomeControlCommunication2.java
bundles/org.openhab.binding.ntp/src/main/java/org/openhab/binding/ntp/internal/handler/NtpHandler.java
bundles/org.openhab.binding.nuki/src/main/java/org/openhab/binding/nuki/internal/NukiHandlerFactory.java
bundles/org.openhab.binding.nuki/src/main/java/org/openhab/binding/nuki/internal/dataexchange/NukiHttpClient.java
bundles/org.openhab.binding.onebusaway/src/main/java/org/openhab/binding/onebusaway/internal/handler/StopHandler.java
bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/handler/BAE091xSensorThingHandler.java
bundles/org.openhab.binding.pixometer/src/main/java/org/openhab/binding/pixometer/handler/MeterHandler.java
bundles/org.openhab.binding.remoteopenhab/src/main/java/org/openhab/binding/remoteopenhab/internal/rest/RemoteopenhabRestClient.java
bundles/org.openhab.binding.revogi/src/main/java/org/openhab/binding/revogi/internal/api/StatusService.java
bundles/org.openhab.binding.revogi/src/main/java/org/openhab/binding/revogi/internal/api/SwitchService.java
bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/discovery/RFXComDeviceDiscoveryService.java
bundles/org.openhab.binding.rotel/src/main/java/org/openhab/binding/rotel/internal/communication/RotelConnector.java
bundles/org.openhab.binding.rotel/src/main/java/org/openhab/binding/rotel/internal/communication/RotelSimuConnector.java
bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MainTVServerService.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/event/IntegraStateEvent.java
bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java
bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeHandler.java
bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboAccountHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java
bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/points/PointDeserializer.java
bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/SmartMeterHandler.java
bundles/org.openhab.binding.smartmeter/src/main/java/org/openhab/binding/smartmeter/internal/conformity/Conformity.java
bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/SmartthingsHandlerFactory.java
bundles/org.openhab.binding.smartthings/src/main/java/org/openhab/binding/smartthings/internal/discovery/SmartthingsDiscoveryService.java
bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java
bundles/org.openhab.binding.somfymylink/src/main/java/org/openhab/binding/somfymylink/internal/handler/SomfyMyLinkBridgeHandler.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java
bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/api/SpotifyApi.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/builder/ZoneSettingsBuilder.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoZoneHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusThingHandler.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java
bundles/org.openhab.binding.vigicrues/src/main/java/org/openhab/binding/vigicrues/internal/handler/VigiCruesHandler.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/api/VocHttpApi.java
bundles/org.openhab.binding.weathercompany/src/main/java/org/openhab/binding/weathercompany/internal/handler/WeatherCompanyForecastHandler.java
bundles/org.openhab.binding.weathercompany/src/main/java/org/openhab/binding/weathercompany/internal/handler/WeatherCompanyObservationsHandler.java
bundles/org.openhab.binding.wlanthermo/src/main/java/org/openhab/binding/wlanthermo/internal/WlanThermoMiniHandler.java
bundles/org.openhab.binding.wlanthermo/src/main/java/org/openhab/binding/wlanthermo/internal/WlanThermoNanoHandler.java
bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java
bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Scenes.java
bundles/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/rest/Schedules.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyMetadataRegistry.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyRuleRegistry.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/NeeoApi.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/NeeoUtil.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/OpenHabToDeviceConverter.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/TokenSearch.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/ChannelUIDSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/ItemSubTypeSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/ListUiActionSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoBrainDeviceSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoCapabilityTypeSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoDeviceChannelKindSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoDeviceChannelSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoDeviceSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoDeviceTypeSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/serialization/NeeoThingUIDSerializer.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/BrainDashboardService.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/NeeoBrainSearchService.java
bundles/org.openhab.persistence.dynamodb/src/main/java/org/openhab/persistence/dynamodb/internal/DynamoDBPersistenceService.java
bundles/org.openhab.persistence.dynamodb/src/test/java/org/openhab/persistence/dynamodb/internal/AbstractDynamoDBItemSerializationTest.java
bundles/org.openhab.persistence.mapdb/src/test/java/org/openhab/persistence/mapdb/StateTypeAdapterTest.java
bundles/org.openhab.persistence.rrd4j/src/main/java/org/openhab/persistence/rrd4j/internal/charts/RRD4jChartServlet.java
bundles/pom.xml
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/ModbusDataHandlerTest.java
itests/pom.xml
pom.xml

index 6838f72cf9f13c21a3d1ada529e8a4ec0fa07c9d..d6bac77128ceaad6ee99b9eea3dbf4a4f898b297 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.amazonechocontrol.internal.channelhandler;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.Objects;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -91,7 +92,7 @@ public class ChannelHandlerAnnouncement extends ChannelHandler {
                         body = e.getLocalizedMessage();
                     }
                 }
-                thingHandler.startAnnouncment(device, speak, body, title, volume);
+                thingHandler.startAnnouncment(device, speak, Objects.requireNonNullElse(body, ""), title, volume);
             }
             refreshChannel();
         }
index fc52d294aca75c2f417a7b715a7f49fbe1995384..f3c2497b90a761506b6438c5f26ef0412b5b1812 100644 (file)
@@ -673,7 +673,7 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
     public void setEnabledFlashBriefingsJson(String flashBriefingJson) {
         Connection currentConnection = connection;
         JsonFeed[] feeds = gson.fromJson(flashBriefingJson, JsonFeed[].class);
-        if (currentConnection != null) {
+        if (currentConnection != null && feeds != null) {
             try {
                 currentConnection.setEnabledFlashBriefings(feeds);
             } catch (IOException | URISyntaxException e) {
index 5e3a7d629c7307116e4e7eb5d7e5ef60fe10a618..9bbae05dc630cdb8def016b75276db7f77db1970 100644 (file)
@@ -25,7 +25,8 @@ import com.google.gson.annotations.SerializedName;
 @NonNullByDefault
 public class JsonRegisterAppRequest {
 
-    public JsonRegisterAppRequest(String serial, String accessToken, String frc, JsonWebSiteCookie[] webSiteCookies) {
+    public JsonRegisterAppRequest(String serial, @Nullable String accessToken, String frc,
+            JsonWebSiteCookie[] webSiteCookies) {
         registrationData.deviceSerial = serial;
         authData.accessToken = accessToken;
         userContextMap.frc = frc;
index f2e2dccd3b4350f03706b0b05bda9687cf74621a..865e6e517677da7e58e21de176e8704cab0609ac 100644 (file)
@@ -73,6 +73,9 @@ public class RemoteSensor {
      * there are remote sensor values
      */
     private void updateSensorChannels(AmbientWeatherStationHandler handler, int i, final @Nullable String jsonData) {
+        if (jsonData == null) {
+            return;
+        }
         String sensorNumber = String.valueOf(i);
         StringReader stringReader = new StringReader(jsonData);
         JsonReader reader = new JsonReader(stringReader);
index e2cf730ffe095916812225c5308956ad2ddb3db0..355edeb73286b4a739002f8ac9044a18ac0ea498 100644 (file)
@@ -19,6 +19,7 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
+import java.util.Objects;
 import java.util.TimeZone;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -91,11 +92,8 @@ public class PropertyUtils {
         Method m = instance.getClass().getMethod(toGetterString(propertyName), null);
         Object result = m.invoke(instance, (Object[]) null);
         if (nestedIndex + 1 < properties.length) {
-            if (result != null) {
-                return getPropertyValue(result, properties, nestedIndex + 1);
-            } else {
-                throw new NullPointerException();
-            }
+            Objects.requireNonNull(result);
+            return getPropertyValue(result, properties, nestedIndex + 1);
         }
         return result;
     }
index e992d4a43ba6a321bf789916bb84a5c48e484a88..98251ae0f760069d0b9a6b93ff7cbd6c27018b12 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.bluetooth.roaming.internal;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
@@ -52,7 +53,7 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice {
     }
 
     public void addBluetoothDevice(BluetoothDevice device) {
-        device.addListener(devices.computeIfAbsent(device, Listener::new));
+        device.addListener(Objects.requireNonNull(devices.computeIfAbsent(device, Listener::new)));
     }
 
     public void removeBluetoothDevice(BluetoothDevice device) {
index 75e62114ae6639e37ba7f064eac580f1662fc6da..4172c4f3c8d7fec42c3b7a32ac90ff17eb0a901b 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.bluetooth.roaming.internal;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.stream.Stream;
@@ -216,8 +217,8 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl
     public RoamingBluetoothDevice getDevice(BluetoothAddress address) {
         // this will only get called by a bluetooth device handler
         synchronized (devices) {
-            RoamingBluetoothDevice roamingDevice = devices.computeIfAbsent(address,
-                    addr -> new RoamingBluetoothDevice(this, addr));
+            RoamingBluetoothDevice roamingDevice = Objects
+                    .requireNonNull(devices.computeIfAbsent(address, addr -> new RoamingBluetoothDevice(this, addr)));
 
             adapters.stream().filter(this::isRoamingMember)
                     .forEach(adapter -> roamingDevice.addBluetoothDevice(adapter.getDevice(address)));
index 9f8ce9d661811687fa3e0bbd1f2bbe827eebcffa..c76e56c3e5f1fdd2c695c65b4b9fc6220dad0725 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.bluetooth;
 
 import java.time.ZonedDateTime;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
@@ -186,7 +187,7 @@ public abstract class AbstractBluetoothBridgeHandler<BD extends BaseBluetoothDev
     @Override
     public BD getDevice(BluetoothAddress address) {
         synchronized (devices) {
-            return devices.computeIfAbsent(address, this::createDevice);
+            return Objects.requireNonNull(devices.computeIfAbsent(address, this::createDevice));
         }
     }
 
index dae65edef9d1ddd0a93cfc3a0eaec4b5903c13ba..0a0843179a180592f130b0c2e8e5db7757847bd3 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.bluetooth;
 
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -59,7 +60,7 @@ public class MockBluetoothAdapter implements BluetoothAdapter {
 
     @Override
     public MockBluetoothDevice getDevice(BluetoothAddress address) {
-        return devices.computeIfAbsent(address, addr -> new MockBluetoothDevice(this, addr));
+        return Objects.requireNonNull(devices.computeIfAbsent(address, addr -> new MockBluetoothDevice(this, addr)));
     }
 
     @Override
index 28c926fc185256d728009023488bde9da8bb1e6b..6aacb84a676cd038f8fd614895652b70659c69ca 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bsblan.internal;
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -42,15 +41,8 @@ public class BsbLanBindingConstants {
     public static final String PARAMETER_CHANNEL_DESCRIPTION = "description";
     public static final String PARAMETER_CHANNEL_DATATYPE = "datatype";
 
-    public static final Set<String> WRITEABLE_CHANNELS = new HashSet<String>() {
-
-        private static final long serialVersionUID = 1L;
-        {
-            add(PARAMETER_CHANNEL_NUMBER_VALUE);
-            add(PARAMETER_CHANNEL_STRING_VALUE);
-            add(PARAMETER_CHANNEL_SWITCH_VALUE);
-        }
-    };
+    public static final Set<String> WRITEABLE_CHANNELS = Set.of(PARAMETER_CHANNEL_NUMBER_VALUE,
+            PARAMETER_CHANNEL_STRING_VALUE, PARAMETER_CHANNEL_SWITCH_VALUE);
 
     public static final int MIN_REFRESH_INTERVAL = 5;
     public static final int DEFAULT_REFRESH_INTERVAL = 60;
index 68c3e7992af244b1232937c694f0f66ba89f1432..78176291ef9099af1d827ab85a0547a3c13eaac5 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.bsblan.internal;
 
 import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -39,14 +38,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.bsblan")
 public class BsbLanHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<ThingTypeUID>() {
-
-        private static final long serialVersionUID = 1L;
-        {
-            add(THING_TYPE_PARAMETER);
-            add(THING_TYPE_BRIDGE);
-        }
-    };
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_PARAMETER, THING_TYPE_BRIDGE);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 35b165f045c35e65c40c59a2e00f883799566a5b..80752aa55540e7a4717ecb97bfe23f9984ec543b 100644 (file)
@@ -142,9 +142,10 @@ public class SmartherAuthorizationServlet extends HttpServlet {
         final StringBuffer requestURL = request.getRequestURL();
 
         // Try to infer the real protocol from request headers
-        final String realProtocol = StringUtil.defaultIfBlank(request.getHeader(X_FORWARDED_PROTO),
-                request.getScheme());
-
+        String realProtocol = request.getHeader(X_FORWARDED_PROTO);
+        if (realProtocol == null || realProtocol.isBlank()) {
+            realProtocol = request.getScheme();
+        }
         return requestURL.replace(0, requestURL.indexOf(":"), realProtocol).toString();
     }
 
index 99cd23eca0306e5f5a165409c47fd4562ad32206..cb0066f621898b7bd1b44c57ae7323bee9339537 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Collections;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.function.Function;
 
@@ -177,7 +178,9 @@ public class SmartherApi {
     public ModuleStatus getModuleStatus(String plantId, String moduleId) throws SmartherGatewayException {
         try {
             final ContentResponse response = requestModule(GET, plantId, moduleId, null);
-            return ModelUtil.gsonInstance().fromJson(response.getContentAsString(), ModuleStatus.class);
+            ModuleStatus moduleStatus = ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
+                    ModuleStatus.class);
+            return Objects.requireNonNull(moduleStatus);
         } catch (JsonSyntaxException e) {
             throw new SmartherGatewayException(e.getMessage());
         }
@@ -280,9 +283,13 @@ public class SmartherApi {
             if (response.getStatus() == HttpStatus.NO_CONTENT_204) {
                 return new ArrayList<>();
             } else {
-                return ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
+                List<Subscription> subscriptions = ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
                         new TypeToken<List<Subscription>>() {
                         }.getType());
+                if (subscriptions == null) {
+                    throw new SmartherGatewayException("fromJson returned null");
+                }
+                return subscriptions;
             }
         } catch (JsonSyntaxException e) {
             throw new SmartherGatewayException(e.getMessage());
index a79c62d00e7ff34e84c5daf27610440f73caaeb7..fd8e0520c7bfd612f27dc9fd803e1ba58ae05ccc 100644 (file)
@@ -165,8 +165,8 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
 
         // get the channel id from the map
         HashMap<String, String> logMap = panelLogMessagesMap;
-        if (logMap != null && logMap.containsKey(eventNumberString)) {
-            String id = logMap.get(eventNumberString);
+        String id = logMap.get(eventNumberString);
+        if (logMap != null && id != null) {
             ChannelUID channelUID = new ChannelUID(getThing().getUID(), id);
             updateChannel(channelUID, logEventMessage.toString());
         }
index d8d7a923add954c6c0da2cc1bc0250794c981f89..703276d08c8c8e425902fb2917638a9c374e95f1 100644 (file)
@@ -131,7 +131,10 @@ public class WebSocketConnection {
             return;
         }
 
-        listener.messageReceived(changedMessage.id, gson.fromJson(message, expectedMessageType));
+        DeconzBaseMessage deconzMessage = gson.fromJson(message, expectedMessageType);
+        if (deconzMessage != null) {
+            listener.messageReceived(changedMessage.id, deconzMessage);
+        }
     }
 
     @OnWebSocketError
index 3bb2c1db277c53fdbd7e051f130bd502c932e921..de82d7ebd27750bbae464033e8807452b74a6fcb 100644 (file)
@@ -30,9 +30,8 @@ import com.google.gson.JsonParseException;
 @NonNullByDefault
 public class GroupTypeDeserializer implements JsonDeserializer<GroupType> {
     @Override
-    public GroupType deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        String s = json != null ? json.getAsString() : null;
-        return s == null ? GroupType.UNKNOWN : GroupType.fromString(s);
+    public @Nullable GroupType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+            throws JsonParseException {
+        return GroupType.fromString(json.getAsString());
     }
 }
index 8255feb12e0b105ccaa7174688754f7babed01e3..9bb8e1db2e517607ee07c6d2e662fa084b635d2d 100644 (file)
@@ -30,9 +30,8 @@ import com.google.gson.JsonParseException;
 @NonNullByDefault
 public class LightTypeDeserializer implements JsonDeserializer<LightType> {
     @Override
-    public LightType deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        String s = json != null ? json.getAsString() : null;
-        return s == null ? LightType.UNKNOWN : LightType.fromString(s);
+    public @Nullable LightType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+            throws JsonParseException {
+        return LightType.fromString(json.getAsString());
     }
 }
index b8f6e211a4c0e77e063e544bee93b4daf9fab445..a73dcdc9fe75388ee94c43c8f1fae189e3097e02 100644 (file)
@@ -30,9 +30,8 @@ import com.google.gson.JsonParseException;
 @NonNullByDefault
 public class ResourceTypeDeserializer implements JsonDeserializer<ResourceType> {
     @Override
-    public ResourceType deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        String s = json != null ? json.getAsString() : null;
-        return s == null ? ResourceType.UNKNOWN : ResourceType.fromString(s);
+    public @Nullable ResourceType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+            throws JsonParseException {
+        return ResourceType.fromString(json.getAsString());
     }
 }
index 652a2e13d751c724a18862dcbce0abd1cfd33a58..ff08ad673873e86b048a7d0bb5b4cc0d67e7ca32 100644 (file)
@@ -34,19 +34,14 @@ import com.google.gson.JsonSerializer;
 @NonNullByDefault
 public class ThermostatModeGsonTypeAdapter implements JsonDeserializer<ThermostatMode>, JsonSerializer<ThermostatMode> {
     @Override
-    public ThermostatMode deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        JsonElement jsonLocal = json;
-        if (jsonLocal != null) {
-            String s = jsonLocal.getAsString();
-            return s == null ? ThermostatMode.UNKNOWN : ThermostatMode.fromString(s);
-        }
-        return ThermostatMode.UNKNOWN;
+    public @Nullable ThermostatMode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+            throws JsonParseException {
+        return ThermostatMode.fromString(json.getAsString());
     }
 
     @Override
-    public JsonElement serialize(ThermostatMode src, @Nullable Type typeOfSrc,
-            @Nullable JsonSerializationContext context) throws JsonParseException {
+    public JsonElement serialize(ThermostatMode src, Type typeOfSrc, JsonSerializationContext context)
+            throws JsonParseException {
         return src != ThermostatMode.UNKNOWN ? new JsonPrimitive(src.getDeconzValue()) : JsonNull.INSTANCE;
     }
 }
index e29aa43ad1b3277fdbb2c1409d3f90700a6b400b..39af1b96acc4f5f36d889a8df1b196522e47e408 100644 (file)
@@ -163,7 +163,9 @@ public class DigiplexAreaHandler extends BaseThingHandler {
         bridgeHandler = (DigiplexBridgeHandler) bridge.getHandler();
 
         String areaParm = getThing().getProperties().get(DigiplexBindingConstants.PROPERTY_AREA_NO);
-        areaNo = Integer.parseInt(areaParm);
+        if (areaParm != null) {
+            areaNo = Integer.parseInt(areaParm);
+        }
         bridgeHandler.registerMessageHandler(visitor);
 
         updateStatus(ThingStatus.ONLINE);
index 8bb308c60464916aeefa50b44ee4072a54dc6874..33bb288ccef2ee5a64ccf7d97b4ef23cabb05ee2 100644 (file)
@@ -121,7 +121,9 @@ public class DigiplexZoneHandler extends BaseThingHandler {
         this.bridgeHandler = (DigiplexBridgeHandler) bridge.getHandler();
 
         String nodeParm = getThing().getProperties().get(DigiplexBindingConstants.PROPERTY_ZONE_NO);
-        zoneNo = Integer.parseInt(nodeParm);
+        if (nodeParm != null) {
+            zoneNo = Integer.parseInt(nodeParm);
+        }
         String areaParm = getThing().getProperties().get(DigiplexBindingConstants.PROPERTY_AREA_NO);
         if (areaParm != null) {
             areaNo = Integer.parseInt(areaParm);
index 66f87f94d851515ab16a627bd6def7d6c79fffb0..92e04ef036eb4db58fba1795a6d6220833fa4259 100644 (file)
@@ -18,7 +18,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.DsAPI;
@@ -81,7 +80,7 @@ public class BridgeDiscoveryService extends AbstractDiscoveryService {
                     if (dsidMap != null) {
                         dSID = dsidMap.get(JSONApiResponseKeysEnum.DSID.getKey());
                     }
-                    if (StringUtils.isNotBlank(dSID)) {
+                    if (dSID != null && !dSID.isBlank()) {
                         return new ThingUID(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE, dSID);
                     } else {
                         logger.error("Can't get server dSID to generate ThingUID. Please add the server manually.");
index a54cd9b9ec5ace0a1959d18d61b2525176150ab6..122aac5d0d2b5d6a8a1cdae56aafc80a6e75a8c1 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Set;
 
 import javax.jmdns.ServiceInfo;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.DsAPI;
@@ -84,7 +83,7 @@ public class BridgeMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant
             if (dsidMap != null) {
                 dSID = dsidMap.get(JSONApiResponseKeysEnum.DSID.getKey());
             }
-            if (StringUtils.isNotBlank(dSID)) {
+            if (dSID != null && !dSID.isBlank()) {
                 return new ThingUID(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE, dSID);
             } else {
                 logger.error("Can't get server dSID to generate thing UID. Please add the server manually.");
index 18392b1146c35e0ea7c0938b607375bd3302de54..b1f2dd41c5220c29390b148191107efc7ab0245a 100644 (file)
  */
 package org.openhab.binding.dsmr.internal.discovery;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -148,8 +144,9 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P
                 .filter(DSMRMeterHandler.class::isInstance)
                 .map(DSMRMeterHandler.class::cast)
                 .map(h -> h == null ? null : h.getMeterDescriptor())
-                .map(d -> d == null ? null : d.getMeterType())
-                .filter(Objects::nonNull)
+                .map(d -> Optional.ofNullable(d == null ? null : d.getMeterType()))
+                .filter(Optional::isPresent)
+                .map(Optional::get)
                 .collect(Collectors.toSet());
         // @formatter:on
         // Create list of all configured meters that are not in the detected list. If not empty meters might not be
index ac47d4e9104f9b92583466eafa301756cf72f218..354283bdf1a5b702506bedb8793a702387702e2f 100644 (file)
@@ -32,7 +32,6 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.events.XMLEvent;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.cache.ExpiringCache;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.OnOffType;
@@ -111,7 +110,7 @@ public class DwdWarningsData {
      */
     public boolean refresh() {
         String rawData = dataAccessCached.getValue();
-        if (StringUtils.isEmpty(rawData)) {
+        if (rawData == null || rawData.isEmpty()) {
             logger.debug("No Data from Endpoint");
             return false;
         }
index 911d53d9e0e2619faa4300a8a698ff6fe93f784e..e47fdabd41128077ea33e40005c5e8a238fde2d5 100644 (file)
@@ -414,6 +414,10 @@ public class EcobeeActions implements ThingActions {
         EventDTO event = new EventDTO();
         for (String key : params.keySet()) {
             Object value = params.get(key);
+            if (value == null) {
+                LOGGER.warn("Event field '{}' has null value, ignored.", key);
+                continue;
+            }
             switch (key) {
                 case "isOccupied":
                     event.isOccupied = ((Boolean) value);
index e4c7ddb8971b18d16f60a630b8938ee5c0594779..a539791f0d0b04819265d000a8a434b95ea49c6d 100644 (file)
@@ -165,9 +165,13 @@ public class SelectionDTO {
     }
 
     public void setThermostats(Set<String> thermostatIds) {
-        boolean isRegistered = thermostatIds == null || thermostatIds.isEmpty();
-        selectionType = isRegistered ? SelectionType.REGISTERED : SelectionType.THERMOSTATS;
-        selectionMatch = isRegistered ? "" : String.join(",", thermostatIds);
+        if (thermostatIds == null || thermostatIds.isEmpty()) {
+            selectionType = SelectionType.REGISTERED;
+            selectionMatch = "";
+        } else {
+            selectionType = SelectionType.THERMOSTATS;
+            selectionMatch = String.join(",", thermostatIds);
+        }
     }
 
     public void setSelectionType(SelectionType selectionType) {
index 166084ff9683cf4c754432528d3e4d8f7247be27..a7e2bd1e6d3225e1866db7d4635e4bf6a9143ce0 100644 (file)
@@ -159,7 +159,7 @@ public class TransmitterStick {
         private static final long serialVersionUID = -3216360253151368826L;
 
         public DueCommandSet() {
-            super(new Comparator<Command>() {
+            super(new Comparator<>() {
                 /**
                  * Due commands are sorted by priority first and then by delay.
                  */
index 832aac0f2f58b550be3e50c6b442c23741b3e0c6..121237b35086b2a3c49e2b5203ba9559297a9666 100644 (file)
@@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Objects;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -123,7 +124,7 @@ public class AbstractFMIResponseParsingTest {
         try {
             Method parseMethod = Client.class.getDeclaredMethod("parseMultiPointCoverageXml", String.class);
             parseMethod.setAccessible(true);
-            return (FMIResponse) parseMethod.invoke(client, content);
+            return Objects.requireNonNull((FMIResponse) parseMethod.invoke(client, content));
         } catch (InvocationTargetException e) {
             throw e.getTargetException();
         } catch (Exception e) {
@@ -137,9 +138,9 @@ public class AbstractFMIResponseParsingTest {
     @SuppressWarnings("unchecked")
     protected Set<Location> parseStations(String content) {
         try {
-            Method parseMethod = Client.class.getDeclaredMethod("parseStations", String.class);
+            Method parseMethod = Objects.requireNonNull(Client.class.getDeclaredMethod("parseStations", String.class));
             parseMethod.setAccessible(true);
-            return (Set<Location>) parseMethod.invoke(client, content);
+            return Objects.requireNonNull((Set<Location>) parseMethod.invoke(client, content));
         } catch (InvocationTargetException e) {
             throw new RuntimeException(e.getTargetException());
         } catch (Exception e) {
index 4f089fdf4862fce06df91032c8607395160b0f20..9dab3306c7718cfb887b0e0ba6a8cca8fcbe9919 100644 (file)
@@ -20,6 +20,7 @@ import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -95,7 +96,8 @@ public class FoobotApiConnector {
                     URLEncoder.encode(username, StandardCharsets.UTF_8.toString()));
             logger.debug("URL = {}", url);
 
-            return GSON.fromJson(request(url, apiKey), FOOTBOT_DEVICE_LIST_TYPE);
+            List<FoobotDevice> foobotDevices = GSON.fromJson(request(url, apiKey), FOOTBOT_DEVICE_LIST_TYPE);
+            return Objects.requireNonNull(foobotDevices);
         } catch (JsonParseException | UnsupportedEncodingException e) {
             throw new FoobotApiException(0, e.getMessage());
         }
index b0f049d905bdd54964a42a98c0b397c453e09010..77e88c6fb3912f303ea5f2c7911fef7a9778fc8e 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.*;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
+import java.util.Objects;
 
 import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
@@ -53,6 +54,7 @@ public class FoobotDeviceHandlerTest {
         final FoobotJsonData sensorData = connector.getSensorData("1234");
 
         assertNotNull(sensorData, "No sensor data read");
+        Objects.requireNonNull(sensorData);
         assertEquals(handler.sensorDataToState("temperature", sensorData), new QuantityType(12.345, SIUnits.CELSIUS));
         assertEquals(handler.sensorDataToState("gpi", sensorData), new DecimalType(5.6789012));
     }
index b4de21d03c6ad6a6105e5e6d5ffd9d3070fe0de2..1c8e34144a677ffcebe45b680445060644936ed0 100644 (file)
@@ -21,10 +21,7 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
@@ -148,6 +145,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
     private static @NonNull Channel getChannel(final @NonNull Thing thing, final @NonNull String channelId) {
         final Channel channel = thing.getChannel(channelId);
         assertNotNull(channel);
+        Objects.requireNonNull(channel);
         return channel;
     }
 
index c8909b7dcad78745589ca90dced954e512a87a23..ccad8f7f8d117a0c5bf4389a13b8eb22089416af 100644 (file)
@@ -18,6 +18,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.servlet.ServletException;
@@ -134,7 +135,7 @@ public class RadioServiceDummy extends HttpServlet {
         Collection<String> requestParameterNames = Collections.list(request.getParameterNames());
         if (queryString != null && requestParameterNames.contains(VALUE)) {
             StringBuffer fullUrl = request.getRequestURL().append("?").append(queryString);
-            int value = Integer.parseInt(request.getParameter(VALUE));
+            int value = Integer.parseInt(Objects.requireNonNullElse(request.getParameter(VALUE), ""));
             requestParameters.put(value, fullUrl.toString());
         }
 
index c8fe210aebf8761d205c037179d9e9a98889debc..3c017e7f6b282d4e383970d8c618d894cb71b2c3 100644 (file)
@@ -51,7 +51,7 @@ public class MessageUtil {
     public LocationMessage fromJson(String json) {
         for (String pattern : PATTERNS) {
             Class<? extends LocationMessage> c = MESSAGE_TYPES.get(pattern);
-            if (json.matches(pattern)) {
+            if (c != null && json.matches(pattern)) {
                 return gson.fromJson(json, c);
             }
         }
index bccdd4afcc9559f8729afc85d0ac5f06ffc9ee8f..32eadc0abf335cdd64124065751d7086596dcfb2 100644 (file)
@@ -47,8 +47,7 @@ public class GreeException extends Exception {
         super(message, exception);
     }
 
-    @Override
-    public @Nullable String getMessage() {
+    public String getMessageString() {
         return isEmpty() ? "" : nonNullString(super.getMessage());
     }
 
@@ -69,7 +68,7 @@ public class GreeException extends Exception {
                 message = MessageFormat.format("{0} ({1})", message, cause);
             }
         } else {
-            message = getMessage();
+            message = getMessageString();
         }
         return message;
     }
@@ -82,7 +81,7 @@ public class GreeException extends Exception {
         Class<?> extype = !isEmpty() ? getCauseClass() : null;
         return (extype != null) && ((extype == SocketTimeoutException.class) || (extype == TimeoutException.class)
                 || (extype == ExecutionException.class) || (extype == InterruptedException.class)
-                || getMessage().toLowerCase().contains("timeout"));
+                || getMessageString().toLowerCase().contains("timeout"));
     }
 
     public boolean isUnknownHost() {
index 0523c5a64191f353cd9a7acf1be33637f1de62d4..50244f6a3d52b30b72ef40d9f525914776d2e93f 100644 (file)
@@ -97,7 +97,7 @@ public class GreeDiscoveryService extends AbstractDiscoveryService {
                 createResult(deviceFinder.getDevices());
             }
         } catch (GreeException e) {
-            logger.info("Discovery: {}", messages.get("discovery.exception", e.getMessage()));
+            logger.info("Discovery: {}", messages.get("discovery.exception", e.getMessageString()));
         } catch (SocketException | RuntimeException e) {
             logger.warn("Discovery: {}", messages.get("discovery.exception", "RuntimeException"), e);
         }
index b6cef937f496a31c643cc895518cf5c78a5cf802..dcb9d41f28f58e123a0c51ed3e533e69f06fd5b4 100644 (file)
@@ -122,7 +122,7 @@ public class GreeHandler extends BaseThingHandler {
             message = messages.get("thinginit.failed");
             logger.info("{}: {}", thingId, message);
         } catch (GreeException e) {
-            logger.info("{}: {}", thingId, messages.get("thinginit.exception", e.getMessage()));
+            logger.info("{}: {}", thingId, messages.get("thinginit.exception", e.getMessageString()));
         } catch (IOException e) {
             logger.warn("{}: {}", thingId, messages.get("thinginit.exception", "I/O Error"), e);
         } catch (RuntimeException e) {
@@ -158,7 +158,7 @@ public class GreeHandler extends BaseThingHandler {
                         logger.debug("{}: Command {} failed for channel {}, retry", thingId, command, channelId);
                     } else {
                         String message = logInfo(
-                                messages.get("command.exception", command, channelId) + ": " + e.getMessage());
+                                messages.get("command.exception", command, channelId) + ": " + e.getMessageString());
                         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, message);
                     }
                 } catch (IllegalArgumentException e) {
@@ -379,7 +379,7 @@ public class GreeHandler extends BaseThingHandler {
                 if (e.getCause() != null) {
                     subcode = " (" + e.getCause().getMessage() + ")";
                 }
-                String message = messages.get("update.exception", e.getMessage() + subcode);
+                String message = messages.get("update.exception", e.getMessageString() + subcode);
                 if (getThing().getStatus() == ThingStatus.OFFLINE) {
                     logger.debug("{}: Thing still OFFLINE ({})", thingId, message);
                 } else {
@@ -472,7 +472,7 @@ public class GreeHandler extends BaseThingHandler {
                 updateState(channelID, state);
             }
         } catch (GreeException e) {
-            logger.info("{}: {}", thingId, messages.get("channel.exception", channelID, e.getMessage()));
+            logger.info("{}: {}", thingId, messages.get("channel.exception", channelID, e.getMessageString()));
         } catch (RuntimeException e) {
             logger.warn("{}: {}", thingId, messages.get("channel.exception", "RuntimeException"), e);
         }
index 214c5a5ababad8a28413fb9f8d5e5d3ef8324528..7ea80306aa6e6f5df92191bcc7ce4198122ac611 100644 (file)
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.harmonyhub.internal.handler.HarmonyHubHandler;
@@ -253,8 +252,8 @@ public class HarmonyHubDiscoveryService extends AbstractDiscoveryService {
                         String friendlyName = properties.get("friendlyName");
                         String hostName = properties.get("host_name");
                         String ip = properties.get("ip");
-                        if (StringUtils.isNotBlank(friendlyName) && StringUtils.isNotBlank(hostName)
-                                && StringUtils.isNotBlank(ip) && !responses.contains(hostName)) {
+                        if (friendlyName != null && !friendlyName.isBlank() && hostName != null && !hostName.isBlank()
+                                && ip != null && !ip.isBlank() && !responses.contains(hostName)) {
                             responses.add(hostName);
                             hubDiscovered(ip, friendlyName, hostName);
                         }
index 7dc62237c4bf763362fb79bb72829013497a7e16..03b1a90869a495501316d1a55868765af9a10757 100644 (file)
@@ -196,7 +196,9 @@ public class HeosBridgeHandler extends BaseBridgeHandler implements HeosEventLis
             @Nullable
             Group[] onlineGroups = getApiConnection().getGroups().payload;
 
-            updatePlayerStatus(onlinePlayers, onlineGroups);
+            if (onlinePlayers != null && onlineGroups != null) {
+                updatePlayerStatus(onlinePlayers, onlineGroups);
+            }
         } catch (ReadException | IOException e) {
             logger.debug("Failed updating online state of groups/players", e);
         }
index ad78dd2b66791eb5343129f84118d518e3760c74..d2c72887bb369ddd941ce2f2d956e6870779c2de 100644 (file)
@@ -18,6 +18,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -57,7 +58,7 @@ public class HeosJsonParser {
 
     public <T> HeosResponseObject<T> parseResponse(String jsonBody, Class<T> clazz) {
         HeosJsonWrapper wrapper = gson.fromJson(jsonBody, HeosJsonWrapper.class);
-        return postProcess(wrapper, clazz);
+        return postProcess(Objects.requireNonNull(wrapper), clazz);
     }
 
     private <T> HeosResponseObject<T> postProcess(HeosJsonWrapper wrapper, Class<T> clazz) {
index 9f981232d2e4a8f403d17f0d25ee25222b9ce010..463ed8cb70a48116e73caeef69d2b7d757f417b2 100644 (file)
@@ -359,7 +359,11 @@ public class HueBridge {
         List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
         SuccessResponse response = entries.get(0);
 
-        return (String) response.success.get("/lights/" + enc(light.getId()) + "/name");
+        String lightName = (String) response.success.get("/lights/" + enc(light.getId()) + "/name");
+        if (lightName == null) {
+            throw new ApiException("Response didn't contain light name.");
+        }
+        return lightName;
     }
 
     /**
@@ -560,7 +564,11 @@ public class HueBridge {
         List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
         SuccessResponse response = entries.get(0);
 
-        return (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
+        String groupName = (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
+        if (groupName == null) {
+            throw new ApiException("Response didn't contain group name.");
+        }
+        return groupName;
     }
 
     /**
@@ -610,7 +618,11 @@ public class HueBridge {
         List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
         SuccessResponse response = entries.get(0);
 
-        return (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
+        String groupName = (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
+        if (groupName == null) {
+            throw new ApiException("Response didn't contain group name.");
+        }
+        return groupName;
     }
 
     /**
@@ -955,7 +967,11 @@ public class HueBridge {
         List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
         SuccessResponse response = entries.get(0);
 
-        return (String) response.success.get("username");
+        String username = (String) response.success.get("username");
+        if (username == null) {
+            throw new ApiException("Response didn't contain username");
+        }
+        return username;
     }
 
     /**
@@ -1019,7 +1035,8 @@ public class HueBridge {
 
         handleErrors(result);
 
-        return gson.fromJson(result.getBody(), FullConfig.class);
+        FullConfig fullConfig = gson.fromJson(result.getBody(), FullConfig.class);
+        return Objects.requireNonNull(fullConfig);
     }
 
     // Used as assert in requests that require authentication
index 9f0f8fcfa287301a017df18cf1f8ad2ade1973a7..9e19852481f0168c167de6f43be56f60cf74ee4b 100644 (file)
@@ -16,12 +16,7 @@ import static org.openhab.binding.hue.internal.HueBindingConstants.*;
 import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -162,8 +157,10 @@ public class HueBridgeNupnpDiscovery extends AbstractDiscoveryService {
         try {
             Gson gson = new Gson();
             String json = doGetRequest(DISCOVERY_URL);
-            return gson.fromJson(json, new TypeToken<List<BridgeJsonParameters>>() {
-            }.getType());
+            List<BridgeJsonParameters> bridgeParameters = gson.fromJson(json,
+                    new TypeToken<List<BridgeJsonParameters>>() {
+                    }.getType());
+            return Objects.requireNonNull(bridgeParameters);
         } catch (IOException e) {
             logger.debug("Philips Hue NUPnP service not reachable. Can't discover bridges");
         } catch (JsonParseException je) {
index 12b6a0358b21cdd93e70704e0e3aeee6aea602c6..f8391675ba6a90f986a9b52b675f6141f8750056 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Optional;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -94,10 +93,9 @@ public class HydrawiseCloudHandler extends HydrawiseHandler {
         } else {
             // try and use ID from saved property
             String controllerId = getThing().getProperties().get(PROPERTY_CONTROLLER_ID);
-            if (StringUtils.isNotBlank(controllerId)) {
+            if (controllerId != null && !controllerId.isBlank()) {
                 try {
                     controller = getController(Integer.parseInt(controllerId), controllers);
-
                 } catch (NumberFormatException e) {
                     logger.debug("Can not parse property vaue {}", controllerId);
                 }
index 42d4e000b1a49a0508a2e966fab845148245d631..404400345874b7f7e0bd138555e6e2618917d5a3 100644 (file)
@@ -16,10 +16,7 @@ import static org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants.*
 
 import java.time.ZonedDateTime;
 import java.time.temporal.ChronoUnit;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -127,6 +124,7 @@ public abstract class HydrawiseHandler extends BaseThingHandler {
                     if (allCommand) {
                         sendRunAllCommand(((DecimalType) command).intValue());
                     } else {
+                        Objects.requireNonNull(relay);
                         sendRunCommand(((DecimalType) command).intValue(), relay);
                     }
                     break;
@@ -142,6 +140,7 @@ public abstract class HydrawiseHandler extends BaseThingHandler {
                             sendStopAllCommand();
                         }
                     } else {
+                        Objects.requireNonNull(relay);
                         if (command == OnOffType.ON) {
                             sendRunCommand(relay);
                         } else {
index e17ebb6f2c1b641dbbbbad78b6f470eba28fbcf0..8db54db1e1e8a4c6a9cb10cc717f32559469d4a0 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.hydrawise.internal.api;
 
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -89,7 +90,7 @@ public class HydrawiseCloudApiClient {
     public StatusScheduleResponse getStatusSchedule(int controllerId)
             throws HydrawiseConnectionException, HydrawiseAuthenticationException {
         String json = doGet(String.format(STATUS_SCHEDUE_URL, apiKey, controllerId));
-        StatusScheduleResponse response = gson.fromJson(json, StatusScheduleResponse.class);
+        StatusScheduleResponse response = Objects.requireNonNull(gson.fromJson(json, StatusScheduleResponse.class));
         throwExceptionIfResponseError(response);
         return response;
     }
@@ -104,13 +105,13 @@ public class HydrawiseCloudApiClient {
     public CustomerDetailsResponse getCustomerDetails()
             throws HydrawiseConnectionException, HydrawiseAuthenticationException {
         String json = doGet(String.format(CUSTOMER_DETAILS_URL, apiKey));
-        CustomerDetailsResponse response = gson.fromJson(json, CustomerDetailsResponse.class);
+        CustomerDetailsResponse response = Objects.requireNonNull(gson.fromJson(json, CustomerDetailsResponse.class));
         throwExceptionIfResponseError(response);
         return response;
     }
 
     /***
-     * Sets the controller with supplied {@value id} as the current controller
+     * Sets the controller with supplied {@param id} as the current controller
      *
      * @param id
      * @return SetControllerResponse
@@ -121,7 +122,7 @@ public class HydrawiseCloudApiClient {
     public SetControllerResponse setController(int id)
             throws HydrawiseConnectionException, HydrawiseAuthenticationException, HydrawiseCommandException {
         String json = doGet(String.format(SET_CONTROLLER_URL, apiKey, id));
-        SetControllerResponse response = gson.fromJson(json, SetControllerResponse.class);
+        SetControllerResponse response = Objects.requireNonNull(gson.fromJson(json, SetControllerResponse.class));
         throwExceptionIfResponseError(response);
         if (!response.message.equals("OK")) {
             throw new HydrawiseCommandException(response.message);
@@ -271,7 +272,7 @@ public class HydrawiseCloudApiClient {
     private String relayCommand(String url)
             throws HydrawiseConnectionException, HydrawiseAuthenticationException, HydrawiseCommandException {
         String json = doGet(url);
-        SetZoneResponse response = gson.fromJson(json, SetZoneResponse.class);
+        SetZoneResponse response = Objects.requireNonNull(gson.fromJson(json, SetZoneResponse.class));
         throwExceptionIfResponseError(response);
         if ("error".equals(response.messageType)) {
             throw new HydrawiseCommandException(response.message);
index d76467002fdf53df81634fe51e97b7b7975ffe95..3c2de22e600b7eabaf0c360f2a72f30c1507c8b0 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.hydrawise.internal.api;
 
 import java.net.URI;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -95,7 +96,7 @@ public class HydrawiseLocalApiClient {
             throws HydrawiseConnectionException, HydrawiseAuthenticationException {
         String json = doGet(localGetURL);
         LocalScheduleResponse response = gson.fromJson(json, LocalScheduleResponse.class);
-        return response;
+        return Objects.requireNonNull(response);
     }
 
     /**
index 604593ba7ab064e39a7194fe69d4ca6a971f8683..d407f1ced13f97988481097cbf1702f9bc6d556a 100644 (file)
@@ -17,6 +17,7 @@ import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
@@ -120,7 +121,7 @@ public class IAqualinkClient {
             if (response.getStatus() != HttpStatus.OK_200) {
                 throw new IOException(response.getReason());
             }
-            return gson.fromJson(response.getContentAsString(), AccountInfo.class);
+            return Objects.requireNonNull(gson.fromJson(response.getContentAsString(), AccountInfo.class));
         } catch (InterruptedException | TimeoutException | ExecutionException e) {
             throw new IOException(e);
         }
@@ -347,7 +348,7 @@ public class IAqualinkClient {
      * @throws NotAuthorizedException
      */
     private <T> T getAqualinkObject(URI uri, Type typeOfT) throws IOException, NotAuthorizedException {
-        return gson.fromJson(getRequest(uri), typeOfT);
+        return Objects.requireNonNull(gson.fromJson(getRequest(uri), typeOfT));
     }
 
     /**
@@ -383,11 +384,8 @@ public class IAqualinkClient {
 
     class HomeDeserializer implements JsonDeserializer<Home> {
         @Override
-        public Home deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-                @Nullable JsonDeserializationContext context) throws JsonParseException {
-            if (json == null) {
-                throw new JsonParseException("No JSON");
-            }
+        public @Nullable Home deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+                throws JsonParseException {
             JsonObject jsonObject = json.getAsJsonObject();
             JsonArray homeScreen = jsonObject.getAsJsonArray("home_screen");
             JsonObject home = new JsonObject();
@@ -408,11 +406,8 @@ public class IAqualinkClient {
 
     class OneTouchDeserializer implements JsonDeserializer<OneTouch[]> {
         @Override
-        public OneTouch[] deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-                @Nullable JsonDeserializationContext context) throws JsonParseException {
-            if (json == null) {
-                throw new JsonParseException("No JSON");
-            }
+        public OneTouch @Nullable [] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+                throws JsonParseException {
             JsonObject jsonObject = json.getAsJsonObject();
             JsonArray oneTouchScreen = jsonObject.getAsJsonArray("onetouch_screen");
             List<OneTouch> list = new ArrayList<>();
@@ -429,7 +424,7 @@ public class IAqualinkClient {
                                         oneTouchJson.add(oneTouchEntry.getKey(), oneTouchEntry.getValue());
                                     });
                                 });
-                                list.add(gsonInternal.fromJson(oneTouchJson, OneTouch.class));
+                                list.add(Objects.requireNonNull(gsonInternal.fromJson(oneTouchJson, OneTouch.class)));
                             }
                         }
                     });
@@ -441,11 +436,8 @@ public class IAqualinkClient {
 
     class AuxDeserializer implements JsonDeserializer<Auxiliary[]> {
         @Override
-        public Auxiliary[] deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-                @Nullable JsonDeserializationContext context) throws JsonParseException {
-            if (json == null) {
-                throw new JsonParseException("No JSON");
-            }
+        public Auxiliary @Nullable [] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+                throws JsonParseException {
             JsonObject jsonObject = json.getAsJsonObject();
             JsonArray auxScreen = jsonObject.getAsJsonArray("devices_screen");
             List<Auxiliary> list = new ArrayList<>();
@@ -462,7 +454,7 @@ public class IAqualinkClient {
                                         auxJson.add(auxEntry.getKey(), auxEntry.getValue());
                                     });
                                 });
-                                list.add(gsonInternal.fromJson(auxJson, Auxiliary.class));
+                                list.add(Objects.requireNonNull(gsonInternal.fromJson(auxJson, Auxiliary.class)));
                             }
                         }
                     });
index 03dd84d25c303d3aa3fcd1eddeaaf9f2bd040275..07628ad1f5096e2bfe4131a5cfa83580d45c0a85 100644 (file)
@@ -20,10 +20,7 @@ import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.time.format.DateTimeFormatter;
 import java.time.format.FormatStyle;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.*;
 
 import org.apache.commons.lang.StringUtils;
@@ -238,6 +235,11 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
         }
 
         Device bridgeDevice = deviceStructMan.getBridgeDevice();
+        if (bridgeDevice == null) {
+            logger.debug("Failed to get bridge device, re-scheduling startClient.");
+            scheduleRestartClient(true);
+            return;
+        }
         setBridgeProperties(bridgeDevice);
         bridgeId = bridgeDevice.getId();
         startWebsocket();
@@ -533,7 +535,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
                     case BaseEvent.TYPE_NEW_MESSAGE_RECEIVED:
                     case BaseEvent.TYPE_MESSAGE_CREATED:
                         final MessageEvent messageEvent = gson.fromJson(msg, MessageEvent.class);
-                        handleNewMessageReceivedEvent(messageEvent);
+                        handleNewMessageReceivedEvent(Objects.requireNonNull(messageEvent));
                         break;
 
                     case BaseEvent.TYPE_MESSAGE_DELETED:
index cb2e871aafb925456e4875873d6c6c342c7ed3d0..b0c6f31d68ab1b51b6eaefa7b601fc0756d48a83 100644 (file)
@@ -63,7 +63,7 @@ public abstract class CommandHandler {
     /**
      * Implements what to do when an openHAB command is received
      *
-     * @param config the configuration for the item that generated the command
+     * @param conf the configuration for the item that generated the command
      * @param cmd the openhab command issued
      * @param device the Insteon device to which this command applies
      */
index 76d3404254a449933f53c8a9d378fc2c0cb39239..cb55463a35e9bbf9192fd34c2a6781cc752ce09f 100644 (file)
@@ -16,11 +16,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -440,8 +436,7 @@ public class DeviceFeature {
     static {
         // read features from xml file and store them in a map
         InputStream input = DeviceFeature.class.getResourceAsStream("/device_features.xml");
-        if (input != null) {
-            readFeatureTemplates(input);
-        }
+        Objects.requireNonNull(input);
+        readFeatureTemplates(input);
     }
 }
index 79b368dd210226faf14b91999eb86c0aea171dbd..a3845e6d2ea2d18d496bd9ce896cd6be89d42cea 100644 (file)
@@ -74,7 +74,7 @@ public class DeviceTypeLoader {
      * Reads the device types from input stream and stores them in memory for
      * later access.
      *
-     * @param is the input stream from which to read
+     * @param in the input stream from which to read
      */
     public void loadDeviceTypesXML(InputStream in) throws ParserConfigurationException, SAXException, IOException {
         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
@@ -204,20 +204,18 @@ public class DeviceTypeLoader {
     public static synchronized DeviceTypeLoader instance() {
         if (deviceTypeLoader.getDeviceTypes().isEmpty()) {
             InputStream input = DeviceTypeLoader.class.getResourceAsStream("/device_types.xml");
-            if (input != null) {
-                try {
+            try {
+                if (input != null) {
                     deviceTypeLoader.loadDeviceTypesXML(input);
-                } catch (ParserConfigurationException e) {
-                    logger.warn("parser config error when reading device types xml file: ", e);
-                } catch (SAXException e) {
-                    logger.warn("SAX exception when reading device types xml file: ", e);
-                } catch (IOException e) {
-                    logger.warn("I/O exception when reading device types xml file: ", e);
+                } else {
+                    logger.warn("Resource stream is null, cannot read xml file.");
                 }
-                logger.debug("loaded {} devices: ", deviceTypeLoader.getDeviceTypes().size());
-                deviceTypeLoader.logDeviceTypes();
-            } else {
-                logger.warn("unable to get device types xml file as a resource");
+            } catch (ParserConfigurationException e) {
+                logger.warn("parser config error when reading device types xml file: ", e);
+            } catch (SAXException e) {
+                logger.warn("SAX exception when reading device types xml file: ", e);
+            } catch (IOException e) {
+                logger.warn("I/O exception when reading device types xml file: ", e);
             }
         }
         return deviceTypeLoader;
index 736f86ec0c3f05ebcc5502acfc3624b81302a415..2e53e8a00b4ce11473d99c27b42bc6d9664901bb 100644 (file)
@@ -14,13 +14,7 @@ package org.openhab.binding.insteon.internal.handler;
 
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -185,7 +179,7 @@ public class InsteonDeviceHandler extends BaseThingHandler {
                 Type mapType = new TypeToken<Map<String, Object>>() {
                 }.getType();
                 try {
-                    deviceConfigMap = new Gson().fromJson(deviceConfig, mapType);
+                    deviceConfigMap = Objects.requireNonNull(new Gson().fromJson(deviceConfig, mapType));
                 } catch (JsonParseException e) {
                     String msg = "The device configuration parameter is not valid JSON.";
                     logger.warn("{} {}", thing.getUID().getAsString(), msg);
index 8d1f16a60c6ec7af64efc1912572836950a48d32..75baefa64f0b7a224215c4bb447aee72c654e341 100644 (file)
@@ -177,6 +177,8 @@ public class JablotronJa100Handler extends JablotronAlarmHandler {
         if (channel == null) {
             logger.debug("Creating a new temperature channel: {}", segmentId);
             createTempChannel(segmentId, segment.getSegmentName());
+            processThermometer(segment);
+            return;
         }
         updateTemperatureChannel(channel, segment);
     }
@@ -187,6 +189,8 @@ public class JablotronJa100Handler extends JablotronAlarmHandler {
         if (channel == null) {
             logger.debug("Creating a new thermostat channel: {}", segmentId);
             createThermostatChannel(segmentId, segment.getSegmentName());
+            processThermostat(segment);
+            return;
         }
         updateTemperatureChannel(channel, segment);
     }
index 06b4dceff514e0ea9a78ec008308791ff2fd18d5..5a49001a0a61fb7aa2dccf73b133537f5ca06240 100644 (file)
@@ -54,15 +54,21 @@ public class KM200Utils {
      */
     public static String checkParameterReplacement(Channel channel, KM200Device device) {
         String service = KM200Utils.translatesNameToPath(channel.getProperties().get("root"));
-        if (service.contains(SWITCH_PROGRAM_REPLACEMENT)) {
-            String currentService = KM200Utils
-                    .translatesNameToPath(channel.getProperties().get(SWITCH_PROGRAM_CURRENT_PATH_NAME));
+        if (service == null) {
+            LOGGER.warn("Root property not found in device {}", device);
+            throw new IllegalStateException("root property not found");
+        }
+        String currentService = KM200Utils
+                .translatesNameToPath(channel.getProperties().get(SWITCH_PROGRAM_CURRENT_PATH_NAME));
+        if (currentService != null) {
             if (device.containsService(currentService)) {
                 KM200ServiceObject curSerObj = device.getServiceObject(currentService);
                 if (null != curSerObj) {
                     if (DATA_TYPE_STRING_VALUE.equals(curSerObj.getServiceType())) {
                         String val = (String) curSerObj.getValue();
-                        service = service.replace(SWITCH_PROGRAM_REPLACEMENT, val);
+                        if (val != null) {
+                            service = service.replace(SWITCH_PROGRAM_REPLACEMENT, val);
+                        }
                         return service;
                     }
                 }
index 1262b315573dad4ca7061ad7b409e2b937591d9a..55c85806f1becac00bffc0b7c035c625887b0e29 100644 (file)
@@ -354,7 +354,7 @@ public class KM200SwitchProgramServiceHandler {
                                     firstVal = (BigDecimal) setpObject.serviceTreeMap.get(key).getValue();
                                 } else {
                                     BigDecimal nextVal = (BigDecimal) setpObject.serviceTreeMap.get(key).getValue();
-                                    if (null != nextVal) {
+                                    if (null != nextVal && null != firstVal) {
                                         if (nextVal.compareTo(firstVal) > 0) {
                                             positiveSwitch = key;
                                         } else {
index 98b330aae9b61dbee8c1546bdb5d10c8d2cffc92..eb771ddab210ba8002d4ffcb78bbb0257cda1802 100644 (file)
@@ -231,6 +231,10 @@ public class KM200ThingHandler extends BaseThingHandler {
             return;
         }
         String service = KM200Utils.translatesNameToPath(thing.getProperties().get("root"));
+        if (service == null) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "root property missing");
+            return;
+        }
         synchronized (gateway.getDevice()) {
             updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.CONFIGURATION_PENDING);
             if (!gateway.getDevice().getInited()) {
@@ -284,10 +288,14 @@ public class KM200ThingHandler extends BaseThingHandler {
                 state = StateDescriptionFragmentBuilder.create().withMinimum(BigDecimal.ZERO).withStep(BigDecimal.ONE)
                         .withPattern("%d minutes").build();
                 String posName = thing.getProperties().get(SWITCH_PROGRAM_POSITIVE);
-                newChannel = createChannel(new ChannelTypeUID(thing.getUID().getAsString() + ":" + posName),
-                        new ChannelUID(thing.getUID(), posName), service + "/" + posName, CoreItemFactory.NUMBER,
-                        currentPathName, "Positive switch of the cycle, like 'Day' 'On'", posName, true, true, state,
-                        "minutes");
+                if (posName == null) {
+                    newChannel = null;
+                } else {
+                    newChannel = createChannel(new ChannelTypeUID(thing.getUID().getAsString() + ":" + posName),
+                            new ChannelUID(thing.getUID(), posName), service + "/" + posName, CoreItemFactory.NUMBER,
+                            currentPathName, "Positive switch of the cycle, like 'Day' 'On'", posName, true, true,
+                            state, "minutes");
+                }
                 if (null == newChannel) {
                     logger.warn("Creation of the channel {} was not possible", thing.getUID());
                 } else {
@@ -295,10 +303,14 @@ public class KM200ThingHandler extends BaseThingHandler {
                 }
 
                 String negName = thing.getProperties().get(SWITCH_PROGRAM_NEGATIVE);
-                newChannel = createChannel(new ChannelTypeUID(thing.getUID().getAsString() + ":" + negName),
-                        new ChannelUID(thing.getUID(), negName), service + "/" + negName, CoreItemFactory.NUMBER,
-                        currentPathName, "Negative switch of the cycle, like 'Night' 'Off'", negName, true, true, state,
-                        "minutes");
+                if (negName == null) {
+                    newChannel = null;
+                } else {
+                    newChannel = createChannel(new ChannelTypeUID(thing.getUID().getAsString() + ":" + negName),
+                            new ChannelUID(thing.getUID(), negName), service + "/" + negName, CoreItemFactory.NUMBER,
+                            currentPathName, "Negative switch of the cycle, like 'Night' 'Off'", negName, true, true,
+                            state, "minutes");
+                }
                 if (null == newChannel) {
                     logger.warn("Creation of the channel {} was not possible", thing.getUID());
                 } else {
index 0d9d6724a4fb00b72b9d6502bc6dc0fe205c8d8f..aea4a38554a3b207fe852cf87643fa303ec7cff8 100644 (file)
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
 
 /**
  * KVVBridgeHandler encapsulates the communication with the KVV API.
@@ -106,7 +107,7 @@ public class KVVBridgeHandler extends BaseBridgeHandler {
         DepartureResult result;
         try {
             result = new Gson().fromJson(data, DepartureResult.class);
-        } catch (Exception e) {
+        } catch (JsonSyntaxException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Failed to connect to KVV API");
             logger.debug("Failed to parse departure data", e);
             logger.debug("Server returned '{}'", data);
@@ -114,6 +115,10 @@ public class KVVBridgeHandler extends BaseBridgeHandler {
             return null;
         }
 
+        if (result == null) {
+            return null;
+        }
+
         if (this.wasOffline) {
             updateStatus(ThingStatus.ONLINE);
         }
@@ -132,7 +137,6 @@ public class KVVBridgeHandler extends BaseBridgeHandler {
         /**
          * Creates a new @{link Cache}.
          *
-         * @param updateInterval the @{code updateInterval}
          */
         public Cache() {
             this.updateInterval = KVVBindingConstants.CACHE_DEFAULT_UPDATEINTERVAL;
index 4bfdc9494cf157eb7d79e3bc99a8049299eb7ed3..2162ceab840486facd6e7635e4e94df3005c124c 100644 (file)
@@ -5,6 +5,7 @@
 package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
 
 import java.io.IOException;
+import java.io.ObjectStreamException;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonElement;
@@ -51,6 +52,9 @@ public abstract class CustomizedTypeAdapterFactory<C> implements TypeAdapterFact
             {
                 JsonElement tree = elementAdapter.read(in);
                 afterRead(tree);
+                if (tree == null) {
+                    throw new IOException("null reader");
+                }
                 return delegate.fromJsonTree(tree);
             }
         };
index f89a7051c1e8c057325a2aafbe8d371416528e83..6ab835553cfc1d002d14ebb7ce4cda511a0a4521 100644 (file)
@@ -21,12 +21,7 @@ import java.nio.channels.Channel;
 import java.nio.channels.CompletionHandler;
 import java.time.Instant;
 import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
+import java.util.*;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledExecutorService;
@@ -150,7 +145,7 @@ public class Connection {
      * @return the data
      */
     public ModInfo updateModuleData(LcnAddrMod addr) {
-        return modData.computeIfAbsent(addr, ModInfo::new);
+        return Objects.requireNonNull(modData.computeIfAbsent(addr, ModInfo::new));
     }
 
     /**
index 35f54d8b227956a60e8809e0ebd044ac4045df31..b5057b93682f6bd978d00f08b95884dd9caecca4 100644 (file)
@@ -17,6 +17,7 @@ import java.net.InetSocketAddress;
 import java.net.StandardSocketOptions;
 import java.nio.channels.AsynchronousSocketChannel;
 import java.nio.channels.CompletionHandler;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -78,15 +79,13 @@ public class ConnectionStateConnecting extends AbstractConnectionState {
     }
 
     private void handleConnectionFailure(@Nullable Throwable e) {
-        String message;
+        String message = null;
         if (e != null) {
             logger.warn("Could not connect to {}:{}: {}", connection.getSettings().getAddress(),
                     connection.getSettings().getPort(), e.getMessage());
             message = e.getMessage();
-        } else {
-            message = "";
         }
-        connection.getCallback().onOffline(message);
+        connection.getCallback().onOffline(Objects.requireNonNullElse(message, ""));
         context.handleConnectionFailed(e);
     }
 
index 4dbc86d69e0b0aedf0013c49ba1f41ac6c09b304..2f0389b09ce5eb23fa9c7f3b83e889fa42a701b9 100644 (file)
@@ -36,6 +36,7 @@ package org.openhab.binding.lgwebos.internal.handler.command;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.lgwebos.internal.handler.core.ResponseListener;
 
 import com.google.gson.JsonElement;
@@ -57,11 +58,11 @@ public class ServiceCommand<T> {
     protected Type type;
     protected JsonObject payload;
     protected String target;
-    protected Function<JsonObject, T> converter;
+    protected Function<JsonObject, @Nullable T> converter;
 
     ResponseListener<T> responseListener;
 
-    public ServiceCommand(String targetURL, JsonObject payload, Function<JsonObject, T> converter,
+    public ServiceCommand(String targetURL, JsonObject payload, Function<JsonObject, @Nullable T> converter,
             ResponseListener<T> listener) {
         this.target = targetURL;
         this.payload = payload;
index 02f697f37f859a3a8376b1dd62bccd22558b2bfc..8da6d0edc6790c45b2c269541e9848b6915d8e21 100644 (file)
@@ -35,6 +35,7 @@ package org.openhab.binding.lgwebos.internal.handler.command;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.lgwebos.internal.handler.core.ResponseListener;
 
 import com.google.gson.JsonObject;
@@ -48,7 +49,7 @@ import com.google.gson.JsonObject;
  */
 public class ServiceSubscription<T> extends ServiceCommand<T> {
 
-    public ServiceSubscription(String uri, JsonObject payload, Function<JsonObject, T> converter,
+    public ServiceSubscription(String uri, JsonObject payload, Function<JsonObject, @Nullable T> converter,
             ResponseListener<T> listener) {
         super(uri, payload, converter, listener);
         type = Type.subscribe;
index d14e1ee84e953e8d82794a39b4b3aa8a313c3a67..6c59b8fa0b5223b3931fbe6567019c9514f7ccab 100644 (file)
@@ -636,6 +636,7 @@ public class LifxLightHandler extends BaseThingHandler {
                     .setTemperature(percentTypeToKelvin(localPowerOnTemperature, product.getTemperatureRange()));
         }
 
+        PercentType powerOnBrightness = this.powerOnBrightness;
         if (powerOnBrightness != null) {
             PercentType newBrightness = onOff == OnOffType.ON ? powerOnBrightness : new PercentType(0);
             getLightStateForCommand().setBrightness(newBrightness);
index d44ece03d497bb2732d952358dbe64552c3a395f..67aabcd0289a463cb26ac52b0928cb6e7b4edca4 100644 (file)
@@ -213,7 +213,7 @@ public class EnedisHttpApi {
     public UserInfo getUserInfo() throws LinkyException {
         final String user_info_url = URL_APPS_LINCS + "/userinfos";
         String data = getData(user_info_url);
-        return gson.fromJson(data, UserInfo.class);
+        return Objects.requireNonNull(gson.fromJson(data, UserInfo.class));
     }
 
     private Consumption getMeasures(String userId, String prmId, LocalDate from, LocalDate to, String request)
index 4a0ea241ff260282aa156a1f33f050564369e2cc..59e0a520d0ce74b3c131d3de26f81e1fb862fa9d 100644 (file)
@@ -533,14 +533,14 @@ public class LxServerHandler extends BaseThingHandler implements LxServerHandler
         channels.sort((c1, c2) -> {
             String label1 = c1.getLabel();
             String label2 = c2.getLabel();
-            if (label1 == null && label2 != null) {
+            if (label1 != null && label2 != null) {
+                return label1.compareTo(label2);
+            } else if (label1 == null && label2 != null) {
                 return 1;
             } else if (label1 != null && label2 == null) {
                 return -1;
-            } else if (label1 == null && label2 == null) {
-                return 0;
             } else {
-                return label1.compareTo(label2);
+                return 0;
             }
         });
         ThingBuilder builder = editThing();
index c65e4276bf0ec49f7293bc95adbd5aaea9181219..5aa3d48b58ef7d1c236ada7542738659a630bffa 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.luftdateninfo.internal.handler;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -82,7 +83,7 @@ public class HTTPHandler {
                         } else {
                             failure = result.getFailure().getMessage();
                         }
-                        callback.onError(failure);
+                        callback.onError(Objects.requireNonNullElse(failure, "Unknown error"));
                     } else {
                         callback.onResponse(getContentAsString());
                     }
index 53d70691a459097c28a27065652373b08e29f9a7..2d9d605c48714e62e3a228612182f430945a564e 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.luftdateninfo.internal;
 import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -41,14 +42,17 @@ public class HTTPHandlerEvalTest {
     public void setUp() {
         String conditionsStr = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
         assertNotNull(conditionsStr);
+        Objects.requireNonNull(conditionsStr);
         conditions = http.getLatestValues(conditionsStr);
 
         String particulateStr = FileReader.readFileInString("src/test/resources/pm-result.json");
         assertNotNull(particulateStr);
+        Objects.requireNonNull(particulateStr);
         particulate = http.getLatestValues(particulateStr);
 
         String noiseStr = FileReader.readFileInString("src/test/resources/noise-result.json");
         assertNotNull(noiseStr);
+        Objects.requireNonNull(noiseStr);
         noise = http.getLatestValues(noiseStr);
     }
 
index 1ea6da258093a9db1dc2f28a54d7e2eea2ac2aa8..3e8936c817c7ea4f45d27bee4017d6163855aca0 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.luftdateninfo.internal;
 import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
@@ -39,8 +40,10 @@ public class HTTPHandlerValueTest {
     public void testValueDecoding() {
         String resource1 = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
         assertNotNull(resource1);
+        Objects.requireNonNull(resource1);
         List<SensorDataValue> l = http.getLatestValues(resource1);
         assertNotNull(l);
+        Objects.requireNonNull(l);
         l.forEach(sd -> {
             testSensorValue(sd);
         });
@@ -48,8 +51,10 @@ public class HTTPHandlerValueTest {
         String resource2 = FileReader
                 .readFileInString("src/test/resources/condition-result-no-pressure-flipped-values.json");
         assertNotNull(resource2);
+        Objects.requireNonNull(resource2);
         l = http.getLatestValues(resource2);
         assertNotNull(l);
+        Objects.requireNonNull(l);
         l.forEach(sd -> {
             testSensorValue(sd);
         });
index 45db7dc08342dce3371488d99943de3787168515..af84f6195d83372548dc79862bfde9cabf389db6 100644 (file)
@@ -150,9 +150,11 @@ public class LeapDeviceDiscoveryService extends AbstractDiscoveryService
                     } else {
                         areaName = "Occupancy Group";
                     }
-                    logger.debug("Discovered occupancy group: {} areas: {} area name: {}", groupNum,
-                            oGroup.associatedAreas.length, areaName);
-                    notifyDiscovery(THING_TYPE_OGROUP, groupNum, areaName);
+                    if (areaName != null) {
+                        logger.debug("Discovered occupancy group: {} areas: {} area name: {}", groupNum,
+                                oGroup.associatedAreas.length, areaName);
+                        notifyDiscovery(THING_TYPE_OGROUP, groupNum, areaName);
+                    }
                 }
             }
             this.areaMap = null;
index a8d96050a1cf8dbcbebd2664b6a05acf63d74d29..47867a3484769ac0040723be525a267e45a11397 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.lutron.internal.protocol.leap;
 
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -212,6 +213,7 @@ public class LeapMessageParser {
         try {
             if (messageBody.has(memberName)) {
                 JsonObject jsonObject = messageBody.get(memberName).getAsJsonObject();
+                @Nullable
                 T obj = gson.fromJson(jsonObject, type);
                 return obj;
             } else {
@@ -233,7 +235,7 @@ public class LeapMessageParser {
 
                 for (JsonElement element : jsonArray) {
                     JsonObject jsonObject = element.getAsJsonObject();
-                    T obj = gson.fromJson(jsonObject, type);
+                    T obj = Objects.requireNonNull(gson.fromJson(jsonObject, type));
                     objList.add(obj);
                 }
                 return objList;
index bc218d9d71ad4448a15e5d4815f3a987f519e38d..df901d91f38645564364865fda8855690ab14289 100644 (file)
@@ -391,10 +391,7 @@ public class MagentaTVControl {
             // direct key code
             return key;
         }
-        if (KEY_MAP.containsKey(key)) {
-            return KEY_MAP.get(key);
-        }
-        return "";
+        return KEY_MAP.getOrDefault(key, "");
     }
 
     /**
index 7dfcc29952c1fc1cf1d453e3c0b9fc101ebc1636..371c2402359fc6362357d45d95829c4808f46c0d 100644 (file)
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
 import java.time.ZonedDateTime;
 import java.util.AbstractMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -115,9 +116,13 @@ public class MeteoAlerteHandler extends BaseThingHandler {
                 throw new MalformedURLException("queryUrl not initialized");
             }
             String response = HttpUtil.executeUrl("GET", queryUrl, TIMEOUT_MS);
+            if (response == null) {
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "empty response");
+                return;
+            }
             updateStatus(ThingStatus.ONLINE);
             ApiResponse apiResponse = gson.fromJson(response, ApiResponse.class);
-            updateChannels(apiResponse);
+            updateChannels(Objects.requireNonNull(apiResponse));
         } catch (MalformedURLException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     String.format("Querying '%s' raised : %s", queryUrl, e.getMessage()));
index 63f1929da7f9df1d0f0e5ad1b9362474771c41b8..92df54e41adf4cea0f3d92d885d262263573eea0 100644 (file)
@@ -129,9 +129,9 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
         }
         logger.debug("Locating action for {} channel '{}': '{}'", getThing().getUID(), channelUID.getId(), command);
         if (!actions.isEmpty()) {
-            if (actions.containsKey(channelUID)) {
+            MiIoBasicChannel miIoBasicChannel = actions.get(channelUID);
+            if (miIoBasicChannel != null) {
                 int valuePos = 0;
-                MiIoBasicChannel miIoBasicChannel = actions.get(channelUID);
                 for (MiIoDeviceAction action : miIoBasicChannel.getActions()) {
                     @Nullable
                     JsonElement value = null;
index 1966d9bf7fb9d3b5a6d4214a7dfb3134afe1c9d5..fbda70afd5d05bab36cba1f5abbefbed59082eee 100644 (file)
@@ -17,12 +17,7 @@ import static org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal
 import java.math.BigDecimal;
 import java.time.Duration;
 import java.time.LocalDateTime;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.NotImplementedException;
@@ -922,7 +917,8 @@ public class ModbusDataThingHandler extends BaseThingHandler {
     }
 
     private ChannelUID getChannelUID(String channelID) {
-        return channelCache.computeIfAbsent(channelID, id -> new ChannelUID(getThing().getUID(), id));
+        return Objects
+                .requireNonNull(channelCache.computeIfAbsent(channelID, id -> new ChannelUID(getThing().getUID(), id)));
     }
 
     private void updateStatusIfChanged(ThingStatus status) {
index 73d1bdfaab6befcd9b6eddc0a7466c0bf48a6a97..bfc7500b60baf8938aced9cdccdda93eea26d45e 100644 (file)
@@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.stream.Stream;
@@ -201,8 +202,10 @@ public class MqttTopicClassMapperTests {
                 String suffix = mapToField != null ? mapToField.suffix() : "";
                 assertThat(f.field.get(attributes).toString(), is(prefix + annotation.value() + suffix));
             } else {
-                assertThat(Stream.of((String[]) f.field.get(attributes)).reduce((v, i) -> v + "," + i).orElse(""),
-                        is(annotation.value()));
+                String[] attributeArray = (String[]) f.field.get(attributes);
+                assertNotNull(attributeArray);
+                Objects.requireNonNull(attributeArray);
+                assertThat(Stream.of(attributeArray).reduce((v, i) -> v + "," + i).orElse(""), is(annotation.value()));
             }
         }
 
index f0635264789dbf72b9d2522e808d1c435f8401cc..00db2dc330a4b0a43f0ba7e59441d81908480a87 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.mqtt.homeassistant.internal;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -54,7 +55,7 @@ public abstract class BaseChannelConfiguration {
      */
     public static <C extends BaseChannelConfiguration> C fromString(final String configJSON, final Gson gson,
             final Class<C> clazz) {
-        return gson.fromJson(configJSON, clazz);
+        return Objects.requireNonNull(gson.fromJson(configJSON, clazz));
     }
 
     /**
index 52f0e398b259063fa01f8e66ca63e1262511ad0c..b07ace908a02270daaf679b2c0e8fd639b8da6d5 100644 (file)
@@ -69,10 +69,7 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
 
         return new TypeAdapter<T>() {
             @Override
-            public T read(@Nullable JsonReader in) throws IOException {
-                if (in == null) {
-                    return null;
-                }
+            public @Nullable T read(JsonReader in) throws IOException {
                 /* read the object using the default adapter, but translate the names in the reader */
                 T result = delegate.read(MappingJsonReader.getConfigMapper(in));
                 /* do the '~' expansion afterwards */
@@ -81,7 +78,7 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
             }
 
             @Override
-            public void write(@Nullable JsonWriter out, T value) throws IOException {
+            public void write(JsonWriter out, @Nullable T value) throws IOException {
                 delegate.write(out, value);
             }
         };
@@ -93,17 +90,14 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
 
         return new TypeAdapter<T>() {
             @Override
-            public T read(@Nullable JsonReader in) throws IOException {
-                if (in == null) {
-                    return null;
-                }
+            public @Nullable T read(JsonReader in) throws IOException {
                 /* read the object using the default adapter, but translate the names in the reader */
                 T result = delegate.read(MappingJsonReader.getDeviceMapper(in));
                 return result;
             }
 
             @Override
-            public void write(@Nullable JsonWriter out, T value) throws IOException {
+            public void write(JsonWriter out, @Nullable T value) throws IOException {
                 delegate.write(out, value);
             }
         };
index 27742b152c06b5f2f40e99100b75bc607730c568..ddfdb9a14f1cf3efa5e60d63573eb4c99c61b3e9 100644 (file)
@@ -19,6 +19,7 @@ import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Scanner;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutionException;
@@ -493,9 +494,8 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
                         if (line.startsWith("data:")) {
                             String json = line.substring(5).trim(); // supposed to be JSON
                             try {
-                                @Nullable
                                 TouchEvents touchEvents = gson.fromJson(json, TouchEvents.class);
-                                handleTouchEvents(touchEvents);
+                                handleTouchEvents(Objects.requireNonNull(touchEvents));
                             } catch (JsonSyntaxException jse) {
                                 logger.error("couldn't parse touch event json {}", json);
                             }
@@ -645,9 +645,8 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
     private ControllerInfo receiveControllerInfo() throws NanoleafException, NanoleafUnauthorizedException {
         ContentResponse controllerlInfoJSON = OpenAPIUtils.sendOpenAPIRequest(OpenAPIUtils.requestBuilder(httpClient,
                 getControllerConfig(), API_GET_CONTROLLER_INFO, HttpMethod.GET));
-        @Nullable
         ControllerInfo controllerInfo = gson.fromJson(controllerlInfoJSON.getContentAsString(), ControllerInfo.class);
-        return controllerInfo;
+        return Objects.requireNonNull(controllerInfo);
     }
 
     private void sendStateCommand(String channel, Command command) throws NanoleafException {
index 099ec5adeed8c946f86c6c1015c2696df02bbf57..cdc2984f9b3d4224cda6828ab5a59319cf33755c 100644 (file)
@@ -76,7 +76,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), NeeoBrain.class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), NeeoBrain.class));
     }
 
     /**
@@ -97,7 +97,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), NeeoRoom.class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), NeeoRoom.class));
     }
 
     /**
@@ -121,7 +121,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), ExecuteResult.class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), ExecuteResult.class));
     }
 
     /**
@@ -145,7 +145,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), ExecuteResult.class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), ExecuteResult.class));
     }
 
     /**
@@ -163,7 +163,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), String[].class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), String[].class));
     }
 
     /**
@@ -189,7 +189,7 @@ public class NeeoBrainApi implements AutoCloseable {
             throw resp.createException();
         }
 
-        return gson.fromJson(resp.getContent(), ExecuteResult.class);
+        return Objects.requireNonNull(gson.fromJson(resp.getContent(), ExecuteResult.class));
     }
 
     /**
index 90ec7e881728ca08b487c825649ba1ec44914713..462f9f45b394e5ee7962df0701423caead0f162c 100644 (file)
@@ -190,7 +190,7 @@ public class NeeoBrainHandler extends BaseBridgeHandler {
                             public void post(String json) {
                                 triggerChannel(NeeoConstants.CHANNEL_BRAIN_FOWARDACTIONS, json);
 
-                                final NeeoAction action = gson.fromJson(json, NeeoAction.class);
+                                final NeeoAction action = Objects.requireNonNull(gson.fromJson(json, NeeoAction.class));
 
                                 for (final Thing child : getThing().getThings()) {
                                     final ThingHandler th = child.getHandler();
index d83a337190c02e27e2389a0aee55a27aaf727465..1cca3ec41ea175af1710cbbda2c80e84313c5857 100644 (file)
@@ -35,16 +35,15 @@ import com.google.gson.JsonPrimitive;
 public class NeohubBoolDeserializer implements JsonDeserializer<NeohubBool> {
 
     @Override
-    public NeohubBool deserialize(@Nullable JsonElement json, @Nullable Type typeOfT,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        if (json != null) {
-            JsonPrimitive jsonPrimitive = json.getAsJsonPrimitive();
-            if (jsonPrimitive.isBoolean()) {
-                return new NeohubBool(jsonPrimitive.getAsBoolean());
-            } else if (jsonPrimitive.isNumber()) {
-                return new NeohubBool(jsonPrimitive.getAsNumber().intValue() != 0);
-            }
+    public @Nullable NeohubBool deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+            throws JsonParseException {
+        JsonPrimitive jsonPrimitive = json.getAsJsonPrimitive();
+        if (jsonPrimitive.isBoolean()) {
+            return new NeohubBool(jsonPrimitive.getAsBoolean());
+        } else if (jsonPrimitive.isNumber()) {
+            return new NeohubBool(jsonPrimitive.getAsNumber().intValue() != 0);
         }
+
         return new NeohubBool(false);
     }
 }
index 6da8ea92da99b12598b97f076e1f583723714b70..dd51659310cba497624473f7f384bb2a7fbb2878 100644 (file)
@@ -60,11 +60,13 @@ public class NestUpdateHandler<T> {
 
     private Set<NestThingDataListener<T>> getListeners(String nestId) {
         Set<NestThingDataListener<T>> listeners = new HashSet<>();
-        if (listenersMap.get(nestId) != null) {
-            listeners.addAll(listenersMap.get(nestId));
+        Set<NestThingDataListener<T>> idListeners = listenersMap.get(nestId);
+        if (idListeners != null) {
+            listeners.addAll(idListeners);
         }
-        if (listenersMap.get(ANY_ID) != null) {
-            listeners.addAll(listenersMap.get(ANY_ID));
+        Set<NestThingDataListener<T>> anyListeners = listenersMap.get(ANY_ID);
+        if (anyListeners != null) {
+            listeners.addAll(anyListeners);
         }
         return listeners;
     }
index 8929af01255db6e6e527b3f6f017ea47a84bd733..e7fd8979331d6f8509e5fe4bf0f46e153f20257a 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.netatmo.internal.webhook;
 
 import java.io.IOException;
+import java.util.Objects;
 import java.util.Scanner;
 
 import javax.servlet.ServletException;
@@ -91,7 +92,7 @@ public class WelcomeWebHookServlet extends HttpServlet {
         if (!data.isEmpty() && handler != null) {
             NAWebhookCameraEvent event = gson.fromJson(data, NAWebhookCameraEvent.class);
             logger.debug("Event transmitted from restService");
-            handler.webHookEvent(event);
+            handler.webHookEvent(Objects.requireNonNull(event));
         }
 
         setHeaders(resp);
index c0b369f1855b11af996664593f61bd2624fb6e20..60c5a8409da66a989f27e22d4694fe2480e45647 100644 (file)
@@ -328,6 +328,10 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
         for (Map<String, String> location : data) {
             String id = location.get("id");
             String name = location.get("name");
+            if (id == null || name == null) {
+                logger.debug("id or name null, ignoring entry");
+                continue;
+            }
             NhcLocation1 nhcLocation1 = new NhcLocation1(name);
             locations.put(id, nhcLocation1);
         }
@@ -337,8 +341,11 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
         logger.debug("Niko Home Control: list actions");
 
         for (Map<String, String> action : data) {
-
             String id = action.get("id");
+            if (id == null) {
+                logger.debug("id not found in action {}", action);
+                continue;
+            }
             String value1 = action.get("value1");
             int state = ((value1 == null) || value1.isEmpty() ? 0 : Integer.parseInt(value1));
             String value2 = action.get("value2");
@@ -349,6 +356,10 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
             if (!actions.containsKey(id)) {
                 // Initial instantiation of NhcAction class for action object
                 String name = action.get("name");
+                if (name == null) {
+                    logger.debug("name not found in action {}", action);
+                    continue;
+                }
                 String type = action.get("type");
                 ActionType actionType = ActionType.GENERIC;
                 switch (type) {
@@ -371,8 +382,8 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
                 }
                 String locationId = action.get("location");
                 String location = "";
-                if (!locationId.isEmpty()) {
-                    location = locations.get(locationId).getName();
+                if (locationId != null && !locationId.isEmpty()) {
+                    location = locations.getOrDefault(locationId, new NhcLocation1("")).getName();
                 }
                 NhcAction nhcAction = new NhcAction1(id, name, actionType, location, this, scheduler);
                 if (actionType == ActionType.ROLLERSHUTTER) {
@@ -405,6 +416,10 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
         for (Map<String, String> thermostat : data) {
             try {
                 String id = thermostat.get("id");
+                if (id == null) {
+                    logger.debug("skipping thermostat {}, id not found", thermostat);
+                    continue;
+                }
                 int measured = parseIntOrThrow(thermostat.get("measured"));
                 int setpoint = parseIntOrThrow(thermostat.get("setpoint"));
                 int mode = parseIntOrThrow(thermostat.get("mode"));
@@ -528,6 +543,10 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
 
     private void eventGetAlarms(Map<String, String> data) {
         String alarmText = data.get("text");
+        if (alarmText == null) {
+            logger.debug("message does not contain alarmtext: {}", data);
+            return;
+        }
         switch (data.getOrDefault("type", "")) {
             case "0":
                 logger.debug("Niko Home Control: alarm - {}", alarmText);
index b3e195b3d587bb8de30a5f7744032ac89179405d..21c6de463febace9bb7b19f2023aa8d4a30fb76a 100644 (file)
@@ -33,8 +33,7 @@ import java.util.stream.IntStream;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.nikohomecontrol.internal.protocol.NhcControllerEvent;
-import org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlCommunication;
+import org.openhab.binding.nikohomecontrol.internal.protocol.*;
 import org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlConstants.ActionType;
 import org.openhab.binding.nikohomecontrol.internal.protocol.nhc2.NhcDevice2.NhcProperty;
 import org.openhab.binding.nikohomecontrol.internal.protocol.nhc2.NhcMessage2.NhcMessageParam;
@@ -309,7 +308,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
             return;
         } else if ("devices.added".equals(method)) {
             deviceList.forEach(this::addDevice);
-        } else if ("devices.changed".contentEquals(method)) {
+        } else if ("devices.changed".equals(method)) {
             deviceList.forEach(this::removeDevice);
             deviceList.forEach(this::addDevice);
         }
@@ -444,12 +443,16 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
             return;
         }
 
-        if (actions.containsKey(device.uuid)) {
-            updateActionState((NhcAction2) actions.get(device.uuid), deviceProperties);
-        } else if (thermostats.containsKey(device.uuid)) {
-            updateThermostatState((NhcThermostat2) thermostats.get(device.uuid), deviceProperties);
-        } else if (energyMeters.containsKey(device.uuid)) {
-            updateEnergyMeterState((NhcEnergyMeter2) energyMeters.get(device.uuid), deviceProperties);
+        NhcAction action = actions.get(device.uuid);
+        NhcThermostat thermostat = thermostats.get(device.uuid);
+        NhcEnergyMeter energyMeter = energyMeters.get(device.uuid);
+
+        if (action != null) {
+            updateActionState((NhcAction2) action, deviceProperties);
+        } else if (thermostat != null) {
+            updateThermostatState((NhcThermostat2) thermostat, deviceProperties);
+        } else if (energyMeter != null) {
+            updateEnergyMeterState((NhcEnergyMeter2) energyMeter, deviceProperties);
         }
     }
 
index 9a4b84db2d03ed8fe7e98be063ece6482bdc9da3..0a95d5ca3108215887f8f7668f5c9285d1b5c066 100644 (file)
@@ -22,6 +22,7 @@ import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Objects;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -122,8 +123,7 @@ public class NtpHandler extends BaseThingHandler {
             logger.debug("{} using default timezone '{}', because configuration setting '{}' is null.",
                     getThing().getUID(), timeZoneProvider.getTimeZone(), PROPERTY_TIMEZONE);
         }
-        ZoneId zoneId = timeZoneId != null ? timeZoneId : timeZoneProvider.getTimeZone();
-
+        ZoneId zoneId = Objects.requireNonNullElse(timeZoneId, timeZoneProvider.getTimeZone());
         Channel stringChannel = getThing().getChannel(CHANNEL_STRING);
         if (stringChannel != null) {
             String dateTimeFormatString = stringChannel.getConfiguration()
@@ -183,7 +183,7 @@ public class NtpHandler extends BaseThingHandler {
             refreshNtpCount--;
         }
 
-        ZoneId zoneId = timeZoneId != null ? timeZoneId : timeZoneProvider.getTimeZone();
+        ZoneId zoneId = Objects.requireNonNullElse(timeZoneId, timeZoneProvider.getTimeZone());
         ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(networkTimeInMillis), zoneId);
         updateState(CHANNEL_DATE_TIME, new DateTimeType(zoned));
         dateTimeFormat.withZone(zoneId);
@@ -208,7 +208,7 @@ public class NtpHandler extends BaseThingHandler {
             timeInfo.computeDetails();
 
             long serverMillis = timeInfo.getReturnTime() + timeInfo.getOffset();
-            ZoneId zoneId = timeZoneId != null ? timeZoneId : timeZoneProvider.getTimeZone();
+            ZoneId zoneId = Objects.requireNonNullElse(timeZoneId, timeZoneProvider.getTimeZone());
             ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(serverMillis), zoneId);
             logger.debug("{} Got time update from host '{}': {}.", getThing().getUID(), hostname,
                     zoned.format(DATE_FORMATTER_WITH_TZ));
index bc5c26a3f32e1005f97ae9bc73e104481bcc6ddc..281c1e194d00f6e357468630c56688c27f597067 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.nuki.internal;
 
-import java.util.ArrayList;
-
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -118,9 +116,7 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
             logger.warn("Cannot find port of the http service.");
             return null;
         }
-        ArrayList<String> parameters = new ArrayList<>();
-        parameters.add(ipAddress + ":" + port);
-        String callbackUrl = String.format(NukiBindingConstants.CALLBACK_URL, parameters.toArray());
+        String callbackUrl = String.format(NukiBindingConstants.CALLBACK_URL, ipAddress + ":" + port);
         logger.trace("callbackUrl[{}]", callbackUrl);
         return callbackUrl;
     }
index 8b62845c7bf0d202698f1e1fc54ab993ee8b46db..2279f087cc1cb6c5f9145255132af4d5a8d82d9f 100644 (file)
@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 import java.net.SocketException;
 import java.net.URLEncoder;
 import java.time.Instant;
-import java.util.ArrayList;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
@@ -64,16 +63,12 @@ public class NukiHttpClient {
         String configIp = (String) configuration.get(NukiBindingConstants.CONFIG_IP);
         BigDecimal configPort = (BigDecimal) configuration.get(NukiBindingConstants.CONFIG_PORT);
         String configApiToken = (String) configuration.get(NukiBindingConstants.CONFIG_API_TOKEN);
-        ArrayList<String> parameters = new ArrayList<>();
-        parameters.add(configIp);
-        parameters.add(configPort.toString());
-        parameters.add(configApiToken);
-        if (additionalArguments != null) {
-            for (String argument : additionalArguments) {
-                parameters.add(argument);
-            }
-        }
-        String uri = String.format(uriTemplate, parameters.toArray());
+        String[] parameters = new String[additionalArguments.length + 3];
+        parameters[0] = configIp;
+        parameters[1] = configPort.toString();
+        parameters[2] = configApiToken;
+        System.arraycopy(additionalArguments, 0, parameters, 3, additionalArguments.length);
+        String uri = String.format(uriTemplate, parameters);
         logger.trace("prepareUri(...):URI[{}]", uri);
         return uri;
     }
index 39fbf3be96f166dc175a2637f8083d29709e367c..0550a61f02213b88c7ad75ebb25538f44b65001e 100644 (file)
@@ -119,17 +119,16 @@ public class StopHandler extends BaseBridgeHandler {
         if (listener == null) {
             throw new IllegalArgumentException("It makes no sense to register a null listener!");
         }
-        boolean added = routeDataListeners.add(listener);
-        if (added) {
-            String routeId = listener.getRouteId();
-            List<ObaStopArrivalResponse.ArrivalAndDeparture> copiedRouteData;
-            synchronized (routeData) {
-                copiedRouteData = new ArrayList<>(routeData.get(routeId));
-            }
-            Collections.sort(copiedRouteData);
-            listener.onNewRouteData(routeDataLastUpdateMs, copiedRouteData);
+        routeDataListeners.add(listener);
+        String routeId = listener.getRouteId();
+        List<ObaStopArrivalResponse.ArrivalAndDeparture> copiedRouteData;
+        synchronized (routeData) {
+            copiedRouteData = new ArrayList<>(routeData.getOrDefault(routeId, List.of()));
         }
-        return added;
+        Collections.sort(copiedRouteData);
+        listener.onNewRouteData(routeDataLastUpdateMs, copiedRouteData);
+
+        return true;
     }
 
     /**
@@ -212,7 +211,8 @@ public class StopHandler extends BaseBridgeHandler {
                     routeData.put(d.routeId, Arrays.asList(d));
                 }
                 for (String key : routeData.keySet()) {
-                    List<ObaStopArrivalResponse.ArrivalAndDeparture> copy = new ArrayList<>(routeData.get(key));
+                    List<ObaStopArrivalResponse.ArrivalAndDeparture> copy = new ArrayList<>(
+                            routeData.getOrDefault(key, List.of()));
                     Collections.sort(copy);
                     copiedRouteData.put(key, copy);
                 }
index be112770c60a51aee258a383395fe2bcf0e8495f..45abf951c77e910087fda8ae939e0543e78a0204 100644 (file)
@@ -102,7 +102,7 @@ public class BAE091xSensorThingHandler extends OwBaseThingHandler {
         BAE091xHandlerConfiguration configuration = getConfig().as(BAE091xHandlerConfiguration.class);
 
         Set<OwChannelConfig> wantedChannel = new HashSet<>();
-        wantedChannel.addAll(SENSOR_TYPE_CHANNEL_MAP.get(sensorType));
+        wantedChannel.addAll(SENSOR_TYPE_CHANNEL_MAP.getOrDefault(sensorType, Set.of()));
 
         // Pin1:
         switch (configuration.pin1) {
index 49d8289faf38186f5b974a76aa57167b53da5937..831cc1a06a1e3691754834f2ba5fe05c88076329 100644 (file)
@@ -16,6 +16,7 @@ import static org.openhab.binding.pixometer.internal.PixometerBindingConstants.*
 
 import java.io.IOException;
 import java.time.Duration;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -253,7 +254,7 @@ public class MeterHandler extends BaseThingHandler {
 
             ReadingInstance latestReading = gson.fromJson(new JsonParser().parse(urlResponse), ReadingInstance.class);
 
-            return new MeterState(latestReading);
+            return new MeterState(Objects.requireNonNull(latestReading));
         } catch (IOException e) {
             logger.debug("Exception while refreshing cache for Meter {}: {}", getThing().getUID(), e.getMessage(), e);
             return null;
index 1f7b04a2b0b438629cb79b33f47bdd776dc36975..0dff1cb7c59bb4cd1c794d0e76b2a2d5161bc1fd 100644 (file)
@@ -18,6 +18,7 @@ import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.TimeUnit;
@@ -286,12 +287,12 @@ public class RemoteopenhabRestClient {
                     break;
                 case "ItemAddedEvent":
                     itemName = extractItemNameFromTopic(event.topic, event.type, "added");
-                    item = jsonParser.fromJson(event.payload, Item.class);
+                    item = Objects.requireNonNull(jsonParser.fromJson(event.payload, Item.class));
                     listeners.forEach(listener -> listener.onItemAdded(item));
                     break;
                 case "ItemRemovedEvent":
                     itemName = extractItemNameFromTopic(event.topic, event.type, "removed");
-                    item = jsonParser.fromJson(event.payload, Item.class);
+                    item = Objects.requireNonNull(jsonParser.fromJson(event.payload, Item.class));
                     listeners.forEach(listener -> listener.onItemRemoved(item));
                     break;
                 case "ItemUpdatedEvent":
index ee2c5c0ad7023a802e99d34999a86c8958a6d6d8..d66bdffa31018f40aa4e2e13983986fdf1c1b46a 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.revogi.internal.api;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -69,7 +70,7 @@ public class StatusService {
     private StatusRawDTO deserializeString(String response) {
         String extractedJsonResponse = response.substring(response.lastIndexOf(VERSION_STRING) + 2);
         try {
-            return gson.fromJson(extractedJsonResponse, StatusRawDTO.class);
+            return Objects.requireNonNull(gson.fromJson(extractedJsonResponse, StatusRawDTO.class));
         } catch (JsonSyntaxException e) {
             logger.warn("Could not parse string \"{}\" to StatusRaw", response, e);
             return new StatusRawDTO(503, 0, new StatusDTO(false, 503, null, null, null));
index 4d79cc2078a1ac06649c0dbcf422d9a7d89a1377..0147d73e497e250d9a753140125bed519c587fe7 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.revogi.internal.api;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -76,7 +77,7 @@ public class SwitchService {
     private SwitchResponseDTO deserializeString(String response) {
         String extractedJsonResponse = response.substring(response.lastIndexOf(VERSION_STRING) + 2);
         try {
-            return gson.fromJson(extractedJsonResponse, SwitchResponseDTO.class);
+            return Objects.requireNonNull(gson.fromJson(extractedJsonResponse, SwitchResponseDTO.class));
         } catch (JsonSyntaxException e) {
             logger.warn("Could not parse string \"{}\" to SwitchResponse", response);
             return new SwitchResponseDTO(0, 503);
index 0f5b0e48f0b99c340e522e3461189fe1d893d856..48f698218a01ba729ecceec4016a906d7b9a41bb 100644 (file)
@@ -70,6 +70,10 @@ public class RFXComDeviceDiscoveryService extends AbstractDiscoveryService imple
 
         String id = message.getDeviceId();
         ThingTypeUID uid = RFXComBindingConstants.PACKET_TYPE_THING_TYPE_UID_MAP.get(message.getPacketType());
+        if (uid == null) {
+            logger.debug("cannot find uid for message {}", message);
+            return;
+        }
         ThingUID thingUID = new ThingUID(uid, bridge, id.replace(ID_DELIMITER, "_"));
 
         if (!bridgeHandler.getConfiguration().disableDiscovery) {
index 7e53cd64a88f5b5f7ddcb7e6ebde64ed1028fab3..514354dc626fe362f080e955e333fc514fcb449f 100644 (file)
@@ -984,7 +984,7 @@ public abstract class RotelConnector {
             } else {
                 for (RotelSource src : sourcesLabels.keySet()) {
                     String label = sourcesLabels.get(src);
-                    if (value.startsWith(label)) {
+                    if (label != null && value.startsWith(label)) {
                         if (source == null || sourcesLabels.get(source).length() < label.length()) {
                             source = src;
                         }
index fe6df3c45050151e127f4335b8c40a2595389a42..1e583824634414b052f0f95b777f16ddf24046ab 100644 (file)
@@ -16,6 +16,7 @@ import java.io.InterruptedIOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Map;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -1145,11 +1146,10 @@ public class RotelSimuConnector extends RotelConnector {
         String label;
         if (considerFollowMain && source.getName().equals(RotelSource.CAT1_FOLLOW_MAIN.getName())) {
             label = "SOURCE";
-        } else if (sourcesLabels.get(source) != null) {
-            label = sourcesLabels.get(source);
         } else {
-            label = source.getLabel();
+            label = Objects.requireNonNullElse(sourcesLabels.get(source), source.getLabel());
         }
+
         return label;
     }
 }
index 4508197923d38a9aa423dfa352608bcdc3974f5d..d8bd37559f1fa93aaf7766b3ae0253bd90d3b5b4 100644 (file)
@@ -231,10 +231,8 @@ public class MainTVServerService implements UpnpIOParticipant, SamsungTvService
 
         if (result.get("Result").equals("OK")) {
             String xml = result.get("SourceList");
-
-            Map<String, String> list = parseSourceList(xml);
-            if (list != null) {
-                id = list.get(source);
+            if (xml != null) {
+                id = parseSourceList(xml).get(source);
             }
         } else {
             logger.warn("Source list query failed, result='{}'", result.get("Result"));
index 963f2bd42b3e75d93efcb3616983526ea39e0683..1608681185051caf8a903b5f31c3d55f00fd53b8 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.satel.internal.event;
 import java.util.BitSet;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.satel.internal.types.StateType;
@@ -71,10 +72,10 @@ public class IntegraStateEvent implements SatelEvent {
         if (stateType.getStartByte() == 0 && bitsCount == stateBits.size()) {
             return stateBits;
         }
-        return stateBitsMap.computeIfAbsent(stateType, k -> {
+        return Objects.requireNonNull(stateBitsMap.computeIfAbsent(stateType, k -> {
             int startBit = k.getStartByte() * 8;
             return stateBits.get(startBit, startBit + bitsCount);
-        });
+        }));
     }
 
     /**
index ca4b7060d9a757c3489d24f72c22d24ea02b0891..f6416b366cf8872cbb7ad3066d6b8a155e8a8b59 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.senechome.internal;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
@@ -78,7 +79,7 @@ public class SenecHomeApi {
                 .content(new StringContentProvider(gson.toJson(new SenecHomeResponse()))).send();
 
         if (response.getStatus() == HttpStatus.OK_200) {
-            return gson.fromJson(response.getContentAsString(), SenecHomeResponse.class);
+            return Objects.requireNonNull(gson.fromJson(response.getContentAsString(), SenecHomeResponse.class));
         } else {
             logger.trace("Got unexpected response code {}", response.getStatus());
             throw new IOException("Got unexpected response code " + response.getStatus());
index 393485c82aaef69bfca332f555f152ca23769296..78902720e14e974029fa4e119821ca57e1942c28 100644 (file)
@@ -131,35 +131,44 @@ public class SenecHomeHandler extends BaseThingHandler {
 
             Channel channelLimitationState = getThing()
                     .getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_POWER_LIMITATION_STATE);
-            updatePowerLimitationStatus(channelLimitationState,
-                    (100 - pvLimitation.intValue()) <= config.limitationTresholdValue, config.limitationDuration);
+            if (channelLimitationState != null) {
+                updatePowerLimitationStatus(channelLimitationState,
+                        (100 - pvLimitation.intValue()) <= config.limitationTresholdValue, config.limitationDuration);
+            }
 
             Channel channelConsumption = getThing()
                     .getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_POWER_CONSUMPTION);
-            updateState(channelConsumption.getUID(),
-                    new QuantityType<Power>(
-                            getSenecValue(response.energy.homePowerConsumption).setScale(2, RoundingMode.HALF_UP),
-                            SmartHomeUnits.WATT));
+            if (channelConsumption != null) {
+                updateState(channelConsumption.getUID(),
+                        new QuantityType<Power>(
+                                getSenecValue(response.energy.homePowerConsumption).setScale(2, RoundingMode.HALF_UP),
+                                SmartHomeUnits.WATT));
+            }
 
             Channel channelEnergyProduction = getThing()
                     .getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_ENERGY_PRODUCTION);
-            updateState(channelEnergyProduction.getUID(),
-                    new QuantityType<Power>(
-                            getSenecValue(response.energy.inverterPowerGeneration).setScale(0, RoundingMode.HALF_UP),
-                            SmartHomeUnits.WATT));
+            if (channelEnergyProduction != null) {
+                updateState(channelEnergyProduction.getUID(), new QuantityType<Power>(
+                        getSenecValue(response.energy.inverterPowerGeneration).setScale(0, RoundingMode.HALF_UP),
+                        SmartHomeUnits.WATT));
+            }
 
             Channel channelBatteryPower = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_POWER);
-            updateState(channelBatteryPower.getUID(),
-                    new QuantityType<Power>(
-                            getSenecValue(response.energy.batteryPower).setScale(2, RoundingMode.HALF_UP),
-                            SmartHomeUnits.WATT));
+            if (channelBatteryPower != null) {
+                updateState(channelBatteryPower.getUID(),
+                        new QuantityType<Power>(
+                                getSenecValue(response.energy.batteryPower).setScale(2, RoundingMode.HALF_UP),
+                                SmartHomeUnits.WATT));
+            }
 
             Channel channelBatteryFuelCharge = getThing()
                     .getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_FUEL_CHARGE);
-            updateState(channelBatteryFuelCharge.getUID(),
-                    new QuantityType<Dimensionless>(
-                            getSenecValue(response.energy.batteryFuelCharge).setScale(0, RoundingMode.HALF_UP),
-                            SmartHomeUnits.PERCENT));
+            if (channelBatteryFuelCharge != null) {
+                updateState(channelBatteryFuelCharge.getUID(),
+                        new QuantityType<Dimensionless>(
+                                getSenecValue(response.energy.batteryFuelCharge).setScale(0, RoundingMode.HALF_UP),
+                                SmartHomeUnits.PERCENT));
+            }
 
             Channel channelGridCurrentPhase1 = getThing()
                     .getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_CURRENT_PH1);
@@ -266,7 +275,9 @@ public class SenecHomeHandler extends BaseThingHandler {
                             SmartHomeUnits.VOLT));
 
             Channel channelBatteryState = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_STATE);
-            updateBatteryState(channelBatteryState, getSenecValue(response.energy.batteryState).intValue());
+            if (channelBatteryState != null) {
+                updateBatteryState(channelBatteryState, getSenecValue(response.energy.batteryState).intValue());
+            }
 
             updateGridPowerValues(getSenecValue(response.grid.currentGridValue));
 
index 48b11eba6e41f0b610245eb84aee05b4d5e08b45..3c58886028b1c589029f7ab02f246ff09dc052ef 100644 (file)
@@ -98,13 +98,14 @@ public class SensiboAccountHandler extends BaseBridgeHandler {
 
         gson = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new TypeAdapter<ZonedDateTime>() {
             @Override
-            public void write(final @NonNullByDefault({}) JsonWriter out, final ZonedDateTime value)
-                    throws IOException {
-                out.value(value.toString());
+            public void write(JsonWriter out, @Nullable ZonedDateTime value) throws IOException {
+                if (value != null) {
+                    out.value(value.toString());
+                }
             }
 
             @Override
-            public ZonedDateTime read(final @NonNullByDefault({}) JsonReader in) throws IOException {
+            public @Nullable ZonedDateTime read(final JsonReader in) throws IOException {
                 return ZonedDateTime.parse(in.nextString());
             }
         }).setLenient().setPrettyPrinting().create();
index d0d09d32d34b7b96969ec311f9cf4b0045a1a867..50271e06295f14031c02ed4ba33bff50488b2275 100644 (file)
@@ -18,6 +18,7 @@ import static org.openhab.binding.shelly.internal.util.ShellyUtils.*;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.shelly.internal.api.ShellyApiJsonDTO.ShellySettingsDimmer;
@@ -103,7 +104,7 @@ public class ShellyDeviceProfile {
         try {
             initFromThingType(thingType);
             settingsJson = json;
-            settings = gson.fromJson(json, ShellySettingsGlobal.class);
+            settings = Objects.requireNonNull(gson.fromJson(json, ShellySettingsGlobal.class));
         } catch (IllegalArgumentException | JsonSyntaxException e) {
             throw new ShellyApiException(
                     thingName + ": Unable to transform settings JSON " + e.toString() + ", json='" + json + "'", e);
index 574f2938e6e401d36cfc7c381a56d0bd2520b90f..87356a5a1e0c1237e8887dfa468747a4bf3e65d2 100644 (file)
@@ -17,10 +17,7 @@ import static org.openhab.binding.shelly.internal.coap.ShellyCoapJSonDTO.*;
 import static org.openhab.binding.shelly.internal.util.ShellyUtils.*;
 
 import java.net.UnknownHostException;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
 
 import org.eclipse.californium.core.CoapClient;
 import org.eclipse.californium.core.coap.CoAP.Code;
@@ -389,6 +386,7 @@ public class ShellyCoapHandler implements ShellyCoapListener {
                     continue;
                 }
                 CoIotDescrSen sen = sensorMap.get(s.id);
+                Objects.requireNonNull(sen);
                 // find matching sensor definition from device description, use the Link ID as index
                 sen = coiot.fixDescription(sen, blkMap);
                 if (!blkMap.containsKey(sen.links)) {
index 467a05682aedaad2fc4a5678fe576d945ba26844..17212c20baf57cb8cb7bab91aebee00fc92feadb 100644 (file)
@@ -41,12 +41,8 @@ public class PointDeserializer implements JsonDeserializer<BasePoint> {
     }
 
     @Override
-    public BasePoint deserialize(@Nullable JsonElement element, @Nullable Type guff,
-            @Nullable JsonDeserializationContext ctxt) throws JsonParseException {
-        if (element == null || ctxt == null) {
-            throw new JsonParseException("method called with null argument(s)");
-        }
-
+    public @Nullable BasePoint deserialize(JsonElement element, Type guff, JsonDeserializationContext ctxt)
+            throws JsonParseException {
         JsonObject obj = element.getAsJsonObject();
         JsonElement value = obj.get("value");
         if (value == null) {
index 5925fbb4d5f185d247590c1ff8f2535f89779878..560ecce8b0484ff0dd4ee75e0494684ce3fcfc23 100644 (file)
@@ -252,10 +252,12 @@ public class SmartMeterHandler extends BaseThingHandler {
             Channel channel = this.thing.getChannel(channelId.getId());
             if (channel != null) {
                 String obis = channel.getProperties().get(SmartMeterBindingConstants.CHANNEL_PROPERTY_OBIS);
-                MeterValue<?> value = this.smlDevice.getMeterValue(obis);
-                if (value != null) {
-                    State state = getStateForObisValue(value, channel);
-                    updateState(channel.getUID(), state);
+                if (obis != null) {
+                    MeterValue<?> value = this.smlDevice.getMeterValue(obis);
+                    if (value != null) {
+                        State state = getStateForObisValue(value, channel);
+                        updateState(channel.getUID(), state);
+                    }
                 }
             }
         }
index 91c691d9beefce2fe093f88cedf86ea959fb54e8..dcc67cfa71085d9488eed77212d5493f61bf1b55 100644 (file)
@@ -67,28 +67,30 @@ public enum Conformity {
                 // Negate if this channel has the unit "Watt" and the negate bit is set. Read from all other
                 // channels the state and check if there is a negate bit.
                 String channelObis = channel.getProperties().get(SmartMeterBindingConstants.CHANNEL_PROPERTY_OBIS);
-                MeterValue<?> value = device.getMeterValue(channelObis);
-                if (value != null && SmartHomeUnits.WATT.isCompatible(value.getUnit())) {
-                    for (String obis : device.getObisCodes()) {
-                        try {
-                            MeterValue<?> otherValue = device.getMeterValue(obis);
-                            ObisCode obisCode = ObisCode.from(obis);
-                            if (otherValue != null) {
-                                if (obisCode.matches((byte) 0x60, (byte) 0x05, (byte) 0x05)) {
-                                    // we found status status obis 96.5.5
-                                    if (NegateHandler.isNegateSet(otherValue.getValue(), 5)) {
-                                        return currentState.negate();
-                                    }
-                                } else if (obisCode.matches((byte) 0x01, (byte) 0x08, (byte) 0x00)) {
-                                    // check obis 1.8.0 for status if status has negate bit set.
-                                    String status = otherValue.getStatus();
-                                    if (status != null && NegateHandler.isNegateSet(status, 5)) {
-                                        return currentState.negate();
+                if (channelObis != null) {
+                    MeterValue<?> value = device.getMeterValue(channelObis);
+                    if (value != null && SmartHomeUnits.WATT.isCompatible(value.getUnit())) {
+                        for (String obis : device.getObisCodes()) {
+                            try {
+                                MeterValue<?> otherValue = device.getMeterValue(obis);
+                                ObisCode obisCode = ObisCode.from(obis);
+                                if (otherValue != null) {
+                                    if (obisCode.matches((byte) 0x60, (byte) 0x05, (byte) 0x05)) {
+                                        // we found status status obis 96.5.5
+                                        if (NegateHandler.isNegateSet(otherValue.getValue(), 5)) {
+                                            return currentState.negate();
+                                        }
+                                    } else if (obisCode.matches((byte) 0x01, (byte) 0x08, (byte) 0x00)) {
+                                        // check obis 1.8.0 for status if status has negate bit set.
+                                        String status = otherValue.getStatus();
+                                        if (status != null && NegateHandler.isNegateSet(status, 5)) {
+                                            return currentState.negate();
+                                        }
                                     }
                                 }
+                            } catch (Exception e) {
+                                logger.warn("Failed to check negate status for obis {}", obis, e);
                             }
-                        } catch (Exception e) {
-                            logger.warn("Failed to check negate status for obis {}", obis, e);
                         }
                     }
                 }
index 35273cd52d4a0fcc1694c2f7b6aaf7d7ae46aa90..8d9fd7cf2561f083a91b3237351b06bb9a43bb35 100644 (file)
@@ -64,8 +64,7 @@ public class SmartthingsHandlerFactory extends BaseThingHandlerFactory implement
     private @Nullable SmartthingsBridgeHandler bridgeHandler = null;
     private @Nullable ThingUID bridgeUID;
     private Gson gson;
-    private List<SmartthingsThingHandler> thingHandlers = Collections
-            .synchronizedList(new ArrayList<SmartthingsThingHandler>());
+    private List<SmartthingsThingHandler> thingHandlers = Collections.synchronizedList(new ArrayList<>());
 
     private @NonNullByDefault({}) HttpClient httpClient;
 
@@ -153,6 +152,9 @@ public class SmartthingsHandlerFactory extends BaseThingHandlerFactory implement
             String data = (String) event.getProperty("data");
             SmartthingsStateData stateData = new SmartthingsStateData();
             stateData = gson.fromJson(data, stateData.getClass());
+            if (stateData == null) {
+                return;
+            }
             SmartthingsThingHandler handler = findHandler(stateData);
             if (handler != null) {
                 handler.handleStateMessage(stateData);
index 6982bc98399740a409eed736db7374950feb8e10..2259b075c420451c959a515fc81e022ed7e49777 100644 (file)
  */
 package org.openhab.binding.smartthings.internal.discovery;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -166,11 +163,11 @@ public class SmartthingsDiscoveryService extends AbstractDiscoveryService implem
 
         // The data returned from the Smartthings hub is a list of strings where each
         // element is the data for one device. That device string is another json object
-        List<String> devices = new ArrayList<String>();
+        List<String> devices = new ArrayList<>();
         devices = gson.fromJson(data, devices.getClass());
         for (String device : devices) {
             SmartthingsDeviceData deviceData = gson.fromJson(device, SmartthingsDeviceData.class);
-            createDevice(deviceData);
+            createDevice(Objects.requireNonNull(deviceData));
         }
     }
 
index 1a62361b4f8b1edad4460069f982058193efa8bc..040320c45e92c273f901de20b658ccc9a960d933 100644 (file)
@@ -372,11 +372,13 @@ public class SmhiHandler extends BaseThingHandler {
         // See https://github.com/openhab/openhab-webui/issues/212
         Set<Integer> hours = new TreeSet<>();
         Set<Integer> days = new TreeSet<>();
-        if (config.hourlyForecasts != null) {
-            hours.addAll(config.hourlyForecasts);
+        List<Integer> hourlyForecasts = config.hourlyForecasts;
+        if (hourlyForecasts != null) {
+            hours.addAll(hourlyForecasts);
         }
-        if (config.dailyForecasts != null) {
-            days.addAll(config.dailyForecasts);
+        List<Integer> dailyForecasts = config.dailyForecasts;
+        if (dailyForecasts != null) {
+            days.addAll(dailyForecasts);
         }
 
         for (int i : hours) {
index 94e045870b7bcc7e0000f43af9f92daccf3018f9..dc208a1243103de6b1de9aebe2a74fb84bbf03c4 100644 (file)
@@ -23,10 +23,7 @@ import java.io.Writer;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -351,7 +348,7 @@ public class SomfyMyLinkBridgeHandler extends BaseBridgeHandler {
             throw new SomfyMyLinkException("Incomplete message.");
         }
 
-        return gson.fromJson(jsonObj, responseType);
+        return Objects.requireNonNull(gson.fromJson(jsonObj, responseType));
     }
 
     private Socket getConnection() throws IOException, SomfyMyLinkException {
index 1f12dc80951d5ce5086fde3e3dd2b293053603b6..7e12dc9cd63cfa72df77e11f8462e78c557398f8 100644 (file)
@@ -130,8 +130,9 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
 
     protected void refresh(String channel) {
         SomfyTahomaBridgeHandler handler = getBridgeHandler();
-        if (handler != null && stateNames.containsKey(channel)) {
-            handler.refresh(url, stateNames.get(channel));
+        String stateName = stateNames.get(channel);
+        if (handler != null && stateName != null) {
+            handler.refresh(url, stateName);
         }
     }
 
index afda601eaf63c74f08465f437743358a75c322f3..628c2cb1f02883f60aa9e829ba3e4fca8c83d23a 100644 (file)
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -88,7 +89,7 @@ public class SpotifyApi {
     public Me getMe() {
         final ContentResponse response = request(GET, SPOTIFY_API_URL, "");
 
-        return ModelUtil.gsonInstance().fromJson(response.getContentAsString(), Me.class);
+        return Objects.requireNonNull(ModelUtil.gsonInstance().fromJson(response.getContentAsString(), Me.class));
     }
 
     /**
index a6b11377a912f06a511b053328ba432fafcbbfaa..efbf6d4051e70258196a3bc2819c8442d0b49283 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.tado.internal.builder;
 
 import java.io.IOException;
 
+import org.openhab.binding.tado.internal.TadoBindingConstants;
 import org.openhab.binding.tado.internal.TadoBindingConstants.FanSpeed;
 import org.openhab.binding.tado.internal.TadoBindingConstants.HvacMode;
 import org.openhab.binding.tado.internal.TadoBindingConstants.TemperatureUnit;
@@ -30,7 +31,11 @@ import org.openhab.binding.tado.internal.handler.TadoZoneHandler;
  */
 public abstract class ZoneSettingsBuilder {
     public static ZoneSettingsBuilder of(TadoZoneHandler zoneHandler) {
-        switch (zoneHandler.getZoneType()) {
+        TadoBindingConstants.ZoneType zoneType = zoneHandler.getZoneType();
+        if (zoneType == null) {
+            throw new IllegalArgumentException("Zone type is null");
+        }
+        switch (zoneType) {
             case HEATING:
                 return new HeatingZoneSettingsBuilder();
             case AIR_CONDITIONING:
index 555d762caa8010324425d6a09a7e472f71bf6fa4..e000fc05ff6a78fd84fbe39abbbc816cf2e952a2 100644 (file)
@@ -62,7 +62,8 @@ public class TadoHomeHandler extends BaseBridgeHandler {
     }
 
     public TemperatureUnit getTemperatureUnit() {
-        String temperatureUnitStr = this.thing.getProperties().get(TadoBindingConstants.PROPERTY_HOME_TEMPERATURE_UNIT);
+        String temperatureUnitStr = this.thing.getProperties()
+                .getOrDefault(TadoBindingConstants.PROPERTY_HOME_TEMPERATURE_UNIT, "CELSIUS");
         return TemperatureUnit.valueOf(temperatureUnitStr);
     }
 
index 7abd80f27f93991c2705dfbd7c02d70909a60735..87db99569961fa1ee33defad751f01c86442335e 100644 (file)
@@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit;
 
 import javax.measure.quantity.Temperature;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.tado.internal.TadoBindingConstants;
 import org.openhab.binding.tado.internal.TadoBindingConstants.OperationMode;
 import org.openhab.binding.tado.internal.TadoBindingConstants.TemperatureUnit;
@@ -81,9 +82,9 @@ public class TadoZoneHandler extends BaseHomeThingHandler {
         return this.configuration.fallbackTimerDuration;
     }
 
-    public ZoneType getZoneType() {
+    public @Nullable ZoneType getZoneType() {
         String zoneTypeStr = this.thing.getProperties().get(TadoBindingConstants.PROPERTY_ZONE_TYPE);
-        return ZoneType.valueOf(zoneTypeStr);
+        return zoneTypeStr != null ? ZoneType.valueOf(zoneTypeStr) : null;
     }
 
     public OverlayTerminationCondition getDefaultTerminationCondition() throws IOException, ApiException {
index c99a5f85b520f80b2179d91ffd361be358608e81..4c7931494d21e0015a8b84913b2e6edac13606d8 100644 (file)
@@ -17,10 +17,7 @@ import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -114,8 +111,8 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
             }
         } else {
             String currentFirmware = thing.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION);
-            if (!isNullOrEmpty(currentFirmware)
-                    && MIN_SUPPORTED_VERSION.compareTo(new TradfriVersion(currentFirmware)) > 0) {
+            if (!isNullOrEmpty(currentFirmware) && MIN_SUPPORTED_VERSION
+                    .compareTo(new TradfriVersion(Objects.requireNonNull(currentFirmware))) > 0) {
                 // older firmware not supported
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                         String.format(
index 87410cce90b24772f1384f77d6a7363e475e8095..0b1869dcdefb003a1f262c16cbb9f37afbb00420 100644 (file)
@@ -148,8 +148,8 @@ public abstract class VelbusThingHandler extends BaseThingHandler implements Vel
             byte[] subAddresses = new byte[numberOfSubAddresses];
             for (int i = 0; i < numberOfSubAddresses; i++) {
                 String propertyKey = SUB_ADDRESS + (i + 1);
-                if (getThing().getProperties().containsKey(propertyKey)) {
-                    String subAddress = getThing().getProperties().get(propertyKey);
+                String subAddress = getThing().getProperties().get(propertyKey);
+                if (subAddress != null) {
                     subAddresses[i] = hexToByte(subAddress);
                 } else {
                     subAddresses[i] = (byte) 0xFF;
index a6675bb0058e381e43cf9cb19b220d692b39e833..f6eefee8169ff95acda5042ffd4d0e6d49a097f8 100644 (file)
@@ -20,13 +20,7 @@ import java.math.RoundingMode;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -365,7 +359,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             if (!isFutureValid(localUpdatesTask)) {
                 return;
             }
-            infoData = gson.fromJson(response, VenstarInfoData.class);
+            infoData = Objects.requireNonNull(gson.fromJson(response, VenstarInfoData.class));
             updateUnits(infoData);
             updateIfChanged(CHANNEL_HEATING_SETPOINT, getHeatingSetpoint());
             updateIfChanged(CHANNEL_COOLING_SETPOINT, getCoolingSetpoint());
index 02909f64f0ace769911280b79f14914e6422be70..7bf4950ee2470196def9eba6b91df432ca0515f3 100644 (file)
@@ -108,10 +108,12 @@ public class VigiCruesHandler extends BaseThingHandler {
         List<QuantityType<?>> flows = new ArrayList<>();
         thing.getProperties().keySet().stream().filter(key -> key.startsWith(FLOOD)).forEach(key -> {
             String value = thing.getProperties().get(key);
-            if (key.contains(FLOW)) {
-                flows.add(new QuantityType<>(value));
-            } else {
-                heights.add(new QuantityType<>(value));
+            if (value != null) {
+                if (key.contains(FLOW)) {
+                    flows.add(new QuantityType<>(value));
+                } else {
+                    heights.add(new QuantityType<>(value));
+                }
             }
         });
         referenceHeights = heights.stream().distinct().sorted().collect(Collectors.toList());
index 8d80377224106db91aa0619fb82fd316a9921655..76c7f399ab9f11c10a8f0a054993c6d53a2d11bf 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.volvooncall.internal.api;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -108,7 +109,7 @@ public class VocHttpApi {
                 throw new IOException();
             } else {
                 logger.debug("Request to `{}` answered : {}", url, jsonResponse);
-                T responseDTO = gson.fromJson(jsonResponse, objectClass);
+                T responseDTO = Objects.requireNonNull(gson.fromJson(jsonResponse, objectClass));
                 String error = responseDTO.getErrorLabel();
                 if (error != null) {
                     throw new VolvoOnCallException(error, responseDTO.getErrorDescription());
index fc2c7983e0a70af1a6a7e574c3119ca2b9cf85ac..d5dcd220dc2ca8bc101dfe7281f718cb24410160 100644 (file)
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Objects;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -207,7 +208,7 @@ public class WeatherCompanyForecastHandler extends WeatherCompanyAbstractHandler
         }
         try {
             logger.trace("Handler: Parsing forecast response: {}", response);
-            ForecastDTO forecast = gson.fromJson(response, ForecastDTO.class);
+            ForecastDTO forecast = Objects.requireNonNull(gson.fromJson(response, ForecastDTO.class));
             logger.debug("Handler: Successfully parsed daily forecast response object");
             updateStatus(ThingStatus.ONLINE);
             updateDailyForecast(forecast);
index 164bed3c4123e1623552408512b109bca711cbdd..6ea940dda812be77bb75f7542241b40ccd37475c 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.weathercompany.internal.handler;
 
 import static org.openhab.binding.weathercompany.internal.WeatherCompanyBindingConstants.*;
 
+import java.util.Objects;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -136,7 +137,8 @@ public class WeatherCompanyObservationsHandler extends WeatherCompanyAbstractHan
         }
         try {
             logger.debug("Handler: Parsing PWS observations response: {}", response);
-            PwsObservationsDTO pwsObservations = gson.fromJson(response, PwsObservationsDTO.class);
+            PwsObservationsDTO pwsObservations = Objects
+                    .requireNonNull(gson.fromJson(response, PwsObservationsDTO.class));
             logger.debug("Handler: Successfully parsed PWS observations response object");
             updateStatus(ThingStatus.ONLINE);
             updatePwsObservations(pwsObservations);
index 7c20d8b0a93d71511ec31f75e80c367fb1eab503..5da0445306e5623a09b59810f3faa88b6a35c89d 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.wlanthermo.internal;
 
 import java.net.URISyntaxException;
+import java.util.Objects;
 import java.util.concurrent.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -108,7 +109,7 @@ public class WlanThermoMiniHandler extends BaseThingHandler {
         try {
             // Update objects with data from device
             String json = httpClient.GET(config.getUri("/app.php")).getContentAsString();
-            app = gson.fromJson(json, App.class);
+            app = Objects.requireNonNull(gson.fromJson(json, App.class));
             logger.debug("Received at /app.php: {}", json);
 
             // Update channels
index 16be29817b3f884193a77119f02f71716aa857dd..4adeeb1ab4b1780d1f5ad93a60d2006ce236d612 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.wlanthermo.internal;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Objects;
 import java.util.concurrent.*;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -134,10 +135,10 @@ public class WlanThermoNanoHandler extends BaseThingHandler {
         try {
             // Update objects with data from device
             String json = httpClient.GET(config.getUri("/data")).getContentAsString();
-            data = gson.fromJson(json, Data.class);
+            data = Objects.requireNonNull(gson.fromJson(json, Data.class));
             logger.debug("Received at /data: {}", json);
             json = httpClient.GET(config.getUri("/settings")).getContentAsString();
-            settings = gson.fromJson(json, Settings.class);
+            settings = Objects.requireNonNull(gson.fromJson(json, Settings.class));
             logger.debug("Received at /settings: {}", json);
 
             // Update channels
index 5cde5abc6d4fb11ae438d3fd358ff2bdb5623ddc..2f45bbeddda8d820d2053702eca884407195f157 100644 (file)
@@ -16,15 +16,9 @@ import static org.openhab.io.homekit.internal.HomekitAccessoryType.*;
 import static org.openhab.io.homekit.internal.HomekitCharacteristicType.*;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.*;
 import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -368,8 +362,8 @@ public class HomekitAccessoryFactory {
         characteristics.forEach((type, item) -> {
             try {
                 // check whether a proxyItem already exists, if not create one.
-                final HomekitOHItemProxy proxyItem = proxyItems.computeIfAbsent(item.getUID(),
-                        k -> new HomekitOHItemProxy(item));
+                final HomekitOHItemProxy proxyItem = Objects
+                        .requireNonNull(proxyItems.computeIfAbsent(item.getUID(), k -> new HomekitOHItemProxy(item)));
                 final HomekitTaggedItem optionalItem = new HomekitTaggedItem(proxyItem,
                         accessory.getRootAccessory().getAccessoryType(), type,
                         accessory.getRootAccessory().getRootDeviceGroupItem(),
index 865c868bf4812eaa6b3671ace6f622136b0be2a4..4d885986b6510c470f5d874d862079a0c80192a0 100644 (file)
@@ -383,7 +383,7 @@ public class Scenes implements RegistryChangeListener<Rule> {
             return NetworkUtils.singleError(cs.gson, uri, HueResponse.UNAUTHORIZED, "Not Authorized");
         }
 
-        final HueStateChange changeRequest = cs.gson.fromJson(body, HueStateChange.class);
+        final HueStateChange changeRequest = Objects.requireNonNull(cs.gson.fromJson(body, HueStateChange.class));
 
         Rule rule = ruleRegistry.remove(id);
         if (rule == null) {
index 801e558389218aa9b152889a221fe4af38915800..2d8877b6b5d25e758e08edc3aa16f5a948a7d81b 100644 (file)
  */
 package org.openhab.io.hueemulation.internal.rest;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import javax.ws.rs.Consumes;
@@ -285,7 +281,8 @@ public class Schedules implements RegistryChangeListener<Rule> {
             return NetworkUtils.singleError(cs.gson, uri, HueResponse.UNAUTHORIZED, "Not Authorized");
         }
 
-        final HueChangeScheduleEntry changeRequest = cs.gson.fromJson(body, HueChangeScheduleEntry.class);
+        final HueChangeScheduleEntry changeRequest = Objects
+                .requireNonNull(cs.gson.fromJson(body, HueChangeScheduleEntry.class));
 
         Rule rule = ruleRegistry.remove(id);
         if (rule == null) {
index 7317f27e1e01aa2c3f7eb19fdb51548f73b7662d..8a699ad84e0275183cf5a0816c2b1441d55c96b7 100644 (file)
@@ -66,14 +66,16 @@ public class DummyItemRegistry implements ItemRegistry {
         for (RegistryChangeListener<Item> l : listeners) {
             l.added(element);
         }
-        return put;
+        return element;
     }
 
     @Override
     public @Nullable Item update(Item element) {
         Item put = items.put(element.getUID(), element);
-        for (RegistryChangeListener<Item> l : listeners) {
-            l.updated(put, element);
+        if (put != null) {
+            for (RegistryChangeListener<Item> l : listeners) {
+                l.updated(put, element);
+            }
         }
         return put;
     }
@@ -81,8 +83,10 @@ public class DummyItemRegistry implements ItemRegistry {
     @Override
     public @Nullable Item remove(String key) {
         Item put = items.remove(key);
-        for (RegistryChangeListener<Item> l : listeners) {
-            l.removed(put);
+        if (put != null) {
+            for (RegistryChangeListener<Item> l : listeners) {
+                l.removed(put);
+            }
         }
         return put;
     }
@@ -139,8 +143,10 @@ public class DummyItemRegistry implements ItemRegistry {
     @Override
     public @Nullable Item remove(String itemName, boolean recursive) {
         Item put = items.remove(itemName);
-        for (RegistryChangeListener<Item> l : listeners) {
-            l.removed(put);
+        if (put != null) {
+            for (RegistryChangeListener<Item> l : listeners) {
+                l.removed(put);
+            }
         }
         return put;
     }
index 3adf35711a43cf4373423c1d066074172f39b12c..127b4cba40f4b1dfe5f7dfd55f2b08247f1918cb 100644 (file)
@@ -65,14 +65,16 @@ public class DummyMetadataRegistry implements MetadataRegistry {
         for (RegistryChangeListener<Metadata> l : listeners) {
             l.added(element);
         }
-        return put;
+        return element;
     }
 
     @Override
     public @Nullable Metadata update(Metadata element) {
         Metadata put = items.put(element.getUID(), element);
-        for (RegistryChangeListener<Metadata> l : listeners) {
-            l.updated(put, element);
+        if (put != null) {
+            for (RegistryChangeListener<Metadata> l : listeners) {
+                l.updated(put, element);
+            }
         }
         return put;
     }
@@ -80,8 +82,10 @@ public class DummyMetadataRegistry implements MetadataRegistry {
     @Override
     public @Nullable Metadata remove(MetadataKey key) {
         Metadata put = items.remove(key);
-        for (RegistryChangeListener<Metadata> l : listeners) {
-            l.removed(put);
+        if (put != null) {
+            for (RegistryChangeListener<Metadata> l : listeners) {
+                l.removed(put);
+            }
         }
         return put;
     }
index 0afee55b4b9dd1418ade442e523a51041a3257b4..c2b779740e75827de3f49a1707ad963dbe48b950 100644 (file)
@@ -65,14 +65,16 @@ public class DummyRuleRegistry implements RuleRegistry {
         for (RegistryChangeListener<Rule> l : listeners) {
             l.added(element);
         }
-        return put;
+        return element;
     }
 
     @Override
     public @Nullable Rule update(Rule element) {
         Rule put = items.put(element.getUID(), element);
-        for (RegistryChangeListener<Rule> l : listeners) {
-            l.updated(put, element);
+        if (put != null) {
+            for (RegistryChangeListener<Rule> l : listeners) {
+                l.updated(put, element);
+            }
         }
         return put;
     }
@@ -80,8 +82,10 @@ public class DummyRuleRegistry implements RuleRegistry {
     @Override
     public @Nullable Rule remove(String key) {
         Rule put = items.remove(key);
-        for (RegistryChangeListener<Rule> l : listeners) {
-            l.removed(put);
+        if (put != null) {
+            for (RegistryChangeListener<Rule> l : listeners) {
+                l.removed(put);
+            }
         }
         return put;
     }
index 15dcf89e51e818235e1d04121f974f20738b6fda..a794eadd55c2b259142f1a1695523207fe63cbc4 100644 (file)
@@ -204,7 +204,7 @@ public class NeeoApi implements AutoCloseable {
         try (HttpRequest req = new HttpRequest()) {
             final HttpResponse res = req.sendGetCommand(sysInfo);
             if (res.getHttpCode() == HttpStatus.OK_200) {
-                return GSON.fromJson(res.getContent(), NeeoSystemInfo.class);
+                return Objects.requireNonNull(GSON.fromJson(res.getContent(), NeeoSystemInfo.class));
             } else {
                 throw res.createException();
             }
index 72150d9d425aacf630d2ccddbf4bfeea095074e6..034cc7b0cf5066b95deca9d3109cea72c117a7a6 100644 (file)
@@ -155,9 +155,12 @@ public class NeeoUtil {
      * @param s The UTF-8 encoded String to be decoded
      * @return the decoded String
      */
-    public static String decodeURIComponent(String s) {
-        String result = null;
+    public static String decodeURIComponent(@Nullable String s) {
+        if (s == null) {
+            return "";
+        }
 
+        String result = null;
         try {
             result = URLDecoder.decode(s, StandardCharsets.UTF_8.name());
         } catch (UnsupportedEncodingException e) {
index 5d9738817bb51c6a64a3fa2f9bfd31555bfef4ea..8e7feb3309146975d37eb286d1876430111462e2 100644 (file)
@@ -130,11 +130,14 @@ class OpenHabToDeviceConverter {
         if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOBINDING_BINDING_ID, thing.getUID().getBindingId())) {
             final Map<String, String> properties = thing.getProperties();
             /** The following properties have matches in org.openhab.binding.neeo.NeeoDeviceHandler.java */
-            final String neeoType = StringUtils.isEmpty(properties.get("Type")) ? NeeoDeviceType.ACCESSOIRE.toString()
-                    : properties.get("Type");
-            final String manufacturer = StringUtils.isEmpty(properties.get("Manufacturer")) ? "openHAB"
-                    : properties.get("Manufacturer");
-
+            String neeoType = properties.get("Type");
+            if (neeoType == null || neeoType.isEmpty()) {
+                neeoType = NeeoDeviceType.ACCESSOIRE.toString();
+            }
+            String manufacturer = properties.get("Manufacturer");
+            if (manufacturer == null || manufacturer.isEmpty()) {
+                manufacturer = "openHAB";
+            }
             final Integer standbyDelay = parseInteger(properties.getOrDefault("Standby Command Delay", "0"));
             final Integer switchDelay = parseInteger(properties.getOrDefault("Source Switch Delay", "0"));
             final Integer shutDownDelay = parseInteger(properties.getOrDefault("Shutdown Delay", "0"));
index 9f20b27a8f9e5834434a0837f67a01fac06a76d7..25c813383df491ac77965ee37bab4ed2266030c3 100644 (file)
@@ -110,7 +110,7 @@ public class TokenSearch {
 
                 final Map<@NonNull String, String> properties = thing.getProperties();
                 final String vendor = properties.get(Thing.PROPERTY_VENDOR);
-                if (StringUtils.isNotEmpty(vendor)) {
+                if (vendor != null && !vendor.isEmpty()) {
                     score += search(vendor, needles);
                 }
 
index b74ab6cf7d862d224920db653f3fc7b0df649f12..4a5e7786eaea06d464018dab0a68dbf938dbd7dc 100644 (file)
@@ -36,12 +36,8 @@ import com.google.gson.JsonSerializer;
 public class ChannelUIDSerializer implements JsonSerializer<ChannelUID>, JsonDeserializer<ChannelUID> {
 
     @Override
-    public ChannelUID deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(context, "context cannot be null");
-
+    public @Nullable ChannelUID deserialize(JsonElement elm, Type type, JsonDeserializationContext context)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("Not a valid ChannelUID: (null)");
         }
index 24ba2ac4d217fc6c551eb17a53335589b429478c..5e9ce1371ef3eb09edf6d7d6dada09d7a9f393db 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -36,12 +35,8 @@ import com.google.gson.JsonSerializer;
 @NonNullByDefault
 public class ItemSubTypeSerializer implements JsonSerializer<ItemSubType>, JsonDeserializer<ItemSubType> {
     @Override
-    public ItemSubType deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable ItemSubType deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("ItemSubType could not be parsed from null");
         }
@@ -50,11 +45,7 @@ public class ItemSubTypeSerializer implements JsonSerializer<ItemSubType>, JsonD
     }
 
     @Override
-    public JsonElement serialize(ItemSubType ist, @Nullable Type type, @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(ist, "ist cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(ItemSubType ist, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(ist.toString());
     }
 }
index df461e85c247d7861cfd140e0f706fc8f808c644..a70636d3ee7d4004380e6f6099e99b002e87663d 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -36,12 +35,8 @@ import com.google.gson.JsonSerializer;
 @NonNullByDefault
 public class ListUiActionSerializer implements JsonSerializer<ListUiAction>, JsonDeserializer<ListUiAction> {
     @Override
-    public ListUiAction deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable ListUiAction deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("ListUiAction could not be parsed from null");
         }
@@ -50,12 +45,7 @@ public class ListUiActionSerializer implements JsonSerializer<ListUiAction>, Jso
     }
 
     @Override
-    public JsonElement serialize(ListUiAction ist, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(ist, "ist cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(ListUiAction ist, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(ist.toString());
     }
 }
index 5809b62140e4295f5e6963519b8a77a5ccff5df1..b45491f8ebf3c089ad41ec042515e2b2d7abfe13 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.io.neeo.internal.serialization;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -54,12 +53,7 @@ public class NeeoBrainDeviceSerializer implements JsonSerializer<NeeoDevice> {
     private final Logger logger = LoggerFactory.getLogger(NeeoBrainDeviceSerializer.class);
 
     @Override
-    public JsonElement serialize(NeeoDevice device, @Nullable Type deviceType,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(device, "device cannot be null");
-        Objects.requireNonNull(deviceType, "deviceType cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoDevice device, Type deviceType, JsonSerializationContext jsonContext) {
         final JsonObject jsonObject = new JsonObject();
 
         final String adapterName = device.getUid().getNeeoUID();
index 8cd213909afdf9afe2eeff84b71ee1d037f1c007..68550692c4c977148cb5393fc5b3b6e41bdf9a3a 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -37,12 +36,8 @@ import com.google.gson.JsonSerializer;
 public class NeeoCapabilityTypeSerializer
         implements JsonSerializer<NeeoCapabilityType>, JsonDeserializer<NeeoCapabilityType> {
     @Override
-    public NeeoCapabilityType deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable NeeoCapabilityType deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("NeeoCapabilityType could not be parsed from null");
         }
@@ -51,12 +46,7 @@ public class NeeoCapabilityTypeSerializer
     }
 
     @Override
-    public JsonElement serialize(NeeoCapabilityType nct, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(nct, "nct cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoCapabilityType nct, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(nct.toString());
     }
 }
index fd3e6e91b16d129a39091fe1eab9665f5fb7800e..db708aef6c446e15941b86b07041333287149e6d 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -37,12 +36,8 @@ import com.google.gson.JsonSerializer;
 public class NeeoDeviceChannelKindSerializer
         implements JsonSerializer<NeeoDeviceChannelKind>, JsonDeserializer<NeeoDeviceChannelKind> {
     @Override
-    public NeeoDeviceChannelKind deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable NeeoDeviceChannelKind deserialize(JsonElement elm, Type type,
+            JsonDeserializationContext jsonContext) throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("NeeoDeviceChannelKind could not be parsed from null");
         }
@@ -51,12 +46,7 @@ public class NeeoDeviceChannelKindSerializer
     }
 
     @Override
-    public JsonElement serialize(NeeoDeviceChannelKind ndck, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(ndck, "ndck cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoDeviceChannelKind ndck, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(ndck.toString());
     }
 }
index 2e8e418be07a50d8f40bde1c0c209a675ace53b4..8de0201f8d17d247e46c1498d2471a3c19cc1916 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.io.neeo.internal.serialization;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -77,12 +76,7 @@ public class NeeoDeviceChannelSerializer
     }
 
     @Override
-    public JsonElement serialize(NeeoDeviceChannel chnl, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(chnl, "chnl cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoDeviceChannel chnl, Type type, JsonSerializationContext jsonContext) {
         final JsonObject jo = new JsonObject();
 
         jo.add("kind", jsonContext.serialize(chnl.getKind()));
@@ -169,12 +163,8 @@ public class NeeoDeviceChannelSerializer
     }
 
     @Override
-    public NeeoDeviceChannel deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext context) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(context, "context cannot be null");
-
+    public @Nullable NeeoDeviceChannel deserialize(JsonElement elm, Type type, JsonDeserializationContext context)
+            throws JsonParseException {
         if (!(elm instanceof JsonObject)) {
             throw new JsonParseException("Element not an instance of JsonObject: " + elm);
         }
index 3d3b500ecb404c200f012fb09dcce51eaf71673c..2cb0878d27e8e38f1896b9e500676adb2eb11bca 100644 (file)
@@ -84,12 +84,8 @@ public class NeeoDeviceSerializer implements JsonSerializer<NeeoDevice>, JsonDes
     }
 
     @Override
-    public NeeoDevice deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable NeeoDevice deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (!(elm instanceof JsonObject)) {
             throw new JsonParseException("Element not an instance of JsonObject: " + elm);
         }
index de404190077a26535fabdab33959543b9106040a..3cfc2645a8f47306b12f67f1c4bddbd4c2a32342 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -37,12 +36,8 @@ import com.google.gson.JsonSerializer;
 public class NeeoDeviceTypeSerializer implements JsonSerializer<NeeoDeviceType>, JsonDeserializer<NeeoDeviceType> {
 
     @Override
-    public NeeoDeviceType deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable NeeoDeviceType deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("NeeoDeviceType could not be parsed from null");
         }
@@ -51,12 +46,7 @@ public class NeeoDeviceTypeSerializer implements JsonSerializer<NeeoDeviceType>,
     }
 
     @Override
-    public JsonElement serialize(NeeoDeviceType ndt, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(ndt, "ndt cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoDeviceType ndt, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(ndt.toString());
     }
 }
index 65317374d86e3d7a48beef7cd39d14b6f3bb8cd8..bfeb0e1e994bfe90f48ac83b86c3b579b9300c51 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.io.neeo.internal.serialization;
 
 import java.lang.reflect.Type;
-import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -36,12 +35,8 @@ import com.google.gson.JsonSerializer;
 public class NeeoThingUIDSerializer implements JsonSerializer<NeeoThingUID>, JsonDeserializer<NeeoThingUID> {
 
     @Override
-    public NeeoThingUID deserialize(@Nullable JsonElement elm, @Nullable Type type,
-            @Nullable JsonDeserializationContext jsonContext) throws JsonParseException {
-        Objects.requireNonNull(elm, "elm cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public @Nullable NeeoThingUID deserialize(JsonElement elm, Type type, JsonDeserializationContext jsonContext)
+            throws JsonParseException {
         if (elm.isJsonNull()) {
             throw new JsonParseException("Not a valid ChannelUID: (null)");
         }
@@ -54,12 +49,7 @@ public class NeeoThingUIDSerializer implements JsonSerializer<NeeoThingUID>, Jso
     }
 
     @Override
-    public JsonElement serialize(NeeoThingUID uid, @Nullable Type type,
-            @Nullable JsonSerializationContext jsonContext) {
-        Objects.requireNonNull(uid, "uid cannot be null");
-        Objects.requireNonNull(type, "type cannot be null");
-        Objects.requireNonNull(jsonContext, "jsonContext cannot be null");
-
+    public JsonElement serialize(NeeoThingUID uid, Type type, JsonSerializationContext jsonContext) {
         return new JsonPrimitive(uid.getAsString());
     }
 }
index cead06f6c6eaf2cde5bf05e1abb8d362e021100a..83c3b0a6f234819b15d35c759b9e7aad27e1b91d 100644 (file)
@@ -96,33 +96,40 @@ public class BrainDashboardService extends DefaultServletService {
                 NeeoUtil.write(resp, gson.toJson(status));
             } else if (StringUtils.equalsIgnoreCase(paths[0], "blinkled")) {
                 final String brainId = req.getParameter("brainid");
-                final NeeoBrainServlet servlet = service.getServlet(brainId);
-                if (servlet == null) {
-                    NeeoUtil.write(resp, gson.toJson(new ReturnStatus("Unknown BraidID: " + brainId)));
+                if (brainId == null) {
+                    NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
                 } else {
-                    try {
-                        servlet.getBrainApi().blinkLed();
-                        NeeoUtil.write(resp, gson.toJson(new ReturnStatus(true)));
-                    } catch (IOException e) {
-                        NeeoUtil.write(resp,
-                                gson.toJson(new ReturnStatus("Exception occurred blinking LED: " + e.getMessage())));
+                    final NeeoBrainServlet servlet = service.getServlet(brainId);
+                    if (servlet == null) {
+                        NeeoUtil.write(resp, gson.toJson(new ReturnStatus("Unknown BrainID: " + brainId)));
+                    } else {
+                        try {
+                            servlet.getBrainApi().blinkLed();
+                            NeeoUtil.write(resp, gson.toJson(new ReturnStatus(true)));
+                        } catch (IOException e) {
+                            NeeoUtil.write(resp, gson
+                                    .toJson(new ReturnStatus("Exception occurred blinking LED: " + e.getMessage())));
+                        }
                     }
                 }
             } else if (StringUtils.equalsIgnoreCase(paths[0], "getlog")) {
                 final String brainId = req.getParameter("brainid");
-                final NeeoBrainServlet servlet = service.getServlet(brainId);
-                if (servlet == null) {
-                    NeeoUtil.write(resp, gson.toJson(new ReturnStatus("Unknown BraidID: " + brainId)));
+                if (brainId == null) {
+                    NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
                 } else {
-                    try {
-                        final String log = servlet.getBrainApi().getLog();
-                        NeeoUtil.write(resp, gson.toJson(new ReturnStatus(true, log)));
-                    } catch (IOException e) {
-                        NeeoUtil.write(resp,
-                                gson.toJson(new ReturnStatus("Exception occurred getting log: " + e.getMessage())));
+                    final NeeoBrainServlet servlet = service.getServlet(brainId);
+                    if (servlet == null) {
+                        NeeoUtil.write(resp, gson.toJson(new ReturnStatus("Unknown BraidID: " + brainId)));
+                    } else {
+                        try {
+                            final String log = servlet.getBrainApi().getLog();
+                            NeeoUtil.write(resp, gson.toJson(new ReturnStatus(true, log)));
+                        } catch (IOException e) {
+                            NeeoUtil.write(resp,
+                                    gson.toJson(new ReturnStatus("Exception occurred getting log: " + e.getMessage())));
+                        }
                     }
                 }
-
             } else {
                 logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
             }
index ca4e26b336142d88b98e22c127d450cba5c71a67..ec288f026c30e777a640d73b95039edc8abaacac 100644 (file)
@@ -109,7 +109,10 @@ public class NeeoBrainSearchService extends DefaultServletService {
         final String path = StringUtils.lowerCase(paths[1]);
 
         if (StringUtils.equalsIgnoreCase(path, "search")) {
-            doSearch(req.getQueryString(), resp);
+            String queryString = req.getQueryString();
+            if (queryString != null) {
+                doSearch(queryString, resp);
+            }
         } else if (StringUtils.equalsIgnoreCase(path, "adapterdefinition") && paths.length >= 3) {
             doAdapterDefinition(paths[2], resp);
         } else {
index 97ee8f0f4b2b01b2a437bde6a55666226fe05775..f6d5dc4bf98d68cfed671a9beccbd85810d5970d 100644 (file)
@@ -422,7 +422,7 @@ public class DynamoDBPersistenceService extends AbstractBufferedPersistenceServi
             String tableName = tableNameResolver.fromItem(dynamoItem);
             Deque<DynamoDBItem<?>> batch = batchesByTable.computeIfAbsent(tableName, new Function<>() {
                 @Override
-                public Deque<DynamoDBItem<?>> apply(@Nullable String t) {
+                public @Nullable Deque<DynamoDBItem<?>> apply(@Nullable String t) {
                     return new ArrayDeque<>();
                 }
             });
index 6900a981c4970702634e1aad2f01dfbfb1efd418..b22c45d198aa618902542281c126d91eb23b6883 100644 (file)
@@ -19,6 +19,7 @@ import java.math.BigDecimal;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.util.Objects;
 import java.util.TimeZone;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -73,6 +74,8 @@ public class AbstractDynamoDBItemSerializationTest {
         assertEquals("item1", dbItem.getName());
         assertEquals(date, dbItem.getTime());
         Object actualState = dbItem.getState();
+        assertNotNull(actualState);
+        Objects.requireNonNull(actualState);
         if (expectedState instanceof BigDecimal) {
             BigDecimal expectedRounded = DynamoDBBigDecimalItem.loseDigits(((BigDecimal) expectedState));
             assertEquals(0, expectedRounded.compareTo((BigDecimal) actualState),
index bf195dfde05525a5547475b3faaf0b8aec53734f..af59fb40dd8eed0dd22f64bd5dcd0247759f7078 100644 (file)
@@ -17,6 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -75,7 +76,7 @@ public class StateTypeAdapterTest {
     @MethodSource
     public void readWriteRoundtripShouldRecreateTheWrittenState(State state) {
         String json = mapper.toJson(state);
-        State actual = mapper.fromJson(json, State.class);
+        State actual = Objects.requireNonNull(mapper.fromJson(json, State.class));
         assertThat(actual, is(equalTo(state)));
     }
 
index 8269e7e3585a60c804c056734c4b4762979a3244..1eb7529c64da81638a26b6eb6928b5ad7bcdbd70 100644 (file)
@@ -17,10 +17,7 @@ import java.awt.Font;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
+import java.util.*;
 
 import javax.imageio.ImageIO;
 import javax.servlet.Servlet;
@@ -126,12 +123,12 @@ public class RRD4jChartServlet implements Servlet, ChartProvider {
 
         int width = 480;
         try {
-            width = Integer.parseInt(req.getParameter("w"));
+            width = Integer.parseInt(Objects.requireNonNull(req.getParameter("w")));
         } catch (Exception e) {
         }
         int height = 240;
         try {
-            height = Integer.parseInt(req.getParameter("h"));
+            height = Integer.parseInt(Objects.requireNonNull(req.getParameter("h")));
         } catch (Exception e) {
         }
         Long period = PERIODS.get(req.getParameter("period"));
index 678876f3984f6aed38c5c0080f200e47b0c9e93e..44ae4c02d5c7efcfae18ee2b6ff527140d2ab467 100644 (file)
     <dependency>
       <groupId>org.lastnpe.eea</groupId>
       <artifactId>eea-all</artifactId>
-      <version>2.1.0</version>
+      <version>${eea.version}</version>
     </dependency>
     <!-- openHAB core -->
     <dependency>
                 <artifactItem>
                   <groupId>org.lastnpe.eea</groupId>
                   <artifactId>eea-all</artifactId>
-                  <version>2.1.0</version>
+                  <version>${eea.version}</version>
                   <overWrite>true</overWrite>
                 </artifactItem>
               </artifactItems>
index 2b9397f0d291e29da38ec66ee8645380bcadd24a..706b9f44e4fee1a1f0586fa770f40b92d2b7ba40 100644 (file)
@@ -20,11 +20,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal.*;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
 import java.util.concurrent.ScheduledFuture;
 import java.util.function.Consumer;
@@ -207,6 +203,7 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
                 assertThat(String.format("Could not determine correct item type for %s", channelId), item,
                         is(notNullValue()));
                 assertNotNull(item);
+                Objects.requireNonNull(item);
                 addItem(item);
                 toBeLinked.put(itemName, channelUID);
             }
index 5930e170f18366f0eae3bb48608b7baeb7b64dc0..f079200a89f10f989e60e5445048347e80528913 100644 (file)
@@ -91,7 +91,7 @@
                 <artifactItem>
                   <groupId>org.lastnpe.eea</groupId>
                   <artifactId>eea-all</artifactId>
-                  <version>2.1.0</version>
+                  <version>${eea.version}</version>
                   <overWrite>true</overWrite>
                 </artifactItem>
               </artifactItems>
diff --git a/pom.xml b/pom.xml
index 6cdc99711a1f590bbc4be615ad2cd70df78f2a01..48e68d21f9b555de2550e454e19f6e4440ece29b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,7 @@
 
     <feature.directory>src/main/feature/feature.xml</feature.directory>
     <spotless.version>2.0.3</spotless.version>
+    <eea.version>2.2.1</eea.version>
   </properties>
 
   <dependencyManagement>
@@ -289,8 +290,8 @@ Import-Package: \\
               <classpath>${project.build.directory}/dependency</classpath>
             </compilerArguments>
             <compilerArgs>
-              <arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,-nullUncheckedConversion</arg>
-              <arg>-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference</arg>
+              <arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion</arg>
+              <arg>-warn:+null,+inheritNullAnnot,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference</arg>
             </compilerArgs>
             <showWarnings>true</showWarnings>
             <showDeprecation>true</showDeprecation>