]> git.basschouten.com Git - openhab-addons.git/commitdiff
Rework more commons-lang usages (#10314)
authorWouter Born <github@maindrain.net>
Tue, 16 Mar 2021 11:38:16 +0000 (12:38 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Mar 2021 11:38:16 +0000 (12:38 +0100)
* Reworks many commons-lang usages to use standard Java
* Updates all remaining commons.lang imports to commons.lang3

Related to openhab/openhab-addons#7722

Signed-off-by: Wouter Born <github@maindrain.net>
257 files changed:
bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherBridgeHandler.java
bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherEventListener.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/handler/AstroThingHandler.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/job/Job.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/util/DateTimeUtils.java
bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/handler/AutelisHandler.java
bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/BigAssFanConfig.java
bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java
bundles/org.openhab.binding.bluetooth.am43/src/main/java/org/openhab/binding/bluetooth/am43/internal/command/AM43Command.java
bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/BeaconBluetoothHandler.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/TestUtils.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryServiceTest.java
bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/ContentItem.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/api/BsbLanApiCaller.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/handler/BsbLanBridgeHandler.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/helper/BsbLanParameterConverter.java
bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/BuienradarHandler.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/DenonMarantzState.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/http/DenonMarantzHttpConnector.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/telnet/DenonMarantzTelnetClientThread.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/telnet/DenonMarantzTelnetConnector.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/xml/adapters/StringAdapter.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/DigitalSTROMHandlerFactory.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/DeviceDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/ZoneTemperatureControlDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/BridgeHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/CircuitHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/ConnectionManagerImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/DsAPIImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/HttpTransportImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/simpledsrequestbuilder/SimpleRequestBuilder.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/impl/DeviceImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/scene/InternalScene.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/providers/BaseDsI18n.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/api/EcobeeApi.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/api/EcobeeAuth.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeSensorThingHandler.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeThermostatBridgeHandler.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/SerialConnection.java
bundles/org.openhab.binding.enigma2/src/main/java/org/openhab/binding/enigma2/internal/Enigma2Client.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.java
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/EnturNoHandler.java
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/connection/EnturNoConnection.java
bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/BaseEvohomeHandler.java
bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java
bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/handler/ExecHandler.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotApiConnector.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotDeviceHandler.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusMeterHandler.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusSymoInverterHandler.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/handler/FSInternetRadioHandler.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/FSInternetRadioHandlerJavaTest.java
bundles/org.openhab.binding.ftpupload/src/main/java/org/openhab/binding/ftpupload/internal/FtpUploadHandlerFactory.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java
bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerHandler.java
bundles/org.openhab.binding.harmonyhub/src/main/java/org/openhab/binding/harmonyhub/internal/handler/HarmonyHubHandler.java
bundles/org.openhab.binding.hdanywhere/src/main/java/org/openhab/binding/hdanywhere/internal/handler/Mhub4K431Handler.java
bundles/org.openhab.binding.hdanywhere/src/main/java/org/openhab/binding/hdanywhere/internal/handler/MultiroomPlusHandler.java
bundles/org.openhab.binding.heos/src/main/java/org/openhab/binding/heos/internal/handler/HeosThingBaseHandler.java
bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseHandler.java
bundles/org.openhab.binding.iaqualink/src/main/java/org/openhab/binding/iaqualink/internal/handler/IAqualinkHandler.java
bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ChannelUtils.java
bundles/org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal/ws/services/IhcResourceInteractionService.java
bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/client/InnogyClient.java
bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/handler/InnogyBridgeHandler.java
bundles/org.openhab.binding.irtrans/src/main/java/org/openhab/binding/irtrans/internal/handler/BlasterHandler.java
bundles/org.openhab.binding.irtrans/src/main/java/org/openhab/binding/irtrans/internal/handler/EthernetBridgeHandler.java
bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/lacrosse/LaCrosseTemperatureSensorHandler.java
bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/lacrosse/LgwSensorHandler.java
bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/communication/KaleidescapeFormatter.java
bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/KebaBindingConstants.java
bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactHandler.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Cryption.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Device.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/handler/KM200GatewayHandler.java
bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeHandler.java
bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/config/IPBridgeConfig.java
bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/IPBridgeHandler.java
bundles/org.openhab.binding.max/src/main/java/org/openhab/binding/max/internal/command/MCommand.java
bundles/org.openhab.binding.max/src/main/java/org/openhab/binding/max/internal/command/TCommand.java
bundles/org.openhab.binding.max/src/main/java/org/openhab/binding/max/internal/message/CMessage.java
bundles/org.openhab.binding.meteoblue/src/main/java/org/openhab/binding/meteoblue/internal/MeteoBlueConfiguration.java
bundles/org.openhab.binding.meteoblue/src/main/java/org/openhab/binding/meteoblue/internal/handler/MeteoBlueBridgeHandler.java
bundles/org.openhab.binding.meteoblue/src/main/java/org/openhab/binding/meteoblue/internal/handler/MeteoBlueHandler.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/discovery/MieleApplianceDiscoveryService.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/MieleApplianceHandler.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/MieleBridgeHandler.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/WashingMachineChannelSelector.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/ChannelState.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/internal/handler/GenericMQTTThingHandler.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/TextValue.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/ValueFactory.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/generic/internal/MqttThingHandlerFactory.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/CChannel.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/ChannelConfigurationTypeAdapterFactory.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/ComponentLock.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/ComponentSensor.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/ComponentSwitch.java
bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/HaID.java
bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java
bundles/org.openhab.binding.neato/src/main/java/org/openhab/binding/neato/internal/handler/NeatoHandler.java
bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/utils/NetworkUtils.java
bundles/org.openhab.binding.nibeheatpump/src/main/java/org/openhab/binding/nibeheatpump/internal/protocol/NibeHeatPumpProtocol.java
bundles/org.openhab.binding.nibeuplink/src/main/java/org/openhab/binding/nibeuplink/internal/config/NibeUplinkConfiguration.java
bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/NetworkOceanicThingHandler.java
bundles/org.openhab.binding.oceanic/src/main/java/org/openhab/binding/oceanic/internal/handler/SerialOceanicThingHandler.java
bundles/org.openhab.binding.omnikinverter/src/main/java/org/openhab/binding/omnikinverter/internal/OmnikInverter.java
bundles/org.openhab.binding.onebusaway/src/main/java/org/openhab/binding/onebusaway/internal/config/ApiConfiguration.java
bundles/org.openhab.binding.onebusaway/src/main/java/org/openhab/binding/onebusaway/internal/config/ChannelConfig.java
bundles/org.openhab.binding.onebusaway/src/main/java/org/openhab/binding/onebusaway/internal/config/RouteConfiguration.java
bundles/org.openhab.binding.onebusaway/src/main/java/org/openhab/binding/onebusaway/internal/config/StopConfiguration.java
bundles/org.openhab.binding.onewiregpio/src/main/java/org/openhab/binding/onewiregpio/internal/handler/OneWireGPIOHandler.java
bundles/org.openhab.binding.onkyo/src/main/java/org/openhab/binding/onkyo/internal/discovery/OnkyoUpnpDiscoveryParticipant.java
bundles/org.openhab.binding.orvibo/src/main/java/org/openhab/binding/orvibo/internal/discovery/SocketDiscoveryService.java
bundles/org.openhab.binding.orvibo/src/main/java/org/openhab/binding/orvibo/internal/handler/S20Handler.java
bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/config/PentairIPBridgeConfig.java
bundles/org.openhab.binding.pentair/src/main/java/org/openhab/binding/pentair/internal/config/PentairSerialBridgeConfig.java
bundles/org.openhab.binding.phc/src/main/java/org/openhab/binding/phc/internal/PHCHelper.java
bundles/org.openhab.binding.phc/src/main/java/org/openhab/binding/phc/internal/handler/PHCBridgeHandler.java
bundles/org.openhab.binding.pioneeravr/src/main/java/org/openhab/binding/pioneeravr/internal/discovery/PioneerAvrDiscoveryParticipant.java
bundles/org.openhab.binding.pioneeravr/src/main/java/org/openhab/binding/pioneeravr/internal/protocol/ParameterizedCommand.java
bundles/org.openhab.binding.pioneeravr/src/main/java/org/openhab/binding/pioneeravr/internal/protocol/Response.java
bundles/org.openhab.binding.pioneeravr/src/main/java/org/openhab/binding/pioneeravr/internal/protocol/avr/AvrResponse.java
bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/PlugwiseMessageProcessor.java
bundles/org.openhab.binding.plugwise/src/main/java/org/openhab/binding/plugwise/internal/PlugwiseUtils.java
bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/PulseaudioClient.java
bundles/org.openhab.binding.pulseaudio/src/main/java/org/openhab/binding/pulseaudio/internal/handler/PulseaudioHandler.java
bundles/org.openhab.binding.rme/src/main/java/org/openhab/binding/rme/internal/handler/RMEThingHandler.java
bundles/org.openhab.binding.robonect/src/main/java/org/openhab/binding/robonect/internal/RobonectClient.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/discovery/RioSystemDeviceDiscoveryService.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/discovery/RioSystemDiscovery.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractBridgeHandler.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractRioHandlerCallback.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/RioPresetsProtocol.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/RioSystemFavoritesProtocol.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/StatefulHandlerCallback.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/controller/RioControllerProtocol.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/models/RioBank.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/models/RioFavorite.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/models/RioPreset.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/source/RioSourceHandler.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/source/RioSourceProtocol.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/system/RioSystemProtocol.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/zone/RioZoneHandler.java
bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/zone/RioZoneProtocol.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/command/ControlCommand.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/config/Ethm1Config.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/config/IntRSConfig.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/Ethm1BridgeHandler.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/IntRSBridgeHandler.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelBridgeHandler.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/handler/SatelStateThingHandler.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/Ethm1Module.java
bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/util/StringUtils.java [deleted file]
bundles/org.openhab.binding.satel/src/test/java/org/openhab/binding/satel/internal/util/StringUtilsTest.java [deleted file]
bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/handler/SensiboSkyHandler.java
bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/model/SensiboModel.java
bundles/org.openhab.binding.sensibo/src/main/java/org/openhab/binding/sensibo/internal/model/SensiboSky.java
bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/config/SleepIQCloudConfiguration.java
bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQCloudHandler.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/helper/SerialParameter.java
bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/config/SolarEdgeConfiguration.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosEntry.java
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java
bundles/org.openhab.binding.sonyaudio/src/main/java/org/openhab/binding/sonyaudio/internal/discovery/SonyAudioDiscoveryParticipant.java
bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/SqueezeBoxAudioSink.java
bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/config/SqueezeBoxServerConfig.java
bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxPlayerHandler.java
bundles/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/handler/SqueezeBoxServerHandler.java
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiClientThingConfig.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiControllerThingConfig.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiCache.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/model/UniFiClient.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/model/UniFiController.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/model/UniFiDevice.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/model/UniFiSite.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/util/UniFiTidyLowerCaseStringDeserializer.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/queue/UpnpEntry.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/UpnpXMLParser.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java
bundles/org.openhab.binding.weathercompany/src/main/java/org/openhab/binding/weathercompany/internal/handler/WeatherCompanyBridgeHandler.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.wemo/src/main/java/org/openhab/binding/wemo/internal/discovery/WemoLinkDiscoveryService.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoCoffeeHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoCrockpotHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHolmesHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoLightHandler.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoMakerHandler.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/config/YamahaBridgeConfig.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/DeviceDescriptorXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/DeviceInformationXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputConverterXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithPlayControlXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithPresetControlXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/InputWithTunerDABControlXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/XMLConnection.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/ZoneControlXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/state/NavigationControlState.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayBridgeHandler.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZAutomationDeviceHandler.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/action/SetModeAction.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/action/StopShutterAction.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/ElectricityDevice.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RainDevice.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/RgbLightDevice.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/TrippableDevice.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device/WindDevice.java
bundles/org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/processor/ItemProcessor.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/NeeoService.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/AbstractServlet.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/NeeoDeviceDefinitions.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/NeeoDeviceKeys.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/NeeoItemValueConverter.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/ServiceContext.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/discovery/MdnsBrainDiscovery.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/ItemSubType.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/ListUiAction.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoButtonGroup.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoCapabilityType.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoDevice.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoDeviceChannelKind.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoDeviceChannelRange.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoDeviceType.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoDirectoryResultItem.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoNotification.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoSensorNotification.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoSystemInfo.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/models/NeeoThingUID.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/NeeoDeviceChannelSerializer.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.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/NeeoBrainService.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/ThingDashboardService.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/models/PathInfo.java
bundles/org.openhab.io.neeo/src/main/java/org/openhab/io/neeo/internal/servletservices/models/ReturnStatus.java
itests/org.openhab.binding.astro.tests/itest.bndrun
itests/org.openhab.binding.max.tests/itest.bndrun
itests/org.openhab.binding.ntp.tests/itest.bndrun
itests/org.openhab.binding.ntp.tests/src/main/java/org/openhab/binding/ntp/test/NtpOSGiTest.java
itests/org.openhab.binding.systeminfo.tests/itest.bndrun
itests/org.openhab.binding.wemo.tests/itest.bndrun

index 8461a3f95328a83bc64056610586eb90f10f1f91..1c86211334d2297b33bac9f24ba0a85be2499c95 100644 (file)
@@ -18,7 +18,6 @@ import java.io.IOException;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.ambientweather.internal.config.BridgeConfig;
@@ -128,7 +127,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
      */
     private boolean hasApplicationKey() {
         String configApplicationKey = getConfigAs(BridgeConfig.class).applicationKey;
-        if (StringUtils.isEmpty(configApplicationKey)) {
+        if (configApplicationKey == null || configApplicationKey.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing application key");
             return false;
         }
@@ -141,7 +140,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
      */
     private boolean hasApiKey() {
         String configApiKey = getConfigAs(BridgeConfig.class).apiKey;
-        if (StringUtils.isEmpty(configApiKey)) {
+        if (configApiKey == null || configApiKey.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing API key");
             return false;
         }
index 27ceb2be23f6148467b479e2ff220490f4714974..39d54463ba9096fe9aeaf7d89cd76dbe055fdf73 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Arrays;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.StringUtils;
 import org.json.JSONObject;
 import org.openhab.binding.ambientweather.internal.model.DeviceJson;
 import org.openhab.binding.ambientweather.internal.model.EventDataGenericJson;
@@ -318,8 +317,9 @@ public class AmbientWeatherEventListener {
         logger.debug("Listener: Data: {}", jsonData);
         try {
             EventDataGenericJson data = gson.fromJson(jsonData, EventDataGenericJson.class);
-            if (StringUtils.isNotEmpty(data.macAddress)) {
-                sendWeatherDataToHandler(data.macAddress, jsonData);
+            String macAddress = data == null ? null : data.macAddress;
+            if (macAddress != null && !macAddress.isEmpty()) {
+                sendWeatherDataToHandler(macAddress, jsonData);
             }
         } catch (JsonSyntaxException e) {
             logger.info("Listener: Exception parsing subscribed event: {}", e.getMessage());
index ad27bdb7f13c96457c022cd00626c9a1f21b65b1..2e06df173cfc26e8e15dcf9269d24098c67a61f4 100644 (file)
@@ -34,7 +34,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import javax.measure.quantity.Angle;
 
-import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.astro.internal.action.AstroActions;
index 1ace958cb7da3d551aa06444352c25083915661e..b4a5b8ee8ba7e79319b4899513f2ddf282d4713f 100644 (file)
@@ -16,7 +16,7 @@ import static java.util.Arrays.asList;
 import static java.util.Calendar.SECOND;
 import static java.util.Collections.singletonList;
 import static java.util.stream.Collectors.toList;
-import static org.apache.commons.lang.time.DateUtils.truncatedEquals;
+import static org.apache.commons.lang3.time.DateUtils.truncatedEquals;
 import static org.openhab.binding.astro.internal.AstroBindingConstants.*;
 import static org.openhab.binding.astro.internal.util.DateTimeUtils.*;
 
index 140e8c154971d0810aad56fb59a7de1566ce7b13..6e18febb2c5d46d1f08d3443a77caea619e3c8ad 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.lang3.time.DateUtils;
 import org.openhab.binding.astro.internal.config.AstroChannelConfig;
 import org.openhab.binding.astro.internal.model.Range;
 import org.slf4j.Logger;
index 30e37717fa98313b07560e678601caff582f8068..b80a02c66ebeab2fedc0ba2b5b37059c584b80ce 100644 (file)
@@ -25,7 +25,6 @@ import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
@@ -288,17 +287,17 @@ public class AutelisHandler extends BaseThingHandler {
         String username = configuration.user;
         String password = configuration.password;
 
-        if (StringUtils.isBlank(username)) {
+        if (username == null || username.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "username must not be empty");
             return;
         }
 
-        if (StringUtils.isBlank(password)) {
+        if (password == null || password.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "password must not be empty");
             return;
         }
 
-        if (StringUtils.isBlank(host)) {
+        if (host == null || host.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "hostname must not be empty");
             return;
         }
@@ -443,7 +442,7 @@ public class AutelisHandler extends BaseThingHandler {
                     }
                 }
 
-                if (StringUtils.isEmpty((value))) {
+                if (value == null || value.isEmpty()) {
                     continue;
                 }
 
index 647572c2880396f5f06abdfdf789bcf3306cca99..74b1dc7a7046559ea5007ce9d17a07b84da9ad5e 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.bigassfan.internal;
 
-import org.apache.commons.lang.StringUtils;
-
 /**
  * The {@link BigAssFanConfig} is responsible for storing the BigAssFan thing configuration.
  *
@@ -60,13 +58,13 @@ public class BigAssFanConfig {
     }
 
     public boolean isValid() {
-        if (StringUtils.isBlank(label)) {
+        if (label == null || label.isBlank()) {
             return false;
         }
-        if (StringUtils.isBlank(ipAddress)) {
+        if (ipAddress == null || ipAddress.isBlank()) {
             return false;
         }
-        if (StringUtils.isBlank(macAddress)) {
+        if (macAddress == null || macAddress.isBlank()) {
             return false;
         }
         return true;
index 4c2bf94b760a415d77873ef322f64526acaa3781..eacc428f217d335f49c49896f4224eb84575429f 100644 (file)
@@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.bigassfan.internal.BigAssFanConfig;
 import org.openhab.binding.bigassfan.internal.utils.BigAssFanConverter;
 import org.openhab.core.common.ThreadPoolManager;
@@ -668,7 +667,7 @@ public class BigAssFanHandler extends BaseThingHandler {
         }
 
         private void processMessage(String incomingMessage) {
-            if (StringUtils.isEmpty(incomingMessage)) {
+            if (incomingMessage == null || incomingMessage.isEmpty()) {
                 return;
             }
 
@@ -742,11 +741,11 @@ public class BigAssFanHandler extends BaseThingHandler {
 
         private boolean isMe(String idFromDevice) {
             // Check match on MAC address
-            if (StringUtils.equalsIgnoreCase(idFromDevice, macAddress)) {
+            if (macAddress.equalsIgnoreCase(idFromDevice)) {
                 return true;
             }
             // Didn't match MAC address, check match for label
-            if (StringUtils.equalsIgnoreCase(idFromDevice, label)) {
+            if (label.equalsIgnoreCase(idFromDevice)) {
                 return true;
             }
             return false;
index 92ce6cc0e2cf7512ea102cda80aea59ac2485a11..1204e11b6fd78c4774ddb58bcffd8f12ffc47573 100644 (file)
@@ -18,7 +18,7 @@ import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
index deb1cce3279a836ab0e106cce349e8b5b460ea60..c1602e52d216ab2a80dcb0892462b1245e74a884 100644 (file)
@@ -19,7 +19,6 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import javax.measure.quantity.Power;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.bluetooth.BluetoothDevice.ConnectionState;
@@ -193,7 +192,7 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot
         if (device != null) {
             BluetoothAdapter adapter = device.getAdapter();
             String location = adapter.getLocation();
-            if (location != null || StringUtils.isBlank(location)) {
+            if (location != null && !location.isBlank()) {
                 updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, new StringType(location));
             } else {
                 updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, UnDefType.NULL);
index fc2bbd8fc581846c00e22f92fa6b08b27fb63edd..c87ebec3a678820e18e34a92a9737650fe93ed82 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.bluetooth;
 
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingUID;
 
index 141146d4911d89fa9a589c640d4d99ae97481e97..b05b6e4e46eca2967de7d5b94078066041eb7e44 100644 (file)
@@ -23,7 +23,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.BiConsumer;
 
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
index d119580182331e872f468dcad4d597f76c8ee5d0..84c5a40e355f4ef81c4c16ea5350429ceea0f71c 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.bosesoundtouch.internal;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.openhab.core.types.StateOption;
 
 import com.google.gson.annotations.Expose;
index 62946ffd7a17cfff2b493d283c4b1bbf7c43bea6..50214b06767bc0c6cdd8e321295cf63025e671cf 100644 (file)
  */
 package org.openhab.binding.bsblan.internal.api;
 
-import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
+import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.API_TIMEOUT;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
-import java.util.HashSet;
 import java.util.Set;
+import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiContentDTO;
@@ -50,17 +49,14 @@ public class BsbLanApiCaller {
     }
 
     public @Nullable BsbLanApiParameterQueryResponseDTO queryParameter(Integer parameterId) {
-        Set<Integer> parameters = new HashSet<>();
-
-        parameters.add(parameterId);
-        return queryParameters(parameters);
+        return queryParameters(Set.of(parameterId));
     }
 
     public @Nullable BsbLanApiParameterQueryResponseDTO queryParameters(Set<Integer> parameterIds) {
         // note: make the request even if parameterIds is empty as
         // thing OFFLINE/ONLINE detection relies on a response
-
-        String apiPath = String.format("/JQ=%s", StringUtils.join(parameterIds, ","));
+        String apiPath = String.format("/JQ=%s",
+                parameterIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
         return makeRestCall(BsbLanApiParameterQueryResponseDTO.class, "GET", apiPath, null);
     }
 
@@ -96,21 +92,21 @@ public class BsbLanApiCaller {
     }
 
     private String createApiBaseUrl() {
-        final String host = StringUtils.trimToEmpty(bridgeConfig.host);
-        final String username = StringUtils.trimToEmpty(bridgeConfig.username);
-        final String password = StringUtils.trimToEmpty(bridgeConfig.password);
-        final String passkey = StringUtils.trimToEmpty(bridgeConfig.passkey);
+        final String host = bridgeConfig.host == null ? "" : bridgeConfig.host.trim();
+        final String username = bridgeConfig.username == null ? "" : bridgeConfig.username.trim();
+        final String password = bridgeConfig.password == null ? "" : bridgeConfig.password.trim();
+        final String passkey = bridgeConfig.passkey == null ? "" : bridgeConfig.passkey.trim();
 
         StringBuilder url = new StringBuilder();
         url.append("http://");
-        if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
+        if (!username.isBlank() && !password.isBlank()) {
             url.append(username).append(":").append(password).append("@");
         }
         url.append(host);
         if (bridgeConfig.port != 80) {
             url.append(":").append(bridgeConfig.port);
         }
-        if (StringUtils.isNotBlank(passkey)) {
+        if (!passkey.isBlank()) {
             url.append("/").append(passkey);
         }
         return url.toString();
@@ -134,7 +130,7 @@ public class BsbLanApiCaller {
             if (request != null) {
                 String content = BsbLanApiContentConverter.toJson(request);
                 logger.trace("api request content: '{}'", content);
-                if (StringUtils.isNotBlank(content)) {
+                if (!content.isBlank()) {
                     contentStream = new ByteArrayInputStream(content.getBytes(Charset.forName("UTF-8")));
                     contentType = "application/json";
                 }
index 0c81607a6f62b958fa4d719243bf7c44dd737657..b07b76f0ea540f074314a9671508cbb1fed97b42 100644 (file)
@@ -18,9 +18,8 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.*;
+import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.bsblan.internal.api.BsbLanApiCaller;
@@ -78,7 +77,8 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
         bridgeConfig = getConfigAs(BsbLanBridgeConfiguration.class);
 
         // validate 'host' configuration
-        if (StringUtils.isBlank(bridgeConfig.host)) {
+        String host = bridgeConfig.host;
+        if (host == null || host.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Parameter 'host' is mandatory and must be configured");
             return;
@@ -128,8 +128,10 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
         BsbLanApiCaller apiCaller = new BsbLanApiCaller(bridgeConfig);
 
         // refresh all parameters
-        Set<Integer> parameterIds = things.stream().filter(thing -> thing instanceof BsbLanParameterHandler)
-                .map(thing -> (BsbLanParameterHandler) thing).map(thing -> thing.getParameterId())
+        Set<Integer> parameterIds = things.stream() //
+                .filter(thing -> thing instanceof BsbLanParameterHandler) //
+                .map(thing -> (BsbLanParameterHandler) thing) //
+                .map(thing -> thing.getParameterId()) //
                 .collect(Collectors.toSet());
 
         cachedParameterQueryResponse = apiCaller.queryParameters(parameterIds);
index a0d285a3e3348ba980cdd16c77979372d540242e..e9d24f19c9e09cb1c75289173f2ba48bb4f10a6b 100644 (file)
@@ -14,10 +14,11 @@ package org.openhab.binding.bsblan.internal.helper;
 
 import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
+import org.openhab.binding.bsblan.internal.handler.BsbLanParameterHandler;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.StringType;
@@ -74,7 +75,7 @@ public class BsbLanParameterConverter {
     }
 
     private static State getStateForUnitChannel(BsbLanApiParameterDTO parameter) {
-        String value = StringEscapeUtils.unescapeHtml(parameter.unit);
+        String value = StringEscapeUtils.unescapeHtml4(parameter.unit);
         return new StringType(value);
     }
 
@@ -110,7 +111,7 @@ public class BsbLanParameterConverter {
 
     /**
      * Converts a Command back to a value which is sent to the BSB-LAN device afterwards.
-     * 
+     *
      * @param channelId
      * @param command
      * @return null if conversion fails or channel is readonly.
index 025e675bc884ee4f97f5515dcab0c3f8079d29a3..8fcca83298b235ea210e345b4fa9474788b45e47 100644 (file)
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI;
 import org.openhab.binding.buienradar.internal.buienradarapi.Prediction;
@@ -81,7 +80,7 @@ public class BuienradarHandler extends BaseThingHandler {
         this.config = getConfigAs(BuienradarConfiguration.class);
 
         boolean configValid = true;
-        if (StringUtils.trimToNull(config.location) == null) {
+        if (config.location == null || config.location.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error-missing-location");
             configValid = false;
index 8a2a4462313eac29014885b14e5208edfd914a9e..9fdfc069b90b03f9a28b68ec0e4c769256065203 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal;
 
 import java.math.BigDecimal;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.PercentType;
@@ -184,7 +183,7 @@ public class DenonMarantzState {
     }
 
     public void setNowPlayingArtist(String artist) {
-        StringType newVal = StringUtils.isBlank(artist) ? StringType.EMPTY : StringType.valueOf(artist);
+        StringType newVal = artist == null || artist.isBlank() ? StringType.EMPTY : StringType.valueOf(artist);
         if (!newVal.equals(this.artist)) {
             this.artist = newVal;
             handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ARTIST, this.artist);
@@ -192,7 +191,7 @@ public class DenonMarantzState {
     }
 
     public void setNowPlayingAlbum(String album) {
-        StringType newVal = StringUtils.isBlank(album) ? StringType.EMPTY : StringType.valueOf(album);
+        StringType newVal = album == null || album.isBlank() ? StringType.EMPTY : StringType.valueOf(album);
         if (!newVal.equals(this.album)) {
             this.album = newVal;
             handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ALBUM, this.album);
@@ -200,7 +199,7 @@ public class DenonMarantzState {
     }
 
     public void setNowPlayingTrack(String track) {
-        StringType newVal = StringUtils.isBlank(track) ? StringType.EMPTY : StringType.valueOf(track);
+        StringType newVal = track == null || track.isBlank() ? StringType.EMPTY : StringType.valueOf(track);
         if (!newVal.equals(this.track)) {
             this.track = newVal;
             handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_TRACK, this.track);
index dbee97969c73e05d0fc2ac1885d7255629d79379..f43745c1dab0e96af6a9dba536d071623d601a8c 100644 (file)
@@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.util.StreamReaderDelegate;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.api.Response;
@@ -169,7 +168,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
     @Override
     protected void internalSendCommand(String command) {
         logger.debug("Sending command '{}'", command);
-        if (StringUtils.isBlank(command)) {
+        if (command == null || command.isBlank()) {
             logger.warn("Trying to send empty command");
             return;
         }
@@ -306,7 +305,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
             String result = HttpUtil.executeUrl("GET", uri, REQUEST_TIMEOUT_MS);
             logger.trace("result of getDocument for uri '{}':\r\n{}", uri, result);
 
-            if (StringUtils.isNotBlank(result)) {
+            if (result != null && !result.isBlank()) {
                 JAXBContext jc = JAXBContext.newInstance(response);
                 XMLInputFactory xif = XMLInputFactory.newInstance();
                 xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
@@ -341,7 +340,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
             ByteArrayInputStream inputStream = new ByteArrayInputStream(sw.toString().getBytes(StandardCharsets.UTF_8));
             String result = HttpUtil.executeUrl("POST", uri, inputStream, CONTENT_TYPE_XML, REQUEST_TIMEOUT_MS);
 
-            if (StringUtils.isNotBlank(result)) {
+            if (result != null && !result.isBlank()) {
                 JAXBContext jcResponse = JAXBContext.newInstance(response);
 
                 @SuppressWarnings("unchecked")
index 9eee0775b9163547dea267fc911b6257da541fd4..6062c1ea7d59db83365a2178311b4c9b2bd871fd 100644 (file)
@@ -20,7 +20,6 @@ import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,7 +73,7 @@ public class DenonMarantzTelnetClientThread extends Thread {
                         break;
                     }
                     logger.trace("Received from {}: {}", config.getHost(), line);
-                    if (!StringUtils.isBlank(line)) {
+                    if (!line.isBlank()) {
                         listener.receivedLine(line);
                     }
                 } catch (SocketTimeoutException e) {
index da729e4cab85e37a37deb4e6c031d2cc078d9c55..fbdb8d666f9782e6b764469484c60a2af6cbcc93 100644 (file)
@@ -20,7 +20,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.denonmarantz.internal.DenonMarantzState;
 import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
 import org.openhab.binding.denonmarantz.internal.connector.DenonMarantzConnector;
@@ -263,7 +263,7 @@ public class DenonMarantzTelnetConnector extends DenonMarantzConnector implement
     @Override
     protected void internalSendCommand(String command) {
         logger.debug("Sending command '{}'", command);
-        if (StringUtils.isBlank(command)) {
+        if (command == null || command.isBlank()) {
             logger.warn("Trying to send empty command");
             return;
         }
index eb90b60d0dd757fd2e34e7a1973a7db1736cfd33..011e75c56fd2cd536b76d0754ab0a0dfbb0e1c66 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.denonmarantz.internal.xml.adapters;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * Adapter to clean up string values
index 6fa388fe73856043f4892c62a9ea4fdb776b6950..6b4d2dc48cc9be781c3f36feb433bad486ac2637 100644 (file)
@@ -18,7 +18,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.discovery.DiscoveryServiceManager;
 import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
 import org.openhab.binding.digitalstrom.internal.handler.CircuitHandler;
@@ -139,8 +138,9 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
 
     private ThingUID getDeviceUID(ThingTypeUID thingTypeUID, ThingUID thingUID, Configuration configuration,
             ThingUID bridgeUID) {
-        if (thingUID == null && StringUtils.isNotBlank((String) configuration.get(DEVICE_DSID))) {
-            return new ThingUID(thingTypeUID, bridgeUID, configuration.get(DEVICE_DSID).toString());
+        String id = (String) configuration.get(DEVICE_DSID);
+        if (thingUID == null && id != null && !id.isBlank()) {
+            return new ThingUID(thingTypeUID, bridgeUID, id);
         }
         return thingUID;
     }
@@ -208,7 +208,8 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
             return thingUID;
         }
         String dSID;
-        if (StringUtils.isBlank((String) configuration.get(DS_ID))) {
+        String configValue = (String) configuration.get(DS_ID);
+        if (configValue == null || configValue.isBlank()) {
             dSID = getDSSid(configuration);
             if (dSID != null) {
                 configuration.put(DS_ID, dSID);
@@ -225,13 +226,15 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
 
     private String getDSSid(Configuration configuration) {
         String dSID = null;
-        if (StringUtils.isNotBlank((String) configuration.get(HOST))) {
-            String host = configuration.get(HOST).toString();
+        String hostConfigValue = (String) configuration.get(HOST);
+        if (hostConfigValue != null && !hostConfigValue.isBlank()) {
+            String host = hostConfigValue;
             String applicationToken = null;
             String user = null;
             String pw = null;
 
-            if (StringUtils.isNotBlank((String) configuration.get(APPLICATION_TOKEN))) {
+            String atConfigValue = (String) configuration.get(APPLICATION_TOKEN);
+            if (atConfigValue != null && !atConfigValue.isBlank()) {
                 applicationToken = configuration.get(APPLICATION_TOKEN).toString();
             }
 
@@ -249,8 +252,9 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
     }
 
     private boolean checkUserPassword(Configuration configuration) {
-        return StringUtils.isNotBlank((String) configuration.get(USER_NAME))
-                && StringUtils.isNotBlank((String) configuration.get(PASSWORD));
+        String userName = (String) configuration.get(USER_NAME);
+        String password = (String) configuration.get(PASSWORD);
+        return userName != null && !userName.isBlank() && password != null && !password.isBlank();
     }
 
     @Override
index d713dd3d13aa86d785cf1bfbc49d04f54c1d0f10..820dcf12676698f98912c4a95a47c7b08c1c6ddf 100644 (file)
@@ -21,16 +21,17 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.GeneralDeviceInformation;
+import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.OutputModeEnum;
 import org.openhab.binding.digitalstrom.internal.providers.DsDeviceThingTypeProvider;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
+import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
 import org.slf4j.Logger;
@@ -126,10 +127,8 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
             if (thingUID != null) {
                 Map<String, Object> properties = new HashMap<>(1);
                 properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue());
-                String deviceName = null;
-                if (StringUtils.isNotBlank(device.getName())) {
-                    deviceName = device.getName();
-                } else {
+                String deviceName = device.getName();
+                if (deviceName == null || deviceName.isBlank()) {
                     // if no name is set, the dSID will be used as name
                     deviceName = device.getDSID().getValue();
                 }
index 4d52e673e15eb9b1b055fedc126618cf9546e3b9..83c4251fb2a0294c47473fa3532d34b0e2ce4183 100644 (file)
@@ -20,9 +20,9 @@ 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.handler.BridgeHandler;
+import org.openhab.binding.digitalstrom.internal.handler.ZoneTemperatureControlHandler;
 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -103,7 +103,7 @@ public class ZoneTemperatureControlDiscoveryService extends AbstractDiscoverySer
                 Map<String, Object> properties = new HashMap<>();
                 properties.put(DigitalSTROMBindingConstants.ZONE_ID, tempControlStatus.getZoneID());
                 String zoneName = tempControlStatus.getZoneName();
-                if (StringUtils.isBlank(zoneName)) {
+                if (zoneName == null || zoneName.isBlank()) {
                     zoneName = tempControlStatus.getZoneID().toString();
                 }
                 DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
index 22f81a09a885be3727493063ef4b932a4ab7bad8..f13295f339d510a94f757b4a84d1156bbcd9de8a 100644 (file)
@@ -25,7 +25,6 @@ import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@@ -198,9 +197,10 @@ public class BridgeHandler extends BaseBridgeHandler
             if (versions != null) {
                 properties.putAll(versions);
             }
-            if (StringUtils.isBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT))
-                    && StringUtils.isNotBlank(config.getCert())) {
-                properties.put(DigitalSTROMBindingConstants.SERVER_CERT, config.getCert());
+            String certProperty = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
+            String certConfig = config.getCert();
+            if ((certProperty == null || certProperty.isBlank()) && (certConfig != null && !certConfig.isBlank())) {
+                properties.put(DigitalSTROMBindingConstants.SERVER_CERT, certConfig);
             }
             logger.debug("update properties");
             updateProperties(properties);
@@ -235,8 +235,12 @@ public class BridgeHandler extends BaseBridgeHandler
     }
 
     private boolean checkLoginConfig(Config config) {
-        if ((StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword()))
-                || StringUtils.isNotBlank(config.getAppToken())) {
+        String userName = config.getUserName();
+        String password = config.getPassword();
+        String appToken = config.getAppToken();
+
+        if (((userName != null && !userName.isBlank()) && (password != null && !password.isBlank()))
+                || (appToken != null && !appToken.isBlank())) {
             return true;
         }
         onConnectionStateChange(CONNECTION_LOST, NO_USER_PASSWORD);
@@ -296,8 +300,9 @@ public class BridgeHandler extends BaseBridgeHandler
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, excText + " have to be a number.");
             return null;
         }
-        if (StringUtils.isNotBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT))) {
-            config.setCert(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT));
+        String servertCert = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
+        if (servertCert != null && !servertCert.isBlank()) {
+            config.setCert(servertCert);
         }
         return config;
     }
@@ -307,8 +312,9 @@ public class BridgeHandler extends BaseBridgeHandler
             this.config = new Config();
         }
         // load and check connection and authorization data
-        if (StringUtils.isNotBlank((String) thingConfig.get(HOST))) {
-            config.setHost(thingConfig.get(HOST).toString());
+        String host = (String) thingConfig.get(HOST);
+        if (host != null && !host.isBlank()) {
+            config.setHost(host);
         } else {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "The connection to the digitalSTROM-Server can't established, because the host address is missing. Please set the host address.");
index ede88d34826e0776b20e9c62677816a392d0778f..625e319aa3fc319446db20dbf854bdfff4d5a950 100644 (file)
@@ -16,7 +16,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.listener.DeviceStatusListener;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
@@ -77,8 +76,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
     @Override
     public void initialize() {
         logger.debug("Initializing CircuitHandler.");
-        if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) {
-            dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString();
+        dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
+        if (dSID != null && !dSID.isBlank()) {
             final Bridge bridge = getBridge();
             if (bridge != null) {
                 bridgeStatusChanged(bridge.getStatusInfo());
index a76d75d5d71e2ff5283cde33b7c2d356fe4f67f7..ee37d31a2d4892f6557bcf86402361ad2ed04d35 100644 (file)
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@@ -108,8 +107,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
     @Override
     public void initialize() {
         logger.debug("Initializing DeviceHandler.");
-        if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) {
-            dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString();
+        dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
+        if (dSID != null && !dSID.isBlank()) {
             final Bridge bridge = getBridge();
             if (bridge != null) {
                 bridgeStatusChanged(bridge.getStatusInfo());
index e12f4e0c815732d7d08c59a835e74bb22a900989..dd6f002dc0e265ba379fc301f9c7dbe0e1509210 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.digitalstrom.internal.lib.manager.impl;
 
 import java.net.HttpURLConnection;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
 import org.openhab.binding.digitalstrom.internal.lib.listener.ConnectionListener;
 import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
@@ -286,8 +285,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
     @Override
     public String getNewSessionToken() {
         if (this.genAppToken) {
-            if (StringUtils.isNotBlank(config.getAppToken())) {
-                sessionToken = this.digitalSTROMClient.loginApplication(config.getAppToken());
+            String token = config.getAppToken();
+            if (token != null && !token.isBlank()) {
+                sessionToken = this.digitalSTROMClient.loginApplication(token);
             } else if (codeIsAuthentificationFaild()) {
                 onNotAuthenticated();
             }
@@ -379,8 +379,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
     private void onNotAuthenticated() {
         String applicationToken = null;
         boolean isAuthenticated = false;
-        if (StringUtils.isNotBlank(config.getAppToken())) {
-            sessionToken = digitalSTROMClient.loginApplication(config.getAppToken());
+        String token = config.getAppToken();
+        if (token != null && !token.isBlank()) {
+            sessionToken = digitalSTROMClient.loginApplication(token);
             if (sessionToken != null) {
                 isAuthenticated = true;
             } else {
@@ -425,7 +426,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
                             logger.debug(
                                     "no application-token for application {} found, generate a application-token {}",
                                     config.getApplicationName(), applicationToken);
-                            if (StringUtils.isNotBlank(applicationToken)) {
+                            if (applicationToken != null && !applicationToken.isBlank()) {
                                 // enable applicationToken
                                 if (!digitalSTROMClient.enableApplicationToken(applicationToken,
                                         digitalSTROMClient.login(config.getUserName(), config.getPassword()))) {
@@ -464,10 +465,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
     }
 
     private boolean checkUserPassword() {
-        if (StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword())) {
-            return true;
-        }
-        return false;
+        String userName = config.getUserName();
+        String password = config.getPassword();
+        return userName != null && !userName.isBlank() && password != null && !password.isBlank();
     }
 
     /**
@@ -509,8 +509,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
 
     @Override
     public boolean removeApplicationToken() {
-        if (StringUtils.isNotBlank(config.getAppToken())) {
-            return digitalSTROMClient.revokeToken(config.getAppToken(), null);
+        String token = config.getAppToken();
+        if (token != null && !token.isBlank()) {
+            return digitalSTROMClient.revokeToken(token, null);
         }
         return true;
     }
index 2e78f85ab2e5d8581faac1a0af2c0cab05f396c4..1da43ca30b705afc2b4a307a10046afcde4d7ade 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseSensorValues;
 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.AssignedSensors;
@@ -134,12 +133,13 @@ public class DsAPIImpl implements DsAPI {
     }
 
     private boolean checkRequiredZone(Integer zoneID, String zoneName) {
-        return zoneID != null && zoneID > -1 || StringUtils.isNotBlank(zoneName);
+        return zoneID != null && zoneID > -1 || (zoneName != null && !zoneName.isBlank());
     }
 
     private boolean checkRequiredDevice(DSID dsid, String dSUID, String name) {
-        return StringUtils.isNotBlank(SimpleRequestBuilder.objectToString(dsid)) || StringUtils.isNotBlank(name)
-                || StringUtils.isNotBlank(dSUID);
+        String objectString = SimpleRequestBuilder.objectToString(dsid);
+        return (objectString != null && !objectString.isBlank()) || (name != null && !name.isBlank())
+                || (dSUID != null && !dSUID.isBlank());
     }
 
     @Override
@@ -411,7 +411,7 @@ public class DsAPIImpl implements DsAPI {
     @Override
     public boolean subscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
             int readTimeout) {
-        if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
+        if ((name != null && !name.isBlank()) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
             String response;
             response = transport.execute(
                     SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.SUBSCRIBE)
@@ -428,7 +428,7 @@ public class DsAPIImpl implements DsAPI {
     @Override
     public boolean unsubscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
             int readTimeout) {
-        if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
+        if (name != null && !name.isBlank() && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
             String response;
             response = transport.execute(
                     SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.UNSUBSCRIBE)
@@ -586,7 +586,7 @@ public class DsAPIImpl implements DsAPI {
 
     @Override
     public String loginApplication(String loginToken) {
-        if (StringUtils.isNotBlank(loginToken)) {
+        if (loginToken != null && !loginToken.isBlank()) {
             String response = transport.execute(SimpleRequestBuilder.buildNewRequest(InterfaceKeys.JSON)
                     .addRequestClass(ClassKeys.SYSTEM).addFunction(FunctionKeys.LOGIN_APPLICATION)
                     .addParameter(ParameterKeys.LOGIN_TOKEN, loginToken).buildRequestString());
index b22a31aa19aeab1c607b8795431d2b429093c2d5..f8a7369764d5faf3c51d4e61fc53322cbab2b8a0 100644 (file)
@@ -43,7 +43,7 @@ import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
 import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport;
@@ -194,13 +194,14 @@ public class HttpTransportImpl implements HttpTransport {
             if (config != null) {
                 cert = config.getCert();
                 logger.debug("generate SSLcontext from config cert");
-                if (StringUtils.isNotBlank(cert)) {
+                if (cert != null && !cert.isBlank()) {
                     sslSocketFactory = generateSSLContextFromPEMCertString(cert);
                 } else {
-                    if (StringUtils.isNotBlank(config.getTrustCertPath())) {
+                    String trustCertPath = config.getTrustCertPath();
+                    if (trustCertPath != null && !trustCertPath.isBlank()) {
                         logger.debug("generate SSLcontext from config cert path");
-                        cert = readPEMCertificateStringFromFile(config.getTrustCertPath());
-                        if (StringUtils.isNotBlank(cert)) {
+                        cert = readPEMCertificateStringFromFile(trustCertPath);
+                        if (cert != null && !cert.isBlank()) {
                             sslSocketFactory = generateSSLContextFromPEMCertString(cert);
                         }
                     } else {
@@ -355,7 +356,7 @@ public class HttpTransportImpl implements HttpTransport {
 
     private HttpsURLConnection getConnection(String request, int connectTimeout, int readTimeout) throws IOException {
         String correctedRequest = request;
-        if (StringUtils.isNotBlank(correctedRequest)) {
+        if (correctedRequest != null && !correctedRequest.isBlank()) {
             correctedRequest = fixRequest(correctedRequest);
             URL url = new URL(this.uri + correctedRequest);
             HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
@@ -415,7 +416,7 @@ public class HttpTransportImpl implements HttpTransport {
     }
 
     private String readPEMCertificateStringFromFile(String path) {
-        if (StringUtils.isBlank(path)) {
+        if (path == null || path.isBlank()) {
             logger.error("Path is empty.");
         } else {
             File dssCert = new File(path);
@@ -446,9 +447,9 @@ public class HttpTransportImpl implements HttpTransport {
 
     @Override
     public String writePEMCertFile(String path) {
-        String correctedPath = StringUtils.trimToEmpty(path);
+        String correctedPath = path == null ? "" : path.trim();
         File certFilePath;
-        if (StringUtils.isNotBlank(correctedPath)) {
+        if (!correctedPath.isBlank()) {
             certFilePath = new File(correctedPath);
             boolean pathExists = certFilePath.exists();
             if (!pathExists) {
@@ -485,7 +486,7 @@ public class HttpTransportImpl implements HttpTransport {
     }
 
     private SSLSocketFactory generateSSLContextFromPEMCertString(String pemCert) {
-        if (StringUtils.isNotBlank(pemCert) && pemCert.startsWith(BEGIN_CERT)) {
+        if (pemCert != null && !pemCert.isBlank() && pemCert.startsWith(BEGIN_CERT)) {
             try {
                 InputStream certInputStream = IOUtils.toInputStream(pemCert);
                 final X509Certificate trustedCert = (X509Certificate) CertificateFactory.getInstance("X.509")
index 6adc3a15ef9355109b0f22f41dc3485c421fee6a..3ba6161922aa1ca7ec6397d849ec362b2c677c35 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsr
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.commons.lang.NullArgumentException;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ExeptionConstants;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.InterfaceKeys;
 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ParameterKeys;
@@ -61,7 +60,7 @@ public class SimpleRequestBuilder {
      * @return simpleRequestBuilder with chosen interface
      * @throws NullArgumentException if the interfaceKey is null
      */
-    public static SimpleRequestBuilder buildNewRequest(String interfaceKey) throws NullArgumentException {
+    public static SimpleRequestBuilder buildNewRequest(String interfaceKey) throws IllegalArgumentException {
         if (builder == null) {
             builder = new SimpleRequestBuilder();
         }
@@ -78,14 +77,13 @@ public class SimpleRequestBuilder {
      * @throws IllegalArgumentException if a requestClass is already chosen
      * @throws NullArgumentException if the requestClassKey is null
      */
-    public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey)
-            throws NullArgumentException, IllegalArgumentException {
+    public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey) throws IllegalArgumentException {
         return buildNewRequest(InterfaceKeys.JSON).addRequestClass(requestClassKey);
     }
 
     private SimpleRequestBuilder buildNewRequestInt(String interfaceKey) {
         if (interfaceKey == null) {
-            throw new NullArgumentException("interfaceKey");
+            throw new IllegalArgumentException("interfaceKey is null");
         }
         request = "/" + interfaceKey + "/";
         classIsChosen = false;
@@ -102,8 +100,7 @@ public class SimpleRequestBuilder {
      * @throws IllegalArgumentException if a requestClass is already chosen
      * @throws NullArgumentException if the requestClassKey is null
      */
-    public SimpleRequestBuilder addRequestClass(String requestClassKey)
-            throws IllegalArgumentException, NullArgumentException {
+    public SimpleRequestBuilder addRequestClass(String requestClassKey) throws IllegalArgumentException {
         return builder.addRequestClassInt(requestClassKey);
     }
 
@@ -115,7 +112,7 @@ public class SimpleRequestBuilder {
             if (!classIsChosen) {
                 throw new IllegalArgumentException(ExeptionConstants.CLASS_ALREADY_ADDED);
             } else {
-                throw new NullArgumentException("requestClassKey");
+                throw new IllegalArgumentException("requestClassKey is null");
             }
         }
         return this;
@@ -129,7 +126,7 @@ public class SimpleRequestBuilder {
      * @throws IllegalArgumentException if a function is already chosen
      * @throws NullArgumentException if the functionKey is null
      */
-    public SimpleRequestBuilder addFunction(String functionKey) throws IllegalArgumentException, NullArgumentException {
+    public SimpleRequestBuilder addFunction(String functionKey) throws IllegalArgumentException {
         return builder.addFunctionInt(functionKey);
     }
 
@@ -142,7 +139,7 @@ public class SimpleRequestBuilder {
                 functionIsChosen = true;
                 request = request + functionKey;
             } else {
-                throw new NullArgumentException("functionKey");
+                throw new IllegalArgumentException("functionKey is null");
             }
         } else {
             throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED);
@@ -160,7 +157,7 @@ public class SimpleRequestBuilder {
      * @throws NullArgumentException if the parameterKey is null
      */
     public SimpleRequestBuilder addParameter(String parameterKey, String parameterValue)
-            throws IllegalArgumentException, NullArgumentException {
+            throws IllegalArgumentException {
         return builder.addParameterInt(parameterKey, parameterValue);
     }
 
@@ -175,7 +172,7 @@ public class SimpleRequestBuilder {
      * @throws NullArgumentException if the parameterKey is null
      */
     public SimpleRequestBuilder addDefaultZoneParameter(String sessionToken, Integer zoneID, String zoneName)
-            throws IllegalArgumentException, NullArgumentException {
+            throws IllegalArgumentException {
         return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.ID, objectToString(zoneID))
                 .addParameter(ParameterKeys.NAME, zoneName);
     }
@@ -191,7 +188,7 @@ public class SimpleRequestBuilder {
      * @throws NullArgumentException if the parameterKey is null
      */
     public SimpleRequestBuilder addDefaultGroupParameter(String sessionToken, Short groupID, String groupName)
-            throws IllegalArgumentException, NullArgumentException {
+            throws IllegalArgumentException {
         return addParameter(ParameterKeys.TOKEN, sessionToken)
                 .addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
                 .addParameter(ParameterKeys.GROUP_NAME, groupName);
@@ -210,7 +207,7 @@ public class SimpleRequestBuilder {
      * @throws NullArgumentException if the parameterKey is null
      */
     public SimpleRequestBuilder addDefaultZoneGroupParameter(String sessionToken, Integer zoneID, String zoneName,
-            Short groupID, String groupName) throws IllegalArgumentException, NullArgumentException {
+            Short groupID, String groupName) throws IllegalArgumentException {
         return addDefaultZoneParameter(sessionToken, zoneID, zoneName)
                 .addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
                 .addParameter(ParameterKeys.GROUP_NAME, groupName);
@@ -228,7 +225,7 @@ public class SimpleRequestBuilder {
      * @throws NullArgumentException if the parameterKey is null
      */
     public SimpleRequestBuilder addDefaultDeviceParameter(String sessionToken, DSID dsid, String dSUID, String name)
-            throws IllegalArgumentException, NullArgumentException {
+            throws IllegalArgumentException {
         return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.DSID, objectToString(dsid))
                 .addParameter(ParameterKeys.DSUID, dSUID).addParameter(ParameterKeys.NAME, name);
     }
@@ -236,7 +233,7 @@ public class SimpleRequestBuilder {
     private SimpleRequestBuilder addParameterInt(String parameterKey, String parameterValue) {
         if (allRight()) {
             if (parameterKey == null) {
-                throw new NullArgumentException("parameterKey");
+                throw new IllegalArgumentException("parameterKey is null");
             }
             if (parameterValue != null) {
                 if (!parameterIsAdded) {
index 2f5096b2b4faebd4ddf2c4320425574a6b81dc85..4f7969ca8d7e3ab589ec0deecaecb05cd71fe63a 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
 import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
 import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@@ -1695,7 +1694,7 @@ public class DeviceImpl extends AbstractGeneralDeviceInformations implements Dev
                         short sceneID = Short.parseShort((String) key
                                 .subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length()));
                         sceneSave = propertries.get(key);
-                        if (StringUtils.isNotBlank(sceneSave)) {
+                        if (sceneSave != null && !sceneSave.isBlank()) {
                             logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid,
                                     key);
                             String[] sceneParm = sceneSave.replace(" ", "").split(",");
index 2bd98d08d4b369130aa08e8da1053fcc676c9598..430271a593da63a10a9d5fb3672d82fc6b28eb51 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.digitalstrom.internal.lib.listener.SceneStatusListener;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
 import org.openhab.binding.digitalstrom.internal.lib.structure.scene.constants.SceneTypes;
@@ -71,7 +70,7 @@ public class InternalScene {
             this.zoneID = zoneID;
         }
         this.internalSceneID = this.zoneID + "-" + this.groupID + "-" + this.sceneID;
-        if (StringUtils.isBlank(sceneName)) {
+        if (sceneName == null || sceneName.isBlank()) {
             this.sceneName = this.internalSceneID;
         } else {
             this.sceneName = sceneName;
index d8046cc7343cd3f7a2267c13c63ee9645f707964..64057c1a97648b5ff67ec60c1baa956e33b0abb7 100644 (file)
@@ -13,8 +13,9 @@
 package org.openhab.binding.digitalstrom.internal.providers;
 
 import java.util.Locale;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.i18n.TranslationProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.service.component.ComponentContext;
@@ -132,6 +133,9 @@ public abstract class BaseDsI18n {
      * @return key
      */
     public static String buildIdentifier(Object... parts) {
-        return StringUtils.join(parts, SEPERATOR).toLowerCase();
+        return Stream.of(parts) //
+                .map(Object::toString) //
+                .map(String::toLowerCase) //
+                .collect(Collectors.joining(SEPERATOR));
     }
 }
index 9252bfc3c73ee692f9ef6b09478b3c074b0f0fff..93c28d5e3f9821d08ea13911f27b21c67ae2b349 100644 (file)
@@ -26,7 +26,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
index e3aa1853277e266b53dbcb698cd2352f0e614beb..06958b89d12cfad3336e1808f7132a1536e10dcc 100644 (file)
@@ -18,8 +18,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -133,8 +132,9 @@ public class EcobeeAuth {
                 logger.debug("EcobeeAuth: Got null authorize response from Ecobee API");
                 setState(EcobeeAuthState.NEED_PIN);
             } else {
-                if (StringUtils.isNotEmpty(authResponse.error)) {
-                    throw new EcobeeAuthException(authResponse.error + ": " + authResponse.errorDescription);
+                String error = authResponse.error;
+                if (error != null && !error.isEmpty()) {
+                    throw new EcobeeAuthException(error + ": " + authResponse.errorDescription);
                 }
                 code = authResponse.code;
                 writeLogMessage(authResponse.pin, authResponse.expiresIn);
@@ -172,8 +172,9 @@ public class EcobeeAuth {
             setState(isPinExpired() ? EcobeeAuthState.NEED_PIN : EcobeeAuthState.NEED_TOKEN);
             return;
         }
-        if (StringUtils.isNotEmpty(tokenResponse.error)) {
-            throw new EcobeeAuthException(tokenResponse.error + ": " + tokenResponse.errorDescription);
+        String error = tokenResponse.error;
+        if (error != null && !error.isEmpty()) {
+            throw new EcobeeAuthException(error + ": " + tokenResponse.errorDescription);
         }
         AccessTokenResponse accessTokenResponse = new AccessTokenResponse();
         accessTokenResponse.setRefreshToken(tokenResponse.refreshToken);
index 7168910c1c7fccee6e20a07c8379e9a72e0a6249..760248fc8f273c3c6a0755bd65486c23775fcc6a 100644 (file)
@@ -17,7 +17,7 @@ import static org.openhab.binding.ecobee.internal.EcobeeBindingConstants.*;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.text.WordUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration;
 import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO;
index 76541af49d686f96511559e94322f5d929c4ecc2..f6b399bf6f86703eabecce83e2a4159956d83cdf 100644 (file)
@@ -25,7 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.measure.Unit;
 
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.text.WordUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.ecobee.internal.action.EcobeeActions;
index 16573c9828dfaf44da50ee7fee0b493e89b2321f..71cd206469f40e28b3bfd4d1b94d0787bfb63139 100644 (file)
@@ -17,7 +17,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.TooManyListenersException;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.openhab.core.io.transport.serial.PortInUseException;
 import org.openhab.core.io.transport.serial.SerialPort;
 import org.openhab.core.io.transport.serial.SerialPortEvent;
index b695105c2be0d129ec6fc2af584c889de6c09216..f636b1d9dfe9066669171c89fa00aaf4202ef6e6 100644 (file)
@@ -24,7 +24,6 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.util.UrlEncoded;
@@ -94,7 +93,7 @@ public class Enigma2Client {
         } catch (ParserConfigurationException e) {
             logger.warn("Failed setting parser features against XXE attacks!", e);
         }
-        if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
+        if (user != null && !user.isEmpty() && password != null && !password.isEmpty()) {
             this.host = "http://" + user + ":" + password + "@" + host;
         } else {
             this.host = "http://" + host;
index b4fed2ccb4ad76504bdac77f3f21b1c7db2e8b28..736b37be236716708e16731b6ac3648d464e8634 100644 (file)
@@ -23,7 +23,6 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
 
-import org.apache.commons.lang3.NotImplementedException;
 import org.openhab.binding.enocean.internal.config.EnOceanBaseConfig;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.eep.EEPFactory;
@@ -135,7 +134,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
     }
 
     protected void sendRequestResponse() {
-        throw new NotImplementedException("Sensor cannot send responses");
+        throw new UnsupportedOperationException("Sensor cannot send responses");
     }
 
     @Override
index 15ff8fbd77a810f4af8f34c8d39bc571a5c6a4ec..2a701eaba359742a57fe5a8bf004204be477a0cf 100644 (file)
@@ -20,7 +20,6 @@ import java.util.List;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -95,14 +94,15 @@ public class EnturNoHandler extends BaseThingHandler {
 
         logger.debug("Stop place id: {}", stopId);
         boolean configValid = true;
-        if (StringUtils.trimToNull(stopId) == null) {
+        if (stopId == null || stopId.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error-missing-stopId");
             configValid = false;
         }
 
-        logger.debug("Line code: {}", config.getLineCode());
-        if (StringUtils.trimToNull(config.getLineCode()) == null) {
+        String lineCode = config.getLineCode();
+        logger.debug("Line code: {}", lineCode);
+        if (lineCode == null || lineCode.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error-missing-lineCode");
             configValid = false;
index 6f852ac30222126aacf3ad8dc3cea265f6bad38b..c5c65bcb9a4bff79339d2ddf293080758db1cd08 100644 (file)
@@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -96,9 +96,9 @@ public class EnturNoConnection {
      */
     public synchronized List<DisplayData> getEnturTimeTable(@Nullable String stopPlaceId, @Nullable String lineCode)
             throws JsonSyntaxException, EnturConfigurationException, EnturCommunicationException {
-        if (StringUtils.isBlank(stopPlaceId)) {
+        if (stopPlaceId == null || stopPlaceId.isBlank()) {
             throw new EnturConfigurationException("Stop place id cannot be empty or null");
-        } else if (lineCode == null || StringUtils.isBlank(lineCode)) {
+        } else if (lineCode == null || lineCode.isBlank()) {
             throw new EnturConfigurationException("Line code cannot be empty or null");
         }
 
@@ -115,8 +115,9 @@ public class EnturNoConnection {
 
     private Map<String, String> getRequestParams(EnturNoConfiguration config) {
         Map<String, String> params = new HashMap<>();
-        params.put(PARAM_STOPID, StringUtils.trimToEmpty(config.getStopPlaceId()));
-        params.put(PARAM_START_DATE_TIME, StringUtils.trimToEmpty(LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString()));
+        String stopPlaceId = config.getStopPlaceId();
+        params.put(PARAM_STOPID, stopPlaceId == null ? "" : stopPlaceId.trim());
+        params.put(PARAM_START_DATE_TIME, LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString());
 
         return params;
     }
@@ -141,7 +142,7 @@ public class EnturNoConnection {
 
             int httpStatus = contentResponse.getStatus();
             String content = contentResponse.getContentAsString();
-            String errorMessage = StringUtils.EMPTY;
+            String errorMessage = "";
             logger.trace("Entur response: status = {}, content = '{}'", httpStatus, content);
             switch (httpStatus) {
                 case OK_200:
index e3255b4bac2257271c0dad39c67afb212f139bf6..f959c01d88f7ed84024602dd7ce4c49689504001 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.evohome.internal.handler;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.evohome.internal.api.models.v2.response.Locations;
 import org.openhab.binding.evohome.internal.configuration.EvohomeThingConfiguration;
 import org.openhab.core.thing.Bridge;
@@ -132,7 +131,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler {
         if (configuration == null) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Configuration is missing or corrupted");
-        } else if (StringUtils.isEmpty(configuration.id)) {
+        } else if (configuration.id == null || configuration.id.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Id not configured");
         }
     }
index 06e563f776ab477bfc6c5ec57fa8c6da2d585a50..5c64f717afa7c479ff1149c4936f1c17b27818c8 100644 (file)
@@ -22,7 +22,6 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jetty.client.HttpClient;
 import org.openhab.binding.evohome.internal.RunnableWithTimeout;
 import org.openhab.binding.evohome.internal.api.EvohomeApiClient;
@@ -190,9 +189,9 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler {
 
         if (configuration == null) {
             errorMessage = "Configuration is missing or corrupted";
-        } else if (StringUtils.isEmpty(configuration.username)) {
+        } else if (configuration.username == null || configuration.username.isEmpty()) {
             errorMessage = "Username not configured";
-        } else if (StringUtils.isEmpty(configuration.password)) {
+        } else if (configuration.password == null || configuration.password.isEmpty()) {
             errorMessage = "Password not configured";
         } else {
             return true;
index 33c70ce165df6ff419ecb627391f8acdf3b4c304..10d700467cfd9a1df201750b54a44297742b41cb 100644 (file)
@@ -29,7 +29,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.exec.internal.ExecWhitelistWatchService;
index 61d95b998a740504de435f54679dba10dbeb9762..48e12ed582754f2af283d712215b284402c6eddc 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -156,7 +155,7 @@ public class FoobotApiConnector {
                 apiKeyLimitRemaining = API_RATE_LIMIT_EXCEEDED;
                 throw new FoobotApiException(response.getStatus(), API_RATE_LIMIT_EXCEEDED_MESSAGE);
             case HttpStatus.OK_200:
-                if (StringUtils.trimToNull(content) == null) {
+                if (content == null || content.isBlank()) {
                     throw new FoobotApiException(0, "No data returned");
                 }
                 return content;
index 4684b7456749d81a7da8c664a4c7bf50bbf0e62a..0bece5240d56f7d7b9023960ee61e842978d29a4 100644 (file)
@@ -15,12 +15,14 @@ package org.openhab.binding.foobot.internal.handler;
 import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
 
 import java.time.Duration;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.foobot.internal.FoobotApiConnector;
@@ -93,10 +95,12 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
         final FoobotAccountConfiguration accountConfig = getConfigAs(FoobotAccountConfiguration.class);
         final List<String> missingParams = new ArrayList<>();
 
-        if (StringUtils.trimToNull(accountConfig.apiKey) == null) {
+        String apiKey = accountConfig.apiKey;
+        if (apiKey.isBlank()) {
             missingParams.add("'apikey'");
         }
-        if (StringUtils.trimToNull(accountConfig.username) == null) {
+        String username = accountConfig.username;
+        if (username.isBlank()) {
             missingParams.add("'username'");
         }
 
@@ -104,13 +108,13 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
             final boolean oneParam = missingParams.size() == 1;
             final String errorMsg = String.format(
                     "Parameter%s [%s] %s mandatory and must be configured and not be empty", oneParam ? "" : "s",
-                    StringUtils.join(missingParams, ", "), oneParam ? "is" : "are");
+                    String.join(", ", missingParams), oneParam ? "is" : "are");
 
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, errorMsg);
             return;
         }
-        username = accountConfig.username;
-        connector.setApiKey(accountConfig.apiKey);
+        this.username = username;
+        connector.setApiKey(apiKey);
         refreshInterval = accountConfig.refreshInterval;
         if (this.refreshInterval < MINIMUM_REFRESH_PERIOD_MINUTES) {
             logger.warn(
@@ -118,8 +122,7 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
                     accountConfig.refreshInterval, MINIMUM_REFRESH_PERIOD_MINUTES, DEFAULT_REFRESH_PERIOD_MINUTES);
             refreshInterval = DEFAULT_REFRESH_PERIOD_MINUTES;
         }
-        logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", accountConfig.username,
-                refreshInterval);
+        logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", username, refreshInterval);
 
         updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "Wait to get associated devices");
 
index 46302f7cac200c7a33b794371c48303a28edb4b9..a9855e1467d9fba5f32b6f865cf0d88d963b313d 100644 (file)
@@ -21,7 +21,6 @@ import java.util.Map;
 
 import javax.measure.Unit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.foobot.internal.FoobotApiConnector;
@@ -93,7 +92,7 @@ public class FoobotDeviceHandler extends BaseThingHandler {
         logger.debug("Initializing Foobot handler.");
         uuid = (String) getConfig().get(FoobotBindingConstants.CONFIG_UUID);
 
-        if (StringUtils.trimToNull(uuid) == null) {
+        if (uuid.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Parameter 'uuid' is mandatory and must be configured");
             return;
index 16662d873dfdab9b430fd963a6ed075aed12dd1e..274157f0a3fe0c0dda8d4938514f275c035ae88f 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
 import org.openhab.core.io.net.http.HttpUtil;
 import org.openhab.core.thing.Bridge;
@@ -62,10 +61,13 @@ public class FroniusBridgeHandler extends BaseBridgeHandler {
 
         boolean validConfig = true;
         String errorMsg = null;
-        if (StringUtils.trimToNull(config.hostname) == null) {
+
+        String hostname = config.hostname;
+        if (hostname == null || hostname.isBlank()) {
             errorMsg = "Parameter 'hostname' is mandatory and must be configured";
             validConfig = false;
         }
+
         if (config.refreshInterval != null && config.refreshInterval <= 0) {
             errorMsg = "Parameter 'refresh' must be at least 1 second";
             validConfig = false;
index 22e62e8706c06d5fe972e48c943b7c2c782e557a..9e590f0f7912c9c009d214712b21fa2b009c1e9a 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.fronius.internal.handler;
 
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.fronius.internal.FroniusBaseDeviceConfiguration;
 import org.openhab.binding.fronius.internal.FroniusBindingConstants;
 import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
index e156d7d9bd8310dced25265c08df98f966782cd9..ff8592f8d20c2baa8fd0b020cc3fd83584fbc933 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.fronius.internal.handler;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.fronius.internal.FroniusBaseDeviceConfiguration;
 import org.openhab.binding.fronius.internal.FroniusBindingConstants;
 import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
index a24cb7f0431721ae1f8bb17bcb9e63c887e340f4..548d00a95164381005b40cfbad1beffeeb0a6e94 100644 (file)
@@ -18,7 +18,6 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
 import java.math.BigDecimal;
 import java.util.concurrent.ScheduledFuture;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jetty.client.HttpClient;
 import org.openhab.binding.fsinternetradio.internal.radio.FrontierSiliconRadio;
 import org.openhab.core.library.types.DecimalType;
@@ -128,7 +127,7 @@ public class FSInternetRadioHandler extends BaseThingHandler {
         final BigDecimal port = (BigDecimal) getThing().getConfiguration().get(CONFIG_PROPERTY_PORT);
         final String pin = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_PIN);
 
-        if (ip == null || StringUtils.isEmpty(pin) || port.intValue() == 0) {
+        if (ip == null || pin == null || pin.isEmpty() || port.intValue() == 0) {
             // configuration incomplete
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Configuration incomplete");
         } else {
index 479ff037ebbb84d7e3849ad92f9a4a257cb7a789..0b28a407ab93f4a7ef498eadb2f39fe629a9c8af 100644 (file)
@@ -21,9 +21,12 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -818,7 +821,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
         BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString());
         String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.toString());
 
-        if (ip == null || port.compareTo(BigDecimal.ZERO) == 0 || StringUtils.isEmpty(pin)) {
+        if (ip == null || port.compareTo(BigDecimal.ZERO) == 0 || pin == null || pin.isEmpty()) {
             return false;
         }
         return true;
index 8990d0ec761316655a1fe9c3668af038e577d4f7..21dd1e83b1375b13b58e0bbf5cf64bd0987222b7 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.ftpserver.DataConnectionConfigurationFactory;
 import org.apache.ftpserver.FtpServerConfigurationException;
 import org.apache.ftpserver.ftplet.FtpException;
@@ -98,7 +97,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
 
         if (properties.get("port") != null) {
             String strPort = properties.get("port").toString();
-            if (StringUtils.isNotEmpty(strPort)) {
+            if (!strPort.isEmpty()) {
                 try {
                     port = Integer.valueOf(strPort);
                 } catch (NumberFormatException e) {
@@ -109,7 +108,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
 
         if (properties.get("idleTimeout") != null) {
             String strIdleTimeout = properties.get("idleTimeout").toString();
-            if (StringUtils.isNotEmpty(strIdleTimeout)) {
+            if (!strIdleTimeout.isEmpty()) {
                 try {
                     idleTimeout = Integer.valueOf(strIdleTimeout);
                 } catch (NumberFormatException e) {
index 986b6db1c8a686a2447feae9d368319c2eaa59d6..119fb83d0efa2d6d2b46d683268c08c6984ab775 100644 (file)
@@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
 import org.openhab.binding.globalcache.internal.command.CommandGetstate;
@@ -252,7 +251,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
         }
 
         String mapFile = (String) thing.getConfiguration().get(THING_CONFIG_MAP_FILENAME);
-        if (StringUtils.isEmpty(mapFile)) {
+        if (mapFile == null || mapFile.isEmpty()) {
             logger.warn("MAP file is not defined in configuration of thing {}", thingID());
             return null;
         }
@@ -266,14 +265,13 @@ public class GlobalCacheHandler extends BaseThingHandler {
         String code;
         try {
             code = transformService.transform(mapFile, command.toString());
-
         } catch (TransformationException e) {
             logger.error("Failed to transform {} for thing {} using map file '{}', exception={}", command, thingID(),
                     mapFile, e.getMessage());
             return null;
         }
 
-        if (StringUtils.isEmpty(code)) {
+        if (code == null || code.isEmpty()) {
             logger.warn("No entry for {} in map file '{}' for thing {}", command, mapFile, thingID());
             return null;
         }
@@ -638,7 +636,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
 
         private String getIPAddress() {
             String ipAddress = ((GlobalCacheHandler) thing.getHandler()).getIP();
-            if (StringUtils.isEmpty(ipAddress)) {
+            if (ipAddress == null || ipAddress.isEmpty()) {
                 logger.debug("Handler for thing {} could not get IP address from config", thingID());
                 markThingOfflineWithError(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "IP address not set");
             }
@@ -912,7 +910,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
             if (Boolean.TRUE.equals(enableTwoWay)) {
                 // Get the end of message delimiter from the config, URL decode it, and convert it to a byte array
                 String endOfMessageString = (String) thing.getConfiguration().get(endOfMessageDelimiterConfig);
-                if (StringUtils.isNotEmpty(endOfMessageString)) {
+                if (endOfMessageString != null && !endOfMessageString.isEmpty()) {
                     logger.debug("End of message is {} for thing {} {}", endOfMessageString, thingID(), serialDevice);
                     byte[] endOfMessage;
                     try {
index 6b54975a07f05ce5c5ad32fb297c80336823c4ec..39dfd9fdbfcaa6cb6ca3664cdf243c414e80c5aa 100644 (file)
@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
 import javax.measure.quantity.ElectricCurrent;
 import javax.measure.quantity.Energy;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
index 43013400baa8096b191b4f6d071bba1a4f29ede7..eb974d0f741330ccf5016f27224941702bcd37a8 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.harmonyhub.internal.HarmonyHubHandlerFactory;
@@ -263,9 +262,9 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyClien
         // earlier versions required a name and used network discovery to find the hub and retrieve the host,
         // this section is to not break that and also update older configurations to use the host configuration
         // option instead of name
-        if (StringUtils.isBlank(host)) {
+        if (host == null || host.isBlank()) {
             host = getThing().getProperties().get(HUB_PROPERTY_HOST);
-            if (StringUtils.isNotBlank(host)) {
+            if (host != null && !host.isBlank()) {
                 Configuration genericConfig = getConfig();
                 genericConfig.put(HUB_PROPERTY_HOST, host);
                 updateConfiguration(genericConfig);
index 417ee7a367a1e087ad475692c2f3aeb0dafd1855..79b114d45698ddeea167a2236f47b79a51253ba7 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.hdanywhere.internal.handler;
 
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -93,27 +91,25 @@ public class Mhub4K431Handler extends BaseThingHandler {
             String content = "{tag:ptn}";
             InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
 
-            if (isNotBlank(httpMethod) && isNotBlank(url)) {
-                String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
-                response = response.trim();
-                response = response.substring(1, response.length() - 1);
+            String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
+            response = response.trim();
+            response = response.substring(1, response.length() - 1);
 
-                if (response != null) {
-                    updateStatus(ThingStatus.ONLINE);
+            if (response != null) {
+                updateStatus(ThingStatus.ONLINE);
 
-                    java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
-                    }.getType();
-                    Map<String, String> map = gson.fromJson(response, type);
+                java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
+                }.getType();
+                Map<String, String> map = gson.fromJson(response, type);
 
-                    String inputChannel = map.get("Inputchannel");
+                String inputChannel = map.get("Inputchannel");
 
-                    for (int i = 0; i < numberOfPorts; i++) {
-                        DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
-                        updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
-                    }
-                } else {
-                    updateStatus(ThingStatus.OFFLINE);
+                for (int i = 0; i < numberOfPorts; i++) {
+                    DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
+                    updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
                 }
+            } else {
+                updateStatus(ThingStatus.OFFLINE);
             }
         } catch (Exception e) {
             logger.debug("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
index 70a4672d5c52bbb325f5940422d655e29999e0b0..a2cdc8c9539c6d39aa76927f57890c028a603155 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.hdanywhere.internal.handler;
 
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.concurrent.ScheduledFuture;
@@ -69,24 +67,22 @@ public class MultiroomPlusHandler extends BaseThingHandler {
             String httpMethod = "GET";
             String url = "http://" + host + "/status_show.shtml";
 
-            if (isNotBlank(httpMethod) && isNotBlank(url)) {
-                String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
+            String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
 
-                if (response != null) {
-                    updateStatus(ThingStatus.ONLINE);
+            if (response != null) {
+                updateStatus(ThingStatus.ONLINE);
 
-                    for (int i = 1; i <= numberOfPorts; i++) {
-                        Pattern p = Pattern.compile("var out" + i + "var = (.*);");
-                        Matcher m = p.matcher(response);
+                for (int i = 1; i <= numberOfPorts; i++) {
+                    Pattern p = Pattern.compile("var out" + i + "var = (.*);");
+                    Matcher m = p.matcher(response);
 
-                        while (m.find()) {
-                            DecimalType decimalType = new DecimalType(m.group(1));
-                            updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
-                        }
+                    while (m.find()) {
+                        DecimalType decimalType = new DecimalType(m.group(1));
+                        updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
                     }
-                } else {
-                    updateStatus(ThingStatus.OFFLINE);
                 }
+            } else {
+                updateStatus(ThingStatus.OFFLINE);
             }
         } catch (Exception e) {
             logger.warn("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
index ce625122fb2692b51df734081ece6c5bc5542dfb..afa7ea927e03b5d21ab8f853f3fae0f2ce6c2f57 100644 (file)
@@ -14,9 +14,9 @@ package org.openhab.binding.heos.internal.handler;
 
 import static org.openhab.binding.heos.internal.HeosBindingConstants.*;
 import static org.openhab.binding.heos.internal.handler.FutureUtil.cancel;
-import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.GROUP;
-import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.PLAYER;
+import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.*;
 import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*;
+import static org.openhab.binding.heos.internal.resources.HeosConstants.*;
 import static org.openhab.core.thing.ThingStatus.*;
 
 import java.io.IOException;
@@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit;
 
 import javax.measure.quantity.Time;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.heos.internal.HeosChannelHandlerFactory;
@@ -38,15 +37,31 @@ import org.openhab.binding.heos.internal.api.HeosFacade;
 import org.openhab.binding.heos.internal.exception.HeosFunctionalException;
 import org.openhab.binding.heos.internal.exception.HeosNotConnectedException;
 import org.openhab.binding.heos.internal.exception.HeosNotFoundException;
-import org.openhab.binding.heos.internal.json.dto.*;
+import org.openhab.binding.heos.internal.json.dto.HeosCommandTuple;
+import org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute;
+import org.openhab.binding.heos.internal.json.dto.HeosError;
+import org.openhab.binding.heos.internal.json.dto.HeosEvent;
+import org.openhab.binding.heos.internal.json.dto.HeosEventObject;
+import org.openhab.binding.heos.internal.json.dto.HeosObject;
+import org.openhab.binding.heos.internal.json.dto.HeosResponseObject;
 import org.openhab.binding.heos.internal.json.payload.Media;
 import org.openhab.binding.heos.internal.json.payload.Player;
 import org.openhab.binding.heos.internal.resources.HeosEventListener;
 import org.openhab.binding.heos.internal.resources.Telnet.ReadException;
 import org.openhab.core.io.net.http.HttpUtil;
-import org.openhab.core.library.types.*;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.PlayPauseType;
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.types.RawType;
+import org.openhab.core.library.types.StringType;
 import org.openhab.core.library.unit.Units;
-import org.openhab.core.thing.*;
+import org.openhab.core.thing.Bridge;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
+import org.openhab.core.thing.ThingStatusInfo;
 import org.openhab.core.thing.binding.BaseThingHandler;
 import org.openhab.core.types.UnDefType;
 import org.slf4j.Logger;
@@ -474,16 +489,17 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
     }
 
     private void handleImageUrl(Media info) {
-        if (StringUtils.isNotBlank(info.imageUrl)) {
+        String imageUrl = info.imageUrl;
+        if (imageUrl != null && !imageUrl.isBlank()) {
             try {
-                URL url = new URL(info.imageUrl); // checks if String is proper URL
+                URL url = new URL(imageUrl); // checks if String is proper URL
                 RawType cover = HttpUtil.downloadImage(url.toString());
                 if (cover != null) {
                     updateState(CH_ID_COVER, cover);
                     return;
                 }
             } catch (MalformedURLException e) {
-                logger.debug("Cover can't be loaded. No proper URL: {}", info.imageUrl, e);
+                logger.debug("Cover can't be loaded. No proper URL: {}", imageUrl, e);
             }
         }
         updateState(CH_ID_COVER, UnDefType.NULL);
index ea64e615fb76e5ba102cf171aa13c00df50c3a05..932d88846151938fe946d394be5f9fa46816ac80 100644 (file)
@@ -16,11 +16,14 @@ import static org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants.*
 
 import java.time.ZonedDateTime;
 import java.time.temporal.ChronoUnit;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.hydrawise.internal.api.HydrawiseAuthenticationException;
@@ -210,8 +213,9 @@ public abstract class HydrawiseHandler extends BaseThingHandler {
             updateGroupState(group, CHANNEL_ZONE_TYPE, new DecimalType(r.type));
             updateGroupState(group, CHANNEL_ZONE_TIME,
                     r.runTimeSeconds != null ? new DecimalType(r.runTimeSeconds) : UnDefType.UNDEF);
-            if (StringUtils.isNotBlank(r.icon)) {
-                updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + r.icon));
+            String icon = r.icon;
+            if (icon != null && !icon.isBlank()) {
+                updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + icon));
             }
             if (r.time >= MAX_RUN_TIME) {
                 updateGroupState(group, CHANNEL_ZONE_NEXT_RUN_TIME_TIME, UnDefType.UNDEF);
index 50ed769d62beb0c72526131246cba1bae9f0d533..c928bd6d04606187cd85d23391edd10a85180183 100644 (file)
@@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
 import javax.measure.Unit;
 import javax.measure.quantity.Temperature;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -268,7 +267,7 @@ public class IAqualinkHandler extends BaseThingHandler {
         String confSerialId = configuration.serialId;
         String confApiKey = configuration.apiKey;
 
-        if (StringUtils.isNotBlank(confApiKey)) {
+        if (confApiKey != null && !confApiKey.isBlank()) {
             this.apiKey = confApiKey;
         } else {
             this.apiKey = DEFAULT_API_KEY;
@@ -291,7 +290,7 @@ public class IAqualinkHandler extends BaseThingHandler {
                 return;
             }
 
-            if (StringUtils.isNotBlank(confSerialId)) {
+            if (confSerialId != null && !confSerialId.isBlank()) {
                 serialNumber = confSerialId.replaceAll("[^a-zA-Z0-9]", "").toLowerCase();
                 if (!Arrays.stream(devices).anyMatch(device -> device.getSerialNumber().equals(serialNumber))) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
@@ -438,8 +437,7 @@ public class IAqualinkHandler extends BaseThingHandler {
      */
     private State toState(String name, @Nullable String type, @Nullable String value) {
         try {
-            // @nullable checker does not recognize isBlank as checking null here, so must use == null to make happy
-            if (value == null || StringUtils.isBlank(value)) {
+            if (value == null || value.isBlank()) {
                 return UnDefType.UNDEF;
             }
 
index 0ca762a59df10b8f67b8b822b95d580ee19561b9..e8b3fd52eccd171ab794dfe8c7e5a7732a9828a3 100644 (file)
@@ -19,7 +19,6 @@ import java.util.List;
 import java.util.Set;
 import java.util.function.Predicate;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.ihc.internal.config.ChannelParams;
 import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
 import org.openhab.core.config.core.Configuration;
@@ -214,16 +213,16 @@ public class ChannelUtils {
 
     private static String createDescription(String name1, String name2, String name3, String name4) {
         String description = "";
-        if (StringUtils.isNotEmpty(name1)) {
+        if (name1 != null && !name1.isEmpty()) {
             description = name1;
         }
-        if (StringUtils.isNotEmpty(name2)) {
+        if (name2 != null && !name2.isEmpty()) {
             description += String.format(" - %s", name2);
         }
-        if (StringUtils.isNotEmpty(name3)) {
+        if (name3 != null && !name3.isEmpty()) {
             description += String.format(" - %s", name3);
         }
-        if (StringUtils.isNotEmpty(name4)) {
+        if (name4 != null && !name4.isEmpty()) {
             description += String.format(" - %s", name4);
         }
         return description;
index 8f7b7a8ebd41dad9e7425686b69a957a14dec588..93439b0aa6ac183b8f839e0928ec688d8f1025d4 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Set;
 
 import javax.xml.xpath.XPathExpressionException;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.ihc.internal.ws.datatypes.XPathUtils;
 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
 import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
@@ -92,12 +91,12 @@ public class IhcResourceInteractionService extends IhcBaseService {
         // parse resource id
         String resourceId = XPathUtils.getSpeficValueFromNode(n, "ns1:resourceID");
 
-        if (StringUtils.isNotBlank(resourceId)) {
+        if (resourceId != null && !resourceId.isBlank()) {
             int id = Integer.parseInt(resourceId);
 
             // Parse floating point value
             String floatingPointValue = getValue(n, "floatingPointValue");
-            if (StringUtils.isNotBlank(floatingPointValue)) {
+            if (floatingPointValue != null && !floatingPointValue.isBlank()) {
                 String min = getValue(n, "minimumValue");
                 String max = getValue(n, "maximumValue");
                 return new WSFloatingPointValue(id, Double.valueOf(floatingPointValue), Double.valueOf(min),
@@ -106,13 +105,13 @@ public class IhcResourceInteractionService extends IhcBaseService {
 
             // Parse boolean value
             String value = getValue(n, "value");
-            if (StringUtils.isNotBlank(value)) {
+            if (value != null && !value.isBlank()) {
                 return new WSBooleanValue(id, Boolean.valueOf(value));
             }
 
             // Parse integer value
             String integer = getValue(n, "integer");
-            if (StringUtils.isNotBlank(integer)) {
+            if (integer != null && !integer.isBlank()) {
                 String min = getValue(n, "minimumValue");
                 String max = getValue(n, "maximumValue");
                 return new WSIntegerValue(id, Integer.valueOf(integer), Integer.valueOf(min), Integer.valueOf(max));
@@ -120,13 +119,13 @@ public class IhcResourceInteractionService extends IhcBaseService {
 
             // Parse timer value
             String milliseconds = getValue(n, "milliseconds");
-            if (StringUtils.isNotBlank(milliseconds)) {
+            if (milliseconds != null && !milliseconds.isBlank()) {
                 return new WSTimerValue(id, Integer.valueOf(milliseconds));
             }
 
             // Parse time value
             String hours = getValue(n, "hours");
-            if (StringUtils.isNotBlank(hours)) {
+            if (hours != null && !hours.isBlank()) {
                 String minutes = getValue(n, "minutes");
                 String seconds = getValue(n, "seconds");
                 return new WSTimeValue(id, Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds));
@@ -134,7 +133,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
 
             // Parse date value
             String year = getValue(n, "year");
-            if (StringUtils.isNotBlank(year)) {
+            if (year != null && !year.isBlank()) {
                 String month = getValue(n, "month");
                 String day = getValue(n, "day");
                 return new WSDateValue(id, Short.valueOf(year), Byte.valueOf(month), Byte.valueOf(day));
@@ -142,7 +141,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
 
             // Parse enum value
             String definitionTypeID = getValue(n, "definitionTypeID");
-            if (StringUtils.isNotBlank(definitionTypeID)) {
+            if (definitionTypeID != null && !definitionTypeID.isBlank()) {
                 String enumValueID = getValue(n, "enumValueID");
                 String enumName = getValue(n, "enumName");
                 return new WSEnumValue(id, Integer.valueOf(definitionTypeID), Integer.valueOf(enumValueID), enumName);
@@ -150,7 +149,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
 
             // Parse week day value
             value = getValue(n, "weekdayNumber");
-            if (StringUtils.isNotBlank(value)) {
+            if (value != null && !value.isBlank()) {
                 return new WSWeekdayValue(id, Integer.valueOf(value));
             }
 
index 3a841962a3270c7cac08760f1d771d5b0e176d1b..484d99add167f1d74305fdba11f2cb03f1898b36 100644 (file)
@@ -16,13 +16,14 @@ import static org.openhab.binding.innogysmarthome.internal.client.Constants.*;
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -180,7 +181,8 @@ public class InnogyClient {
         } catch (OAuthException | OAuthResponseException e) {
             throw new AuthenticationException("Error fetching access token: " + e.getMessage());
         }
-        if (accessTokenResponse == null || StringUtils.isBlank(accessTokenResponse.getAccessToken())) {
+        if (accessTokenResponse == null || accessTokenResponse.getAccessToken() == null
+                || accessTokenResponse.getAccessToken().isBlank()) {
             throw new AuthenticationException("No innogy accesstoken. Is this thing authorized?");
         }
         return accessTokenResponse;
index a9e74b1b7faf81872ab9cc22741800166daf09ef..65943b322f4d5144f8d267ae015b034135f6563d 100644 (file)
@@ -20,11 +20,19 @@ import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.time.format.DateTimeFormatter;
 import java.time.format.FormatStyle;
-import java.util.*;
-import java.util.concurrent.*;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -183,7 +191,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
      * @return true if success
      */
     private boolean checkOnAuthCode() {
-        if (StringUtils.isNotBlank(bridgeConfiguration.authcode)) {
+        if (!bridgeConfiguration.authcode.isBlank()) {
             logger.debug("Trying to get access and refresh tokens");
             try {
                 oAuthService.getAccessTokenResponseByAuthorizationCode(bridgeConfiguration.authcode,
@@ -868,7 +876,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
 
     /**
      * Sends the command to start or stop moving the rollershutter (ISR2) in a specified direction
-     * 
+     *
      * @param deviceId
      * @param action
      */
@@ -970,7 +978,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
 
     /**
      * Checks if the job is already (re-)scheduled.
-     * 
+     *
      * @param job job to check
      * @return true, when the job is already (re-)scheduled, otherwise false
      */
index a209af76cfc0f78f69106bc1a2ed76216c650442..d2ea1079a2f2beb55350c279ebd76564abefecc9 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.irtrans.internal.handler;
 
 import static org.openhab.binding.irtrans.internal.IRtransBindingConstants.CHANNEL_IO;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led;
 import org.openhab.binding.irtrans.internal.IrCommand;
 import org.openhab.core.library.types.StringType;
index 4a70874e3269114c46b7b916764fc92d46b21c4b..4e0aae384e9c47811dc0b5f9eddbee813825c87b 100644 (file)
@@ -35,7 +35,7 @@ import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.openhab.binding.irtrans.internal.IRtransBindingConstants;
 import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led;
index d7a39f554cb53a3582ec3b3f33370aadfbe15384..9befda8961dbbbd34ab1a894d41f133952575a4a 100644 (file)
@@ -21,7 +21,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
 import org.openhab.binding.jeelink.internal.ReadingPublisher;
 import org.openhab.binding.jeelink.internal.RollingAveragePublisher;
index 7074f1d57460a9fe8e9e6ecd97e9b020e8051da0..fcba0f17a3c7a4f38b65f86ede45d51e290258db 100644 (file)
@@ -18,7 +18,7 @@ import static org.openhab.core.library.unit.MetricPrefix.*;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
 import org.openhab.binding.jeelink.internal.ReadingPublisher;
index 1c6cd46a6611a9badc39434f0df6c5e8599a63ea..0dbe8727f53e46a9af5ed5547ff592ab7746350a 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.kaleidescape.internal.communication;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
@@ -48,8 +48,8 @@ public class KaleidescapeFormatter {
                 // I.e. characters with accent, umlaut, etc., they need to be restored to the correct character
                 // example: Noel (with umlaut 'o') comes in as N\d246el
                 input = input.replaceAll("(?i)\\\\d([0-9]{3})", "\\&#$1;"); // first convert to html escaped codes
-                // then convert with unescapeHtml, not sure how to do this without the Apache libraries :(
-                return StringEscapeUtils.unescapeHtml(input);
+                // then convert with unescapeHtml4, not sure how to do this without the Apache libraries :(
+                return StringEscapeUtils.unescapeHtml4(input);
             }
         }
         return input;
index 42f48c577ec0f0cca858a5989a12e5b83e016236..8280827d8a9742fdd17c757a1502c5dddc134e03 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.keba.internal;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingTypeUID;
 
index 36f789e4962f0ca165b25a0974b3ec5d94573b94..29b93acc3431b33588e412175e5f910380e4b368 100644 (file)
@@ -32,7 +32,7 @@ import javax.measure.quantity.Energy;
 import javax.measure.quantity.Power;
 import javax.measure.quantity.Time;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.keba.internal.KebaBindingConstants.KebaSeries;
 import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType;
 import org.openhab.core.cache.ExpiringCacheMap;
index dfb9af331f58f0207eef449ed4bc91ef64cf14dc..35261b4ffb190bd54eaa57acedcd2290110ce7e7 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Base64;
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.slf4j.Logger;
@@ -131,8 +130,8 @@ public class KM200Cryption {
      * @author Markus Eckhardt
      */
     public void recreateKeys() {
-        if (StringUtils.isNotBlank(remoteDevice.getGatewayPassword())
-                && StringUtils.isNotBlank(remoteDevice.getPrivatePassword()) && remoteDevice.getMD5Salt().length > 0) {
+        if (!remoteDevice.getGatewayPassword().isBlank() && !remoteDevice.getPrivatePassword().isBlank()
+                && remoteDevice.getMD5Salt().length > 0) {
             byte[] md5K1 = null;
             byte[] md5K2Init = null;
             byte[] md5K2Private = null;
index aefc94246a8a203c732f0df49a13228a10f1eeb3..91d5d2dcd98c5f4fb3e1a6fd7dda71c53f7c2195 100644 (file)
@@ -19,8 +19,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -84,7 +83,7 @@ public class KM200Device {
     }
 
     public Boolean isConfigured() {
-        return StringUtils.isNotBlank(ip4Address) && cryptKeyPriv.length > 0;
+        return !ip4Address.isBlank() && cryptKeyPriv.length > 0;
     }
 
     public String getIP4Address() {
index 8b11ac6e5e92eb6e62ba86ad5df172f2166a82a6..3a125dd152467ad9b479cec1172dd5eda68edae6 100644 (file)
@@ -30,7 +30,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -177,7 +176,7 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
             switch (key) {
                 case "ip4Address":
                     String ip = (String) configuration.get("ip4Address");
-                    if (StringUtils.isNotBlank(ip)) {
+                    if (ip != null && !ip.isBlank()) {
                         try {
                             InetAddress.getByName(ip);
                         } catch (UnknownHostException e) {
@@ -190,25 +189,25 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
                     break;
                 case "privateKey":
                     String privateKey = (String) configuration.get("privateKey");
-                    if (StringUtils.isNotBlank(privateKey)) {
+                    if (privateKey != null && !privateKey.isBlank()) {
                         getDevice().setCryptKeyPriv(privateKey);
                     }
                     break;
                 case "md5Salt":
                     String md5Salt = (String) configuration.get("md5Salt");
-                    if (StringUtils.isNotBlank(md5Salt)) {
+                    if (md5Salt != null && !md5Salt.isBlank()) {
                         getDevice().setMD5Salt(md5Salt);
                     }
                     break;
                 case "gatewayPassword":
                     String gatewayPassword = (String) configuration.get("gatewayPassword");
-                    if (StringUtils.isNotBlank(gatewayPassword)) {
+                    if (gatewayPassword != null && !gatewayPassword.isBlank()) {
                         getDevice().setGatewayPassword(gatewayPassword);
                     }
                     break;
                 case "privatePassword":
                     String privatePassword = (String) configuration.get("privatePassword");
-                    if (StringUtils.isNotBlank(privatePassword)) {
+                    if (privatePassword != null && !privatePassword.isBlank()) {
                         getDevice().setPrivatePassword(privatePassword);
                     }
                     break;
index 887a7dbbf799c94549c31e2351c6f4029f12fd4d..026076918ac32cc32871bf8bf11f9dde86ce936e 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
 
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.lametrictime.api.Configuration;
 import org.openhab.binding.lametrictime.api.LaMetricTime;
 import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
@@ -360,12 +359,12 @@ public class LaMetricTimeHandler extends ConfigStatusBridgeHandler {
         String host = config.host;
         String apiKey = config.apiKey;
 
-        if (StringUtils.isEmpty(host)) {
+        if (host == null || host.isEmpty()) {
             configStatusMessages.add(ConfigStatusMessage.Builder.error(HOST)
                     .withMessageKeySuffix(LaMetricTimeConfigStatusMessage.HOST_MISSING).withArguments(HOST).build());
         }
 
-        if (StringUtils.isEmpty(apiKey)) {
+        if (apiKey == null || apiKey.isEmpty()) {
             configStatusMessages.add(ConfigStatusMessage.Builder.error(API_KEY)
                     .withMessageKeySuffix(LaMetricTimeConfigStatusMessage.API_KEY_MISSING).withArguments(API_KEY)
                     .build());
index 4a1a3ce45572475a68e2e8cee85c80fab1d0f417..5bde94ae0741f49f616c9827ec6e89598c5c21fb 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.lutron.internal.config;
 
-import org.openhab.binding.lutron.internal.StringUtils;
+import java.util.Objects;
 
 /**
  * Configuration settings for an {@link org.openhab.binding.lutron.internal.handler.IPBridgeHandler}.
@@ -30,8 +30,8 @@ public class IPBridgeConfig {
     public int delay = 0;
 
     public boolean sameConnectionParameters(IPBridgeConfig config) {
-        return StringUtils.equals(ipAddress, config.ipAddress) && StringUtils.equals(user, config.user)
-                && StringUtils.equals(password, config.password) && (reconnect == config.reconnect)
+        return Objects.equals(ipAddress, config.ipAddress) && Objects.equals(user, config.user)
+                && Objects.equals(password, config.password) && (reconnect == config.reconnect)
                 && (heartbeat == config.heartbeat) && (delay == config.delay);
     }
 }
index e564ee5225c3767e1a07e0a91d4f66be515b632b..61c6cf4e9bae7f64d3f2f3954c683b5809b74c28 100644 (file)
@@ -25,7 +25,6 @@ import java.util.regex.MatchResult;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.openhab.binding.lutron.internal.StringUtils;
 import org.openhab.binding.lutron.internal.config.IPBridgeConfig;
 import org.openhab.binding.lutron.internal.discovery.LutronDeviceDiscoveryService;
 import org.openhab.binding.lutron.internal.net.TelnetSession;
@@ -156,7 +155,8 @@ public class IPBridgeHandler extends LutronBridgeHandler {
             return false;
         }
 
-        if (StringUtils.isEmpty(config.ipAddress)) {
+        String ipAddress = config.ipAddress;
+        if (ipAddress == null || ipAddress.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "bridge address not specified");
 
             return false;
index 9bcf43a95ca9e0423f2fbf2dc4eaece5116238b4..96a71d69fff65b80ede16ada1d7ffd9dd4ce3bb6 100644 (file)
@@ -21,7 +21,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.max.internal.Utils;
 import org.openhab.binding.max.internal.device.Device;
index 8927ac272f8a641f9162be3d733dee8d4351a1cd..c5ac9eed0fe6dcd64384895f9e054adf584b613d 100644 (file)
@@ -16,7 +16,7 @@ import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.max.internal.Utils;
 
index a90f9aaaae3c9d24c59cfae447b3cb0def59af22..a4b326e3874bba2d541de322312e11ef5b3df637 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.max.internal.Utils;
 import org.openhab.binding.max.internal.device.DeviceType;
@@ -278,7 +278,7 @@ public final class CMessage extends Message {
         logger.debug("RoomID:                   {}", roomId);
         for (String key : properties.keySet()) {
             if (!key.startsWith("Unknown")) {
-                String propertyName = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(key), ' ');
+                String propertyName = String.join(" ", StringUtils.splitByCharacterTypeCamelCase(key));
                 logger.debug("{}: {}", propertyName, properties.get(key));
             } else {
                 logger.debug("{}: {}", key, properties.get(key));
index dbfe3d76433ee27f7b20d7843dca355562695480..212525809b80613303523c38293c735de140dbc8 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.meteoblue.internal;
 
-import org.apache.commons.lang.StringUtils;
-
 /**
  * Model for the meteoblue binding configuration.
  *
@@ -64,15 +62,15 @@ public class MeteoBlueConfiguration {
         String a2 = split.length > 1 ? split[1] : null;
         String a3 = split.length > 2 ? split[2] : null;
 
-        if (!StringUtils.isBlank(a1)) {
+        if (a1 != null && !a1.isBlank()) {
             latitude = tryGetDouble(a1);
         }
 
-        if (!StringUtils.isBlank(a2)) {
+        if (a2 != null && !a2.isBlank()) {
             longitude = tryGetDouble(a2);
         }
 
-        if (!StringUtils.isBlank(a3)) {
+        if (a3 != null && !a3.isBlank()) {
             altitude = tryGetDouble(a3);
         }
     }
index beae447647649dbb59f4c54971da14eb3087c980..c74cbbb19b5b85cc50254c82a04368cd1c1e9a99 100644 (file)
@@ -17,7 +17,6 @@ import static org.openhab.binding.meteoblue.internal.MeteoBlueBindingConstants.T
 import java.util.Collections;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.meteoblue.internal.MeteoBlueBridgeConfig;
 import org.openhab.core.io.net.http.HttpUtil;
 import org.openhab.core.thing.Bridge;
@@ -55,7 +54,7 @@ public class MeteoBlueBridgeHandler extends BaseBridgeHandler {
 
         MeteoBlueBridgeConfig config = getConfigAs(MeteoBlueBridgeConfig.class);
         String apiKeyTemp = config.getApiKey();
-        if (StringUtils.isBlank(apiKeyTemp)) {
+        if (apiKeyTemp == null || apiKeyTemp.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Cannot initialize meteoblue bridge. No apiKey provided.");
             return;
index c35212c19cb1152fcbac2a5f6e97f74280b6ef91..eb62fa856b436543e1cf2928ce4b5cb79a95d65a 100644 (file)
@@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
 
 import javax.imageio.ImageIO;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.meteoblue.internal.Forecast;
 import org.openhab.binding.meteoblue.internal.MeteoBlueConfiguration;
 import org.openhab.binding.meteoblue.internal.json.JsonData;
@@ -97,13 +96,13 @@ public class MeteoBlueHandler extends BaseThingHandler {
 
         MeteoBlueConfiguration config = getConfigAs(MeteoBlueConfiguration.class);
 
-        if (StringUtils.isBlank(config.serviceType)) {
+        if (config.serviceType == null || config.serviceType.isBlank()) {
             config.serviceType = MeteoBlueConfiguration.SERVICETYPE_NONCOMM;
             logger.debug("Using default service type ({}).", config.serviceType);
             return;
         }
 
-        if (StringUtils.isBlank(config.location)) {
+        if (config.location == null || config.location.isBlank()) {
             flagBadConfig("The location was not configured.");
             return;
         }
@@ -315,7 +314,7 @@ public class MeteoBlueHandler extends BaseThingHandler {
         if (config.altitude != null) {
             builder.append("&asl=" + config.altitude);
         }
-        if (StringUtils.isNotBlank(config.timeZone)) {
+        if (config.timeZone != null && !config.timeZone.isBlank()) {
             builder.append("&tz=" + config.timeZone);
         }
         url = url.replace("#FORMAT_PARAMS#", builder.toString());
index a82acc26b2ed2dd0bdfd2b2437491b630c868356..b85ce8e11763d74e79475f52134b168b04fd847d 100644 (file)
@@ -20,7 +20,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.miele.internal.handler.ApplianceStatusListener;
 import org.openhab.binding.miele.internal.handler.MieleApplianceHandler;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler;
@@ -46,6 +45,9 @@ import com.google.gson.JsonElement;
  */
 public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener {
 
+    private static final String MIELE_APPLIANCE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance";
+    private static final String MIELE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.Miele";
+
     private final Logger logger = LoggerFactory.getLogger(MieleApplianceDiscoveryService.class);
 
     private static final int SEARCH_TIME = 60;
@@ -103,10 +105,9 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
             properties.put(APPLIANCE_ID, appliance.getApplianceId());
 
             for (JsonElement dc : appliance.DeviceClasses) {
-                if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
-                        && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
-                    properties.put(DEVICE_CLASS, StringUtils.right(dc.getAsString(), dc.getAsString().length()
-                            - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()));
+                String dcStr = dc.getAsString();
+                if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
+                    properties.put(DEVICE_CLASS, dcStr.substring(MIELE_CLASS.length()));
                     break;
                 }
             }
@@ -145,17 +146,16 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
         String modelID = null;
 
         for (JsonElement dc : appliance.DeviceClasses) {
-            if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
-                    && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
-                modelID = StringUtils.right(dc.getAsString(), dc.getAsString().length()
-                        - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
+            String dcStr = dc.getAsString();
+            if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
+                modelID = dcStr.substring(MIELE_CLASS.length());
                 break;
             }
         }
 
         if (modelID != null) {
             ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID,
-                    StringUtils.lowerCase(modelID.replaceAll("[^a-zA-Z0-9_]", "_")));
+                    modelID.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase());
 
             if (getSupportedThingTypes().contains(thingTypeUID)) {
                 ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getId());
index 8f0db9dd3c706ec016840696b10a829bef4bb852..87aa75fdf9b77c3f35f74d23a225b7be8889ba84 100644 (file)
@@ -20,7 +20,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation;
index 7306393008dbe27484c3510a6af6d58067e87229..6a992a125db080e928fbce5d62105862763671d1 100644 (file)
@@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.regex.Pattern;
 import java.util.zip.GZIPInputStream;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.core.common.NamedThreadFactory;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ChannelUID;
index 810a317cf1c972267557cafa7a3b31d337b84cc4..7f1e43fee6478561180d638a94ac772d84947883 100644 (file)
@@ -18,7 +18,7 @@ import java.util.Date;
 import java.util.Map.Entry;
 import java.util.TimeZone;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
 import org.openhab.core.library.types.DateTimeType;
 import org.openhab.core.library.types.DecimalType;
index 878a01d83bfed4384b0c0b9d14cb661aebd7d4c4..88138a9c05e1e1976aff21204a0775384aa64888 100644 (file)
@@ -21,7 +21,6 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.values.TextValue;
@@ -78,7 +77,7 @@ public class ChannelState implements MqttMessageSubscriber {
         this.channelStateUpdateListener = channelStateUpdateListener;
         this.channelUID = channelUID;
         this.cachedValue = cachedValue;
-        this.readOnly = StringUtils.isBlank(config.commandTopic);
+        this.readOnly = config.commandTopic.isBlank();
     }
 
     public boolean isReadOnly() {
@@ -242,7 +241,7 @@ public class ChannelState implements MqttMessageSubscriber {
      */
     public CompletableFuture<@Nullable Void> stop() {
         final MqttBrokerConnection connection = this.connection;
-        if (connection != null && StringUtils.isNotBlank(config.stateTopic)) {
+        if (connection != null && !config.stateTopic.isBlank()) {
             return connection.unsubscribe(config.stateTopic, this).thenRun(this::internalStop);
         } else {
             internalStop();
@@ -297,7 +296,7 @@ public class ChannelState implements MqttMessageSubscriber {
 
             this.connection = connection;
 
-            if (StringUtils.isBlank(config.stateTopic)) {
+            if (config.stateTopic.isBlank()) {
                 return CompletableFuture.completedFuture(null);
             }
 
index 3a991d9471f16d614dce74fda98577a9566bf82e..8cc05429ec1b652f440d61f73ddecd43bcb53fd1 100644 (file)
@@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.AbstractMQTTThingHandler;
@@ -164,9 +164,8 @@ public class GenericMQTTThingHandler extends AbstractMQTTThingHandler implements
                 Value value = ValueFactory.createValueState(channelConfig, channelTypeUID.getId());
                 ChannelState channelState = createChannelState(channelConfig, channel.getUID(), value);
                 channelStateByChannelUID.put(channel.getUID(), channelState);
-                StateDescription description = value
-                        .createStateDescription(StringUtils.isBlank(channelConfig.commandTopic)).build()
-                        .toStateDescription();
+                StateDescription description = value.createStateDescription(channelConfig.commandTopic.isBlank())
+                        .build().toStateDescription();
                 if (description != null) {
                     stateDescProvider.setDescription(channel.getUID(), description);
                 }
index 9b5f3aab601fc88ee2cc2ef2d53861e12c6428b5..1e4ffa3c0d9e42d0dc15dd1c1bab87c8842faa74 100644 (file)
  */
 package org.openhab.binding.mqtt.generic.values;
 
+import static java.util.function.Predicate.not;
+
 import java.util.Collections;
 import java.util.Set;
 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.core.library.CoreItemFactory;
@@ -45,7 +46,7 @@ public class TextValue extends Value {
      */
     public TextValue(String[] states) {
         super(CoreItemFactory.STRING, Collections.singletonList(StringType.class));
-        Set<String> s = Stream.of(states).filter(e -> StringUtils.isNotBlank(e)).collect(Collectors.toSet());
+        Set<String> s = Stream.of(states).filter(not(String::isBlank)).collect(Collectors.toSet());
         if (!s.isEmpty()) {
             this.states = s;
         } else {
index ff8002c07a2afc0809ff9eab0dfd2194484aa9f4..57e593e7b837c5cba5426b5bb185dcd1ea3bc323 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.mqtt.generic.values;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.mqtt.generic.ChannelConfig;
 import org.openhab.binding.mqtt.generic.internal.MqttBindingConstants;
@@ -35,7 +34,7 @@ public class ValueFactory {
         Value value;
         switch (channelTypeID) {
             case MqttBindingConstants.STRING:
-                value = StringUtils.isBlank(config.allowedStates) ? new TextValue()
+                value = config.allowedStates.isBlank() ? new TextValue()
                         : new TextValue(config.allowedStates.split(","));
                 break;
             case MqttBindingConstants.DATETIME:
index 8961fe6026eba768071a38116d902c60caaadfbd..f8862fc7dd6e8c0927255ae5248e31309c972b62 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Set;
 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.mqtt.generic.MqttChannelTypeProvider;
@@ -54,8 +53,8 @@ public class MqttThingHandlerFactory extends BaseThingHandlerFactory implements
     }
 
     private boolean isHomeassistantDynamicType(ThingTypeUID thingTypeUID) {
-        return StringUtils.equals(MqttBindingConstants.BINDING_ID, thingTypeUID.getBindingId())
-                && StringUtils.startsWith(thingTypeUID.getId(), MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId());
+        return MqttBindingConstants.BINDING_ID.equals(thingTypeUID.getBindingId())
+                && thingTypeUID.getId().startsWith(MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId());
     }
 
     @Activate
index 854de33b85d1779746d5bc2bd051b20359eb2d1c..bb17b03530cf1b7ce92cf1a62dbafda5a9f82d76 100644 (file)
@@ -16,7 +16,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.thing.Thing;
@@ -103,9 +102,9 @@ public abstract class BaseChannelConfiguration {
         protected @Nullable String name;
         protected @Nullable String sw_version;
 
-        @Nullable
-        public String getId() {
-            return StringUtils.join(identifiers, "_");
+        public @Nullable String getId() {
+            List<String> identifiers = this.identifiers;
+            return identifiers == null ? null : String.join("_", identifiers);
         }
     }
 
index 4eca5244e56ba911269bc2798813edbc4b155bad..cffc7027d25b0041f96402fc47faba3e110db8ca 100644 (file)
@@ -16,7 +16,6 @@ import java.net.URI;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ScheduledExecutorService;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.ChannelConfigBuilder;
@@ -149,9 +148,9 @@ public class CChannel {
 
         public Builder stateTopic(@Nullable String state_topic, @Nullable String... templates) {
             this.state_topic = state_topic;
-            if (StringUtils.isNotBlank(state_topic)) {
+            if (state_topic != null && !state_topic.isBlank()) {
                 for (String template : templates) {
-                    if (StringUtils.isNotBlank(template)) {
+                    if (template != null && !template.isBlank()) {
                         this.templateIn = template;
                         break;
                     }
@@ -204,7 +203,8 @@ public class CChannel {
                             .withCommandTopic(command_topic).makeTrigger(trigger).build(),
                     channelUID, valueState, channelStateUpdateListener);
 
-            if (StringUtils.isBlank(state_topic) || this.trigger) {
+            String localStateTopic = state_topic;
+            if (localStateTopic == null || localStateTopic.isBlank() || this.trigger) {
                 type = ChannelTypeBuilder.trigger(channelTypeUID, label)
                         .withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL)).build();
             } else {
index 563e39fe894216fe9ebacc387ea638a90c32fbec..5d61e981aeb87ed51561391297038215729a9266 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.mqtt.homeassistant.internal;
 import java.io.IOException;
 import java.lang.reflect.Field;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -119,7 +118,7 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
                         final String oldValue = (String) field.get(config);
 
                         String newValue = oldValue;
-                        if (StringUtils.isNotBlank(oldValue)) {
+                        if (oldValue != null && !oldValue.isBlank()) {
                             if (oldValue.charAt(0) == '~') {
                                 newValue = tilde + oldValue.substring(1);
                             } else if (oldValue.charAt(oldValue.length() - 1) == '~') {
index fb78f52358bac9a553fb70a8a0375e9f2bfb0e1a..aad866a2d155ed349c9595d2b880eab3a3e00f38 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.mqtt.homeassistant.internal;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.values.OnOffValue;
@@ -46,7 +45,7 @@ public class ComponentLock extends AbstractComponent<ComponentLock.ChannelConfig
         super(componentConfiguration, ChannelConfiguration.class);
 
         // We do not support all HomeAssistant quirks
-        if (channelConfiguration.optimistic && StringUtils.isNotBlank(channelConfiguration.state_topic)) {
+        if (channelConfiguration.optimistic && !channelConfiguration.state_topic.isBlank()) {
             throw new UnsupportedOperationException("Component:Lock does not support forced optimistic mode");
         }
 
index e3769c002868a133835098d0cbe414cfb1e67dee..2e18a3a2dd6f14848d129443b3766c8f441f95f7 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.mqtt.homeassistant.internal;
 import java.util.List;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener;
@@ -61,7 +60,7 @@ public class ComponentSensor extends AbstractComponent<ComponentSensor.ChannelCo
 
         String uom = channelConfiguration.unit_of_measurement;
 
-        if (uom != null && StringUtils.isNotBlank(uom)) {
+        if (uom != null && !uom.isBlank()) {
             value = new NumberValue(null, null, null, uom);
         } else {
             value = new TextValue();
index 3326572f65d401dc833b0edc4a5f5f38160cb072..87f179d132b270fb9539c6cbd4fbb889470bdc16 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.mqtt.homeassistant.internal;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.generic.values.OnOffValue;
@@ -52,9 +51,9 @@ public class ComponentSwitch extends AbstractComponent<ComponentSwitch.ChannelCo
         super(componentConfiguration, ChannelConfiguration.class);
 
         boolean optimistic = channelConfiguration.optimistic != null ? channelConfiguration.optimistic
-                : StringUtils.isBlank(channelConfiguration.state_topic);
+                : channelConfiguration.state_topic.isBlank();
 
-        if (optimistic && StringUtils.isNotBlank(channelConfiguration.state_topic)) {
+        if (optimistic && !channelConfiguration.state_topic.isBlank()) {
             throw new UnsupportedOperationException("Component:Switch does not support forced optimistic mode");
         }
 
index 48eba3bab940b71cfd4f31237911a1fdeac4d1c7..c7f895cd4557e74f6ff5bd5737872c896454b3ca 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.mqtt.homeassistant.internal;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.config.core.Configuration;
@@ -93,7 +92,7 @@ public class HaID {
     private static final String createTopic(HaID id) {
         StringBuilder str = new StringBuilder();
         str.append(id.baseTopic).append('/').append(id.component).append('/');
-        if (StringUtils.isNotBlank(id.nodeID)) {
+        if (!id.nodeID.isBlank()) {
             str.append(id.nodeID).append('/');
         }
         str.append(id.objectID).append('/');
@@ -175,7 +174,7 @@ public class HaID {
      */
     public String toShortTopic() {
         String objectID = this.objectID;
-        if (StringUtils.isNotBlank(nodeID)) {
+        if (!nodeID.isBlank()) {
             objectID = nodeID + "/" + objectID;
         }
 
@@ -192,10 +191,10 @@ public class HaID {
         String result = uniqueId;
 
         // the null test is only here so the compile knows, result is not null afterwards
-        if (result == null || StringUtils.isBlank(result)) {
+        if (result == null || result.isBlank()) {
             StringBuilder str = new StringBuilder();
 
-            if (StringUtils.isNotBlank(nodeID)) {
+            if (!nodeID.isBlank()) {
                 str.append(nodeID).append('_');
             }
             str.append(objectID).append('_').append(component);
index 91d803dd43a71dcb4ef4c42eba0c4f8a78663340..f26cd46b8407f603e83da4d33fbd8cf373de9caf 100644 (file)
@@ -19,7 +19,6 @@ import java.util.concurrent.TimeoutException;
 
 import javax.net.ssl.TrustManager;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.mqtt.internal.ssl.Pin;
@@ -60,10 +59,12 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
         super.connectionStateChanged(state, error);
         // Store generated client ID if none was set by the user
         final MqttBrokerConnection connection = this.connection;
-        if (connection != null && state == MqttConnectionState.CONNECTED && StringUtils.isBlank(config.clientID)) {
-            config.clientID = connection.getClientId();
+        String clientID = config.clientID;
+        if (connection != null && state == MqttConnectionState.CONNECTED && (clientID == null || clientID.isBlank())) {
+            clientID = connection.getClientId();
+            config.clientID = clientID;
             Configuration editConfig = editConfiguration();
-            editConfig.put("clientid", config.clientID);
+            editConfig.put("clientid", clientID);
             updateConfiguration(editConfig);
         }
     }
@@ -147,7 +148,7 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
         if (config.certificatepin) {
             try {
                 Pin pin;
-                if (StringUtils.isBlank(config.certificate)) {
+                if (config.certificate.isBlank()) {
                     pin = Pin.LearningPin(PinType.CERTIFICATE_TYPE);
                 } else {
                     String[] split = config.certificate.split(":");
@@ -165,7 +166,7 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
         if (config.publickeypin) {
             try {
                 Pin pin;
-                if (StringUtils.isBlank(config.publickey)) {
+                if (config.publickey.isBlank()) {
                     pin = Pin.LearningPin(PinType.PUBLIC_KEY_TYPE);
                 } else {
                     String[] split = config.publickey.split(":");
@@ -190,7 +191,7 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
      */
     protected MqttBrokerConnection createBrokerConnection() throws IllegalArgumentException {
         String host = config.host;
-        if (StringUtils.isBlank(host) || host == null) {
+        if (host == null || host.isBlank()) {
             throw new IllegalArgumentException("Host is empty!");
         }
 
@@ -199,7 +200,7 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
 
         final String username = config.username;
         final String password = config.password;
-        if (StringUtils.isNotBlank(username) && password != null) {
+        if (username != null && !username.isBlank() && password != null) {
             connection.setCredentials(username, password); // Empty passwords are allowed
         }
 
index ba355b733065a53be12163c504b0d7043d91d5e7..8cd011da807cd5cc200c494e63ed85274fcf2179 100644 (file)
@@ -17,7 +17,7 @@ import static org.openhab.binding.neato.internal.NeatoBindingConstants.*;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.openhab.binding.neato.internal.CouldNotFindRobotException;
 import org.openhab.binding.neato.internal.NeatoBindingConstants;
index 6dc3bfadcb87136fcacf683a818fe068dab20c29..444c32fc8fd6eb95718227a30dd7e8ef02836f32 100644 (file)
@@ -36,8 +36,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang3.SystemUtils;
 import org.apache.commons.net.util.SubnetUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -203,7 +202,7 @@ public class NetworkUtils {
      */
     public ArpPingUtilEnum determineNativeARPpingMethod(String arpToolPath) {
         String result = ExecUtil.executeCommandLineAndWaitResponse(Duration.ofMillis(100), arpToolPath, "--help");
-        if (StringUtils.isBlank(result)) {
+        if (result == null || result.isBlank()) {
             return ArpPingUtilEnum.UNKNOWN_TOOL;
         } else if (result.contains("Thomas Habets")) {
             if (result.matches("(?s)(.*)w sec Specify a timeout(.*)")) {
index 8c811681946266ce3aacc18a1b1439b009106a9f..0ef1c81010172efef36b3c69f8f5ac3484d2e8b6 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.nibeheatpump.internal.protocol;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
 
 /**
index d444245a255ba409a79250b8e95fdbd63c75d122..2c8e2f253ff6ac5c28f468da0d9cfe399143d222 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.nibeuplink.internal.config;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
index f968b1618b013f44565e7772e0766591de55f0f3..8b1f9b39700f1456bb192450bd88976e12fe7802 100644 (file)
@@ -21,7 +21,7 @@ import java.util.Arrays;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.oceanic.internal.NetworkOceanicBindingConfiguration;
index bb87024df73f3bd1ea0bb81f78ce810a8fa28e11..f9d54b8035826305733ea7b18c877bd1d88c2484 100644 (file)
@@ -19,7 +19,7 @@ import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Enumeration;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.oceanic.internal.SerialOceanicBindingConfiguration;
 import org.openhab.binding.oceanic.internal.Throttler;
 import org.openhab.core.thing.Thing;
index fc3bc89caa2ba868978d759451b7ec29ea60d1fb..9ef1d649965cdc72afb65249a69a286f84e6306c 100644 (file)
@@ -16,7 +16,7 @@ import java.io.IOException;
 import java.net.Socket;
 import java.nio.ByteBuffer;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
index 0425bac2a543bd17118632f441f6be23fdfe2bec..5309241591068c183827c318278f484208e2bfd7 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.onebusaway.internal.config;
 
 import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * The {@link ApiConfiguration} defines the model for a API bridge configuration.
index e5e5491086d50797bed1a02f39f17f1b56e16c18..d1158c6da96efe7ee0d05408559db0ae07b3d817 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.onebusaway.internal.config;
 
 import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.CHANNEL_CONFIG_OFFSET;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * The {@link ChannelConfig} defines the model for a channel configuration.
index 965a5585492dbf7f448c00ab7dc44e01df83242f..a4be8d16ba3b30d2091d37689adcaec6e9c145a1 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.onebusaway.internal.config;
 
 import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.ROUTE_CONFIG_ROUTE_ID;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * The {@link RouteConfiguration} defines the model for a route stop configuration.
index b799b823f8e9024bdc3388abdf3f645f76ec6585..488c00d005c2015e88fe20a05ba9597e42b619c1 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.onebusaway.internal.config;
 
 import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * The {@link StopConfiguration} defines the model for a stop bridge configuration.
index bbc8548c9a8bb7a381c7d6fd898184b16e7bb37d..7ee519735d57cafd560c31c27261c9e402b88f3d 100644 (file)
@@ -26,7 +26,6 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.onewiregpio.internal.OneWireGPIOBindingConstants;
 import org.openhab.binding.onewiregpio.internal.OneWireGpioConfiguration;
 import org.openhab.core.library.types.QuantityType;
@@ -94,7 +93,7 @@ public class OneWireGPIOHandler extends BaseThingHandler {
      * When invalid parameter is found, default value is assigned.
      */
     private boolean checkConfiguration() {
-        if (StringUtils.isEmpty(gpioBusFile)) {
+        if (gpioBusFile == null || gpioBusFile.isEmpty()) {
             logger.debug("GPIO_BUS_FILE not set. Please check configuration, and set proper path to w1_slave file.");
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "The path to the w1_slave sensor data file is missing.");
index 280b930351085de151dbe55f774315db886042da..a77136443604b857d152436efcdb63e71bb300bd 100644 (file)
@@ -20,7 +20,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.jupnp.model.meta.RemoteDevice;
@@ -64,7 +64,7 @@ public class OnkyoUpnpDiscoveryParticipant implements UpnpDiscoveryParticipant {
     protected void activate(ComponentContext componentContext) {
         if (componentContext.getProperties() != null) {
             String autoDiscoveryPropertyValue = (String) componentContext.getProperties().get("enableAutoDiscovery");
-            if (StringUtils.isNotEmpty(autoDiscoveryPropertyValue)) {
+            if (autoDiscoveryPropertyValue != null && !autoDiscoveryPropertyValue.isEmpty()) {
                 isAutoDiscoveryEnabled = Boolean.valueOf(autoDiscoveryPropertyValue);
             }
         }
@@ -81,8 +81,8 @@ public class OnkyoUpnpDiscoveryParticipant implements UpnpDiscoveryParticipant {
         DiscoveryResult result = null;
         ThingUID thingUid = getThingUID(device);
         if (thingUid != null) {
-            String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
-                    : device.getDetails().getFriendlyName();
+            String friendlyName = device.getDetails().getFriendlyName();
+            String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
             Map<String, Object> properties = new HashMap<>(2, 1);
             properties.put(HOST_PARAMETER, device.getIdentity().getDescriptorURL().getHost());
             properties.put(UDN_PARAMETER, device.getIdentity().getUdn().getIdentifierString());
@@ -97,13 +97,12 @@ public class OnkyoUpnpDiscoveryParticipant implements UpnpDiscoveryParticipant {
     public @Nullable ThingUID getThingUID(RemoteDevice device) {
         ThingUID result = null;
         if (isAutoDiscoveryEnabled) {
-            if (StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
-                    MANUFACTURER)) {
-                logger.debug("Manufacturer matched: search: {}, device value: {}.", MANUFACTURER,
-                        device.getDetails().getManufacturerDetails().getManufacturer());
-                if (StringUtils.containsIgnoreCase(device.getType().getType(), UPNP_DEVICE_TYPE)) {
-                    logger.debug("Device type matched: search: {}, device value: {}.", UPNP_DEVICE_TYPE,
-                            device.getType().getType());
+            String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+            if (manufacturer != null && manufacturer.toLowerCase().contains(MANUFACTURER.toLowerCase())) {
+                logger.debug("Manufacturer matched: search: {}, device value: {}.", MANUFACTURER, manufacturer);
+                String type = device.getType().getType();
+                if (type != null && type.toLowerCase().contains(UPNP_DEVICE_TYPE.toLowerCase())) {
+                    logger.debug("Device type matched: search: {}, device value: {}.", UPNP_DEVICE_TYPE, type);
 
                     String deviceModel = device.getDetails().getModelDetails() != null
                             ? device.getDetails().getModelDetails().getModelName()
@@ -143,7 +142,7 @@ public class OnkyoUpnpDiscoveryParticipant implements UpnpDiscoveryParticipant {
      * @return
      */
     private boolean isSupportedDeviceModel(final @Nullable String deviceModel) {
-        return StringUtils.isNotBlank(deviceModel) && Arrays.stream(OnkyoModel.values())
+        return deviceModel != null && !deviceModel.isBlank() && Arrays.stream(OnkyoModel.values())
                 .anyMatch(model -> StringUtils.startsWithIgnoreCase(deviceModel, model.getId()));
     }
 }
index 340aec98a3a2776bee45942e44c474ea422d028e..62eb39b16209c027eb0794e3c366df04e5457bc2 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.orvibo.internal.OrviboBindingConstants;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -102,7 +101,7 @@ public class SocketDiscoveryService extends AbstractDiscoveryService implements
     private DiscoveryResult createDiscoveryResult(Socket socket) {
         ThingUID thingUID = getUID(socket);
         String label = socket.getLabel();
-        if (StringUtils.isBlank(label)) {
+        if (label == null || label.isBlank()) {
             label = "S20";
         }
         return DiscoveryResultBuilder.create(thingUID).withLabel(label)
index add5b3d1e07542e7224bc1b00bb2bbe8aa8f6c8e..d8cdfa4b630a701bfc3474e5540c32acd7d16882 100644 (file)
@@ -18,7 +18,6 @@ import java.net.SocketException;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
@@ -98,7 +97,7 @@ public class S20Handler extends BaseThingHandler implements SocketStateListener
 
     @Override
     public void socketDidChangeLabel(Socket socket, String label) {
-        if (!StringUtils.isBlank(label)) {
+        if (label != null && !label.isBlank()) {
             logger.debug("Updating thing label to {}", label);
             thing.setLabel(label);
         }
index 52eba89e936efd126f67108e5e0568af84c870c3..28798ec6d0b3d472d44cdc732a311ae66ffb13ea 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.pentair.internal.config;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * Configuration parameters for IP Bridge
index 4e5f4d7d0d310cb586cf2e6651dd0d047e877514..86ada023a33c5f5585d2a75a85f3b9662391ecc4 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.pentair.internal.config;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * Configuration parameters for Serial Bridge
index cd637b52b40c1ae173e9df1a5fa1fb3d40c92126..f5f20a4d2df5bc35ef0db68bbdcd41ff9765eee4 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.phc.internal;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
index 77c1fd304055648dd0a3d8bfd92621abdba09852..d4c0ceb14ee681b1bf7890b4973abfab60781170 100644 (file)
@@ -24,7 +24,7 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.phc.internal.PHCBindingConstants;
index 95d157028da873d1f4935a5a31c81c421ab414ab..ecafae9e21dfec0238d754264e5c6ef333d942f2 100644 (file)
@@ -17,7 +17,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.jupnp.model.meta.RemoteDevice;
 import org.openhab.binding.pioneeravr.internal.PioneerAvrBindingConstants;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -58,7 +57,7 @@ public class PioneerAvrDiscoveryParticipant implements UpnpDiscoveryParticipant
     protected void activate(ComponentContext componentContext) {
         if (componentContext.getProperties() != null) {
             String autoDiscoveryPropertyValue = (String) componentContext.getProperties().get("enableAutoDiscovery");
-            if (StringUtils.isNotEmpty(autoDiscoveryPropertyValue)) {
+            if (autoDiscoveryPropertyValue != null && !autoDiscoveryPropertyValue.isEmpty()) {
                 isAutoDiscoveryEnabled = Boolean.valueOf(autoDiscoveryPropertyValue);
             }
         }
@@ -76,8 +75,8 @@ public class PioneerAvrDiscoveryParticipant implements UpnpDiscoveryParticipant
         DiscoveryResult result = null;
         ThingUID thingUid = getThingUID(device);
         if (thingUid != null) {
-            String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
-                    : device.getDetails().getFriendlyName();
+            String friendlyName = device.getDetails().getFriendlyName();
+            String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
             Map<String, Object> properties = new HashMap<>(2, 1);
             properties.put(PioneerAvrBindingConstants.HOST_PARAMETER,
                     device.getIdentity().getDescriptorURL().getHost());
@@ -93,15 +92,16 @@ public class PioneerAvrDiscoveryParticipant implements UpnpDiscoveryParticipant
     public ThingUID getThingUID(RemoteDevice device) {
         ThingUID result = null;
         if (isAutoDiscoveryEnabled) {
-            if (StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
-                    PioneerAvrBindingConstants.MANUFACTURER)) {
+            String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+            if (manufacturer != null
+                    && manufacturer.toLowerCase().contains(PioneerAvrBindingConstants.MANUFACTURER.toLowerCase())) {
                 logger.debug("Manufacturer matched: search: {}, device value: {}.",
-                        PioneerAvrBindingConstants.MANUFACTURER,
-                        device.getDetails().getManufacturerDetails().getManufacturer());
-                if (StringUtils.containsIgnoreCase(device.getType().getType(),
-                        PioneerAvrBindingConstants.UPNP_DEVICE_TYPE)) {
+                        PioneerAvrBindingConstants.MANUFACTURER, manufacturer);
+                String type = device.getType().getType();
+                if (type != null
+                        && type.toLowerCase().contains(PioneerAvrBindingConstants.UPNP_DEVICE_TYPE.toLowerCase())) {
                     logger.debug("Device type matched: search: {}, device value: {}.",
-                            PioneerAvrBindingConstants.UPNP_DEVICE_TYPE, device.getType().getType());
+                            PioneerAvrBindingConstants.UPNP_DEVICE_TYPE, type);
 
                     String deviceModel = device.getDetails().getModelDetails() != null
                             ? device.getDetails().getModelDetails().getModelName()
@@ -150,7 +150,7 @@ public class PioneerAvrDiscoveryParticipant implements UpnpDiscoveryParticipant
      * @return
      */
     private boolean isSupportedDeviceModel(String deviceModel, Set<String> supportedDeviceModels) {
-        return StringUtils.isNotBlank(deviceModel) && supportedDeviceModels.stream()
-                .anyMatch(input -> StringUtils.startsWithIgnoreCase(deviceModel, input));
+        return deviceModel != null && !deviceModel.isBlank() && supportedDeviceModels.stream()
+                .anyMatch(input -> deviceModel.toLowerCase().startsWith(input.toLowerCase()));
     }
 }
index edf2fd842f566405bf7789a32a70f5bac07f12a6..8502eef1cd286ccb61f0eda6e44f102b48e21962 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.pioneeravr.internal.protocol;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrCommand;
 import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrConnectionException;
 
@@ -72,7 +71,7 @@ public class ParameterizedCommand extends SimpleCommand {
                     "The parameter of the command " + super.getCommand() + " must not be null.");
         }
 
-        if (StringUtils.isNotEmpty(parameterPattern) && !parameter.matches(parameterPattern)) {
+        if (parameterPattern != null && !parameterPattern.isEmpty() && !parameter.matches(parameterPattern)) {
             throw new AvrConnectionException("The parameter value " + parameter + " of the command "
                     + super.getCommand() + " does not match the pattern " + parameterPattern);
         }
index 238ace9368d8a5d1b423eaa8f2df1cdd08382d88..e3b64497be23275417a53c3b5034bb7ce7832b98 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.pioneeravr.internal.protocol;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrConnectionException;
 import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrResponse;
 
@@ -41,11 +41,11 @@ public class Response implements AvrResponse {
 
         private String[] responsePrefixZone;
 
-        private String parameterPattern;
+        private @Nullable String parameterPattern;
 
         private Pattern[] matchPatternZone;
 
-        private ResponseType(String parameterPattern, String... responsePrefixZone) {
+        private ResponseType(@Nullable String parameterPattern, String... responsePrefixZone) {
             this.responsePrefixZone = responsePrefixZone;
             this.parameterPattern = parameterPattern;
 
@@ -53,8 +53,8 @@ public class Response implements AvrResponse {
 
             for (int zoneIndex = 0; zoneIndex < responsePrefixZone.length; zoneIndex++) {
                 String responsePrefix = responsePrefixZone[zoneIndex];
-                matchPatternZone[zoneIndex] = Pattern.compile(responsePrefix + "("
-                        + (StringUtils.isNotEmpty(parameterPattern) ? parameterPattern : "") + ")");
+                matchPatternZone[zoneIndex] = Pattern
+                        .compile(responsePrefix + "(" + (parameterPattern == null ? "" : parameterPattern) + ")");
             }
         }
 
@@ -65,11 +65,11 @@ public class Response implements AvrResponse {
 
         @Override
         public boolean hasParameter() {
-            return StringUtils.isNotEmpty(parameterPattern);
+            return parameterPattern != null && !parameterPattern.isEmpty();
         }
 
         @Override
-        public String getParameterPattern() {
+        public @Nullable String getParameterPattern() {
             return parameterPattern;
         }
 
@@ -115,7 +115,7 @@ public class Response implements AvrResponse {
     private String parameter;
 
     public Response(String responseData) throws AvrConnectionException {
-        if (StringUtils.isEmpty(responseData)) {
+        if (responseData == null || responseData.isEmpty()) {
             throw new AvrConnectionException("responseData is empty. Cannot parse the response.");
         }
 
index da90e461733d2057a8c845720c380c0cd4db48fb..64cfd0901a7571716913e3adb78dd56a9522b3be 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.pioneeravr.internal.protocol.avr;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.pioneeravr.internal.protocol.Response.ResponseType;
 
 /**
@@ -46,7 +47,7 @@ public interface AvrResponse {
          *
          * @return
          */
-        public String getParameterPattern();
+        public @Nullable String getParameterPattern();
 
         /**
          * Return the zone number if the responseData matches a zone of this responseType.
index 94660067e4573d7890e054c3ea59736faf48ddd2..3cfefd88838865189e986d1d69574f307ba3d4c8 100644 (file)
@@ -22,7 +22,7 @@ import java.util.TooManyListenersException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.plugwise.internal.protocol.AcknowledgementMessage;
index c58e42b9c6e33d2522f2fd52c49819fd86e58009..eb6d7e5cdbe5867c401f6f8640bc87eb21400c86 100644 (file)
@@ -20,8 +20,8 @@ import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.WordUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.plugwise.internal.protocol.InformationResponseMessage;
index 39fa310c252698a775f3ef5c8c9cae4fc1de4c97..80c61f6fae23013e11cee25f5658ee60998a0e9e 100644 (file)
@@ -25,7 +25,6 @@ import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.pulseaudio.internal.cli.Parser;
 import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig;
 import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig.State;
@@ -442,7 +441,7 @@ public class PulseaudioClient {
         sendRawCommand(CMD_UNLOAD_MODULE + " " + combinedSink.getModule().getId());
         // 2. add new combined-sink with same name and all slaves
         sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSink.getPaName()
-                + " slaves=" + StringUtils.join(slaves, ","));
+                + " slaves=" + String.join(",", slaves));
         // 3. update internal data structure because the combined sink has a new number + other slaves
         update();
     }
@@ -533,7 +532,7 @@ public class PulseaudioClient {
         }
         // add new combined-sink with same name and all slaves
         sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSinkName + " slaves="
-                + StringUtils.join(slaves, ","));
+                + String.join(",", slaves));
         // update internal data structure because the combined sink is new
         update();
     }
index 357523051680a3baaa4cf21a79a24d7304fe80bd..1b8f1d63a52a09f50c8fd8e0ef43ec8cae53c2d3 100644 (file)
@@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig;
 import org.openhab.binding.pulseaudio.internal.items.Sink;
 import org.openhab.binding.pulseaudio.internal.items.SinkInput;
@@ -244,8 +243,7 @@ public class PulseaudioHandler extends BaseThingHandler implements DeviceStatusL
                                 : new StringType("-"));
             }
             if (device instanceof Sink && ((Sink) device).isCombinedSink()) {
-                updateState(SLAVES_CHANNEL,
-                        new StringType(StringUtils.join(((Sink) device).getCombinedSinkNames(), ",")));
+                updateState(SLAVES_CHANNEL, new StringType(String.join(",", ((Sink) device).getCombinedSinkNames())));
             }
         }
     }
index 09b7fe731a0f5aeba3abcde88899717838c70d2a..a95dfd7d175ee018f75f42212cbcd1c6f8303cb9 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.rme.internal.handler;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.rme.internal.RMEBindingConstants.DataField;
 import org.openhab.core.io.transport.serial.SerialPortManager;
 import org.openhab.core.library.types.DecimalType;
index c8582ae05551984cce282f0f83abe7477f461734..1f3f0e6b91c8c6e469eaa94eafa882d07fc69d1c 100644 (file)
@@ -18,7 +18,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.api.Authentication;
 import org.eclipse.jetty.client.api.AuthenticationStore;
@@ -142,14 +141,17 @@ public class RobonectClient {
             this.value = value;
         }
 
+        @Override
         public URI getURI() {
             return this.uri;
         }
 
+        @Override
         public void apply(Request request) {
             request.header(this.header, this.value);
         }
 
+        @Override
         public String toString() {
             return String.format("Basic authentication result for %s", this.uri);
         }
@@ -291,7 +293,7 @@ public class RobonectClient {
             String responseString = null;
 
             // jetty uses UTF-8 as default encoding. However, HTTP 1.1 specifies ISO_8859_1
-            if (StringUtils.isBlank(response.getEncoding())) {
+            if (response.getEncoding() == null || response.getEncoding().isBlank()) {
                 responseString = new String(response.getContent(), StandardCharsets.ISO_8859_1);
             } else {
                 // currently v0.9e Robonect does not specifiy the encoding. But if later versions will
index bb418b6662a1c2b1556c22cd8545da1e91c11b9a..dc418c9c54e0bd9313c382ca0829971c6f12258f 100644 (file)
@@ -16,7 +16,7 @@ import java.io.IOException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.russound.internal.RussoundHandlerFactory;
 import org.openhab.binding.russound.internal.net.SocketChannelSession;
 import org.openhab.binding.russound.internal.net.SocketSession;
@@ -148,7 +148,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
     private void discoverControllers() {
         for (int c = 1; c < 7; c++) {
             final String type = sendAndGet("GET C[" + c + "].type", RSP_CONTROLLERNOTIFICATION, 3);
-            if (StringUtils.isNotEmpty(type)) {
+            if (type != null && !type.isEmpty()) {
                 logger.debug("Controller #{} found - {}", c, type);
 
                 final ThingUID thingUID = new ThingUID(RioConstants.BRIDGE_TYPE_CONTROLLER,
@@ -172,7 +172,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
     private void discoverSources() {
         for (int s = 1; s < 9; s++) {
             final String type = sendAndGet("GET S[" + s + "].type", RSP_SRCNOTIFICATION, 3);
-            if (StringUtils.isNotEmpty(type)) {
+            if (type != null && !type.isEmpty()) {
                 final String name = sendAndGet("GET S[" + s + "].name", RSP_SRCNOTIFICATION, 3);
                 logger.debug("Source #{} - {}/{}", s, type, name);
 
@@ -181,8 +181,8 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
 
                 final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
                         .withProperty(RioSourceConfig.SOURCE, s).withBridge(sysHandler.getThing().getUID())
-                        .withLabel((StringUtils.isEmpty(name) || name.equalsIgnoreCase("null") ? "Source" : name) + " ("
-                                + s + ")")
+                        .withLabel((name == null || name.isEmpty() || name.equalsIgnoreCase("null") ? "Source" : name)
+                                + " (" + s + ")")
                         .build();
                 thingDiscovered(discoveryResult);
             }
@@ -207,7 +207,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
         }
         for (int z = 1; z < 9; z++) {
             final String name = sendAndGet("GET C[" + c + "].Z[" + z + "].name", RSP_ZONENOTIFICATION, 4);
-            if (StringUtils.isNotEmpty(name)) {
+            if (name != null && !name.isEmpty()) {
                 logger.debug("Controller #{}, Zone #{} found - {}", c, z, name);
 
                 final ThingUID thingUID = new ThingUID(RioConstants.THING_TYPE_ZONE, controllerUID, String.valueOf(z));
@@ -232,8 +232,8 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
      * @throws IllegalArgumentException if message is null or empty, if the pattern is null
      * @throws IllegalArgumentException if groupNum is less than 0
      */
-    private String sendAndGet(String message, Pattern respPattern, int groupNum) {
-        if (StringUtils.isEmpty(message)) {
+    private @Nullable String sendAndGet(String message, Pattern respPattern, int groupNum) {
+        if (message == null || message.isEmpty()) {
             throw new IllegalArgumentException("message cannot be a null or empty string");
         }
         if (respPattern == null) {
index c1efcf390c9749940fbc1fe2799bf90c672dbd25..a34f0b54b453e9e8a606b62f0f49ae09af052428 100644 (file)
@@ -26,7 +26,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.net.util.SubnetUtils;
 import org.openhab.binding.russound.internal.net.SocketChannelSession;
 import org.openhab.binding.russound.internal.net.SocketSession;
@@ -152,7 +151,7 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
      * @param ipAddress a possibly null, possibly empty ip address (null/empty addresses will be ignored)
      */
     private void scanAddress(String ipAddress) {
-        if (StringUtils.isEmpty(ipAddress)) {
+        if (ipAddress == null || ipAddress.isEmpty()) {
             return;
         }
 
@@ -175,7 +174,7 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
                     continue;
                 }
                 final String type = resp.substring(13, resp.length() - 1);
-                if (!StringUtils.isBlank(type)) {
+                if (!type.isBlank()) {
                     logger.debug("Found a RIO type #{}", type);
                     addResult(ipAddress, type);
                     break;
@@ -202,10 +201,10 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
      * @throws IllegalArgumentException if ipaddress or type is null or empty
      */
     private void addResult(String ipAddress, String type) {
-        if (StringUtils.isEmpty(ipAddress)) {
+        if (ipAddress == null || ipAddress.isEmpty()) {
             throw new IllegalArgumentException("ipAddress cannot be null or empty");
         }
-        if (StringUtils.isEmpty(type)) {
+        if (type == null || type.isEmpty()) {
             throw new IllegalArgumentException("type cannot be null or empty");
         }
 
index 3cc3cf9ff80675aeb536f61794255c521528f83d..2790d065b046a9ce5cd4fc832210f2d2784911a7 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.russound.internal.rio;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.core.library.types.StringType;
@@ -165,7 +164,7 @@ public abstract class AbstractBridgeHandler<E extends AbstractRioProtocol> exten
         if (clazz == null) {
             throw new IllegalArgumentException("clazz cannot be null");
         }
-        if (StringUtils.isEmpty(channelId)) {
+        if (channelId == null || channelId.isEmpty()) {
             throw new IllegalArgumentException("channelId cannot be null or empty");
         }
 
index b7af1c4b68455c60a8d4e7458a66c0b533928d07..ee9339f954c46dba1a9929e7a379afafc1342b27 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.russound.internal.rio;
 
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.types.State;
 
 /**
@@ -56,7 +55,7 @@ public abstract class AbstractRioHandlerCallback implements RioHandlerCallback {
      * @throws IllegalArgumentException if state is null
      */
     protected void fireStateUpdated(String channelId, State state) {
-        if (StringUtils.isEmpty(channelId)) {
+        if (channelId == null || channelId.isEmpty()) {
             throw new IllegalArgumentException("channelId cannot be null or empty)");
         }
         if (state == null) {
index 20116794feff64dba880ef17ac1be91e07696c0b..0b9b5cfae0bce0bbe6abda395895c52aef6d0f16 100644 (file)
@@ -14,13 +14,14 @@ package org.openhab.binding.russound.internal.rio;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.binding.russound.internal.rio.models.GsonUtilities;
@@ -258,7 +259,7 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
      * @throws IllegalArgumentException if source is < 1 or > 8
      * @throws IllegalArgumentException if presetJson contains more than one preset
      */
-    public void setZonePresets(int controller, int zone, int source, String presetJson) {
+    public void setZonePresets(int controller, int zone, int source, @Nullable String presetJson) {
         if (controller < 1 || controller > 6) {
             throw new IllegalArgumentException("Controller must be between 1 and 6");
         }
@@ -271,7 +272,7 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
             throw new IllegalArgumentException("Source must be between 1 and 8");
         }
 
-        if (StringUtils.isEmpty(presetJson)) {
+        if (presetJson == null || presetJson.isEmpty()) {
             return;
         }
 
@@ -299,11 +300,11 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
 
                     // re-retrieve to see if the save/delete worked (saving on a zone that's off - valid won't be set to
                     // true)
-                    if (!StringUtils.equals(myPreset.getName(), presetName) || myPreset.isValid() != presetValid) {
+                    if (!Objects.equals(myPreset.getName(), presetName) || myPreset.isValid() != presetValid) {
                         myPreset.setName(presetName);
                         myPreset.setValid(presetValid);
                         if (presetValid) {
-                            if (StringUtils.isEmpty(presetName)) {
+                            if (presetName == null || presetName.isEmpty()) {
                                 sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!savePreset " + presetId);
                             } else {
                                 sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!savePreset \"" + presetName
@@ -438,8 +439,8 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
      * @param a possibly null, possibly empty response
      */
     @Override
-    public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+    public void responseReceived(@Nullable String response) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index 3fa4dba7019392540195d365b3f9fa6b8fc199c2..cea05bdb66b93fba098584abfb1a50d981e512e4 100644 (file)
@@ -14,13 +14,14 @@ package org.openhab.binding.russound.internal.rio;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.binding.russound.internal.rio.models.GsonUtilities;
@@ -199,7 +200,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
      * @throws IllegalArgumentException if controller is < 1 or > 6
      * @throws IllegalArgumentException if zone is < 1 or > 8
      */
-    public void setSystemFavorites(int controller, int zone, String favJson) {
+    public void setSystemFavorites(int controller, int zone, @Nullable String favJson) {
         if (controller < 1 || controller > 6) {
             throw new IllegalArgumentException("Controller must be between 1 and 6");
         }
@@ -208,7 +209,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
             throw new IllegalArgumentException("Zone must be between 1 and 8");
         }
 
-        if (StringUtils.isEmpty(favJson)) {
+        if (favJson == null || favJson.isEmpty()) {
             return;
         }
 
@@ -242,7 +243,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
                         } else {
                             sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!deleteSystemFavorite " + favId);
                         }
-                    } else if (!StringUtils.equals(myFav.getName(), favName)) {
+                    } else if (!Objects.equals(myFav.getName(), favName)) {
                         myFav.setName(favName);
                         sendCommand("SET System.favorite[" + favId + "]." + FAV_NAME + "=\"" + favName + "\"");
                     }
@@ -311,8 +312,8 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
      * @param a possibly null, possibly empty response
      */
     @Override
-    public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+    public void responseReceived(@Nullable String response) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index e34fc6d80c5f2ab1ea48102e51f532cb718c46e3..e68159458b0dbb07175ef15eb02d5ce620826aad 100644 (file)
@@ -17,7 +17,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.thing.ThingStatus;
 import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.types.State;
@@ -89,7 +88,7 @@ public class StatefulHandlerCallback implements RioHandlerCallback {
      */
     @Override
     public void stateChanged(String channelId, State newState) {
-        if (StringUtils.isEmpty(channelId)) {
+        if (channelId == null || channelId.isEmpty()) {
             return;
         }
 
@@ -117,7 +116,7 @@ public class StatefulHandlerCallback implements RioHandlerCallback {
      * @param channelId the channel id to remove state
      */
     public void removeState(String channelId) {
-        if (StringUtils.isEmpty(channelId)) {
+        if (channelId == null || channelId.isEmpty()) {
             return;
         }
         state.remove(channelId);
index e3a006ce9de7203d84061e37c99e21406f268b72..2913ef687cd21062d18a0f16f10768e488ee8e75 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.controller;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
@@ -155,8 +155,8 @@ class RioControllerProtocol extends AbstractRioProtocol {
      * @param a possibly null, possibly empty response
      */
     @Override
-    public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+    public void responseReceived(@Nullable String response) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index 345b5f7bec51da4402163e3a128dfaa90e822e7f..dfc7eba0db5d1cb45d6488c5e6cff25433e49cd1 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.russound.internal.rio.models;
 
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * Simple model of a RIO Bank and it's attributes. Please note this class is used to serialize/deserialize to JSON.
@@ -50,12 +50,12 @@ public class RioBank {
      * @param name a possibly null, possibly empty bank name (null or empty will result in a bank name of "Bank "+ id)
      * @throws IllegalArgumentException if id is < 1 or > 6
      */
-    public RioBank(int id, String name) {
+    public RioBank(int id, @Nullable String name) {
         if (id < 1 || id > 6) {
             throw new IllegalArgumentException("Bank ID can only be between 1 and 6");
         }
         this.id = id;
-        this.name.set(StringUtils.isEmpty(name) ? "Bank " + id : name);
+        this.name.set(name == null || name.isEmpty() ? "Bank " + id : name);
     }
 
     /**
@@ -81,7 +81,7 @@ public class RioBank {
      *
      * @param bankName a possibly null, possibly empty bank name
      */
-    public void setName(String bankName) {
-        name.set(StringUtils.isEmpty(bankName) ? "Bank " + getId() : bankName);
+    public void setName(@Nullable String bankName) {
+        name.set(bankName == null || bankName.isEmpty() ? "Bank " + getId() : bankName);
     }
 }
index cc982e4e851bb9b6efccde967359fb30ad9e65b8..53d3548ba4b6c4c72315972765be7b340918f75a 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.models;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * Simple model of a RIO Favorite (both system and zone) and it's attributes. Please note this class is used to
@@ -59,18 +59,14 @@ public class RioFavorite {
      * @param name a possibly null, possibly empty favorite name
      * @throws IllegalArgumentException if id < 1 or > 32
      */
-    public RioFavorite(int id, boolean isValid, String name) {
+    public RioFavorite(int id, boolean isValid, @Nullable String name) {
         if (id < 1 || id > 32) {
             throw new IllegalArgumentException("Favorite ID must be between 1 and 32");
         }
 
-        if (StringUtils.isEmpty(name)) {
-            name = "Favorite " + id;
-        }
-
         this.id = id;
         this.valid.set(isValid);
-        this.name.set(name);
+        this.name.set(name == null || name.isEmpty() ? "Favorite " + id : name);
     }
 
     /**
@@ -105,8 +101,8 @@ public class RioFavorite {
      *
      * @param favName a possibly null, possibly empty favorite name
      */
-    public void setName(String favName) {
-        name.set(StringUtils.isEmpty(favName) ? "Favorite " + getId() : favName);
+    public void setName(@Nullable String favName) {
+        name.set(favName == null || favName.isEmpty() ? "Favorite " + getId() : favName);
     }
 
     /**
index a6820696bb814d6f5557fe3b80869959d14abfd5..96d7b8f2596207eceaf9d6b662e9daf49d9a8ccd 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.models;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * Simple model of a RIO Preset and it's attributes. Please note this class is used to
@@ -59,18 +59,14 @@ public class RioPreset {
      * @param name a possibly null, possibly empty preset name
      * @throws IllegalArgumentException if id < 1 or > 32
      */
-    public RioPreset(int id, boolean valid, String name) {
+    public RioPreset(int id, boolean valid, @Nullable String name) {
         if (id < 1 || id > 36) {
             throw new IllegalArgumentException("Preset ID can only be between 1 and 36");
         }
 
-        if (StringUtils.isEmpty(name)) {
-            name = "Preset " + id;
-        }
-
         this.id = id;
         this.valid.set(valid);
-        this.name.set(name);
+        this.name.set(name == null || name.isEmpty() ? "Preset " + id : name);
     }
 
     /**
@@ -123,8 +119,8 @@ public class RioPreset {
      *
      * @param presetName a possibly null, possibly empty preset name
      */
-    public void setName(String presetName) {
-        name.set(StringUtils.isEmpty(presetName) ? "Preset " + getId() : presetName);
+    public void setName(@Nullable String presetName) {
+        name.set(presetName == null || presetName.isEmpty() ? "Preset " + getId() : presetName);
     }
 
     /**
index 2ab342eb31bff921a19cc5ea26011e56b3f6c725..5ca7dc53daaa7b8213287007601174bc5be4f5d4 100644 (file)
@@ -16,7 +16,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.rio.AbstractRioHandlerCallback;
 import org.openhab.binding.russound.internal.rio.AbstractThingHandler;
@@ -84,7 +83,7 @@ public class RioSourceHandler extends AbstractThingHandler<RioSourceProtocol> im
     @Override
     public String getName() {
         final String name = sourceName.get();
-        return StringUtils.isEmpty(name) ? ("Source " + getId()) : name;
+        return name == null || name.isEmpty() ? "Source " + getId() : name;
     }
 
     /**
index 4f5b02969a7566e997d075f09ec24cbd907af086..755f987db75c7a1cd7571615401677eddb7faec5 100644 (file)
@@ -15,14 +15,14 @@ package org.openhab.binding.russound.internal.rio.source;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.NullArgumentException;
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
@@ -367,7 +367,7 @@ class RioSourceProtocol extends AbstractRioProtocol {
      */
     Runnable setBanks(String bankJson) {
         // If null or empty - simply return a do nothing runnable
-        if (StringUtils.isEmpty(bankJson)) {
+        if (bankJson == null || bankJson.isEmpty()) {
             return () -> {
             };
         }
@@ -387,7 +387,7 @@ class RioSourceProtocol extends AbstractRioProtocol {
                 } else {
                     final RioBank myBank = banks[bankId - 1];
 
-                    if (!StringUtils.equals(myBank.getName(), bank.getName())) {
+                    if (!Objects.equals(myBank.getName(), bank.getName())) {
                         myBank.setName(bank.getName());
                         sendCommand(
                                 "SET S[" + source + "].B[" + bankId + "]." + BANK_NAME + "=\"" + bank.getName() + "\"");
@@ -431,8 +431,8 @@ class RioSourceProtocol extends AbstractRioProtocol {
      * @throws IllegalArgumentException if channelID is null or empty
      */
     private void handleMMChange(String channelId, String value) {
-        if (StringUtils.isEmpty(channelId)) {
-            throw new NullArgumentException("channelId cannot be null or empty");
+        if (channelId == null || channelId.isEmpty()) {
+            throw new IllegalArgumentException("channelId cannot be null or empty");
         }
 
         final AtomicInteger ai = mmSeqNbrs.get(channelId);
@@ -688,8 +688,8 @@ class RioSourceProtocol extends AbstractRioProtocol {
      * @param a possibly null, possibly empty response
      */
     @Override
-    public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+    public void responseReceived(@Nullable String response) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index 2badcb8f5c5825958816853dff805200263d21bd..edd990e1a57056f4de7a6ea355ccc6a695ca5027 100644 (file)
@@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
@@ -245,8 +245,8 @@ class RioSystemProtocol extends AbstractRioProtocol {
      * @param a possibly null, possibly empty response
      */
     @Override
-    public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+    public void responseReceived(@Nullable String response) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index 3fcaa5e7f24199883d183490fbaad63c402968cf..23832a19db1c00f1eb54b8b1a67a0b8135a673e3 100644 (file)
@@ -16,7 +16,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.rio.AbstractBridgeHandler;
 import org.openhab.binding.russound.internal.rio.AbstractRioHandlerCallback;
@@ -108,7 +107,7 @@ public class RioZoneHandler extends AbstractThingHandler<RioZoneProtocol>
     @Override
     public String getName() {
         final String name = zoneName.get();
-        return StringUtils.isEmpty(name) ? ("Zone " + getId()) : name;
+        return name == null || name.isEmpty() ? "Zone " + getId() : name;
     }
 
     /**
index 02e85516ef5332bf73e43c7121d57d317d829b2f..5749f19b4e33aa82589a5a3668b2ce1f972bd40d 100644 (file)
@@ -14,11 +14,11 @@ package org.openhab.binding.russound.internal.rio.zone;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.russound.internal.net.SocketSession;
 import org.openhab.binding.russound.internal.net.SocketSessionListener;
 import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
@@ -529,7 +529,7 @@ class RioZoneProtocol extends AbstractRioProtocol
      * @return a non-null {@link Runnable} that should be run after the call
      */
     Runnable setZoneFavorites(String favJson) {
-        if (StringUtils.isEmpty(favJson)) {
+        if (favJson.isEmpty()) {
             return () -> {
             };
         }
@@ -550,7 +550,7 @@ class RioZoneProtocol extends AbstractRioProtocol
                     final boolean favValid = fav.isValid();
                     final String favName = fav.getName();
 
-                    if (!StringUtils.equals(myFav.getName(), favName) || myFav.isValid() != favValid) {
+                    if (!Objects.equals(myFav.getName(), favName) || myFav.isValid() != favValid) {
                         myFav.setName(favName);
                         myFav.setValid(favValid);
                         if (favValid) {
@@ -923,7 +923,7 @@ class RioZoneProtocol extends AbstractRioProtocol
      */
     @Override
     public void responseReceived(String response) {
-        if (StringUtils.isEmpty(response)) {
+        if (response == null || response.isEmpty()) {
             return;
         }
 
index c6d44986943e9c6a4d638edb41eba621e0bb2ee5..bf5a85edae31eeb32e281e1f86434f4cfaa5b1db 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.satel.internal.command;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.satel.internal.protocol.SatelMessage;
-import org.openhab.binding.satel.internal.util.StringUtils;
 
 /**
  * Base class for all commands that return result code in the response.
@@ -59,7 +58,7 @@ public abstract class ControlCommand extends SatelCommandBase {
     }
 
     protected static byte[] userCodeToBytes(String userCode) {
-        if (StringUtils.isEmpty(userCode)) {
+        if (userCode.isEmpty()) {
             throw new IllegalArgumentException("User code is empty");
         }
         if (userCode.length() > 8) {
index bb7ff9933758ce001bd12064f52184d066579291..3df0f3e7c19b456ab2a137efea181d2b20db6394 100644 (file)
@@ -25,7 +25,7 @@ public class Ethm1Config extends SatelBridgeConfig {
 
     public static final String HOST = "host";
 
-    private @Nullable String host;
+    private String host = "";
     private int port;
     private @Nullable String encryptionKey;
 
@@ -33,8 +33,7 @@ public class Ethm1Config extends SatelBridgeConfig {
      * @return IP or hostname of the bridge
      */
     public String getHost() {
-        final String host = this.host;
-        return host == null ? "" : host;
+        return host;
     }
 
     /**
index 2b92a2b09d6aa727ded5064ca027937eef2f6b5b..d785d40201c6f6abbd539332ac735fc0cdeeedb1 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.binding.satel.internal.config;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * The {@link IntRSConfig} contains configuration values for Satel INT-RS bridge.
@@ -25,12 +24,12 @@ public class IntRSConfig extends SatelBridgeConfig {
 
     public static final String PORT = "port";
 
-    private @Nullable String port;
+    private String port = "";
 
     /**
      * @return serial port to which the module is connected
      */
-    public @Nullable String getPort() {
+    public String getPort() {
         return port;
     }
 }
index 2d795d6c7bd8d6dfd50088d997101c7d73f87b2d..9644f0b2ae317d12464d3e13eddafe57cfc8a087 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.satel.internal.config.Ethm1Config;
 import org.openhab.binding.satel.internal.protocol.Ethm1Module;
 import org.openhab.binding.satel.internal.protocol.SatelModule;
-import org.openhab.binding.satel.internal.util.StringUtils;
 import org.openhab.core.config.core.status.ConfigStatusMessage;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ThingStatus;
@@ -54,7 +53,7 @@ public class Ethm1BridgeHandler extends SatelBridgeHandler {
         logger.debug("Initializing handler");
 
         Ethm1Config config = getConfigAs(Ethm1Config.class);
-        if (StringUtils.isNotBlank(config.getHost())) {
+        if (!config.getHost().isBlank()) {
             SatelModule satelModule = new Ethm1Module(config.getHost(), config.getPort(), config.getTimeout(),
                     config.getEncryptionKey(), config.hasExtCommandsSupport());
             super.initialize(satelModule);
@@ -71,7 +70,7 @@ public class Ethm1BridgeHandler extends SatelBridgeHandler {
         Collection<ConfigStatusMessage> configStatusMessages;
 
         // Check whether an IP address is provided
-        if (StringUtils.isBlank(host)) {
+        if (host.isBlank()) {
             configStatusMessages = Collections.singletonList(ConfigStatusMessage.Builder.error(HOST)
                     .withMessageKeySuffix("hostEmpty").withArguments(HOST).build());
         } else {
index 0718a3234db89c6b97f6ff3dee37c9d0669acacc..2489f589d671721c4161d6bea94b9b9d2a289806 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.satel.internal.config.IntRSConfig;
 import org.openhab.binding.satel.internal.protocol.IntRSModule;
 import org.openhab.binding.satel.internal.protocol.SatelModule;
-import org.openhab.binding.satel.internal.util.StringUtils;
 import org.openhab.core.config.core.status.ConfigStatusMessage;
 import org.openhab.core.io.transport.serial.SerialPortManager;
 import org.openhab.core.thing.Bridge;
@@ -59,7 +58,7 @@ public class IntRSBridgeHandler extends SatelBridgeHandler {
 
         final IntRSConfig config = getConfigAs(IntRSConfig.class);
         final String port = config.getPort();
-        if (port != null && StringUtils.isNotBlank(port)) {
+        if (!port.isBlank()) {
             SatelModule satelModule = new IntRSModule(port, serialPortManager, config.getTimeout(),
                     config.hasExtCommandsSupport());
             super.initialize(satelModule);
@@ -76,7 +75,7 @@ public class IntRSBridgeHandler extends SatelBridgeHandler {
         Collection<ConfigStatusMessage> configStatusMessages;
 
         // Check whether a serial port is provided
-        if (StringUtils.isBlank(port)) {
+        if (port.isBlank()) {
             configStatusMessages = Collections.singletonList(ConfigStatusMessage.Builder.error(PORT)
                     .withMessageKeySuffix("portEmpty").withArguments(PORT).build());
         } else {
index f06ba231c0089e9f46527f4f342e45d8c488152b..aca68ab2a8d8711d2fd43a1dc5aa5765a175bdf3 100644 (file)
@@ -26,7 +26,6 @@ import org.openhab.binding.satel.internal.event.ConnectionStatusEvent;
 import org.openhab.binding.satel.internal.event.SatelEventListener;
 import org.openhab.binding.satel.internal.protocol.SatelModule;
 import org.openhab.binding.satel.internal.types.IntegraType;
-import org.openhab.binding.satel.internal.util.StringUtils;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.ThingStatus;
@@ -164,7 +163,7 @@ public abstract class SatelBridgeHandler extends ConfigStatusBridgeHandler imple
      * @return current user code, either from the configuration or set later using {@link #setUserCode(String)}
      */
     public String getUserCode() {
-        if (StringUtils.isNotEmpty(userCodeOverride)) {
+        if (!userCodeOverride.isEmpty()) {
             return userCodeOverride;
         } else {
             return config.getUserCode();
index 19eedacd0fe525cce0f34623c85c0a14c39643ae..704b4452c916bbd53d946f447e2ab988f013160d 100644 (file)
@@ -25,7 +25,6 @@ import org.openhab.binding.satel.internal.event.ConnectionStatusEvent;
 import org.openhab.binding.satel.internal.event.IntegraStateEvent;
 import org.openhab.binding.satel.internal.event.NewStatesEvent;
 import org.openhab.binding.satel.internal.types.StateType;
-import org.openhab.binding.satel.internal.util.StringUtils;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
@@ -59,7 +58,7 @@ public abstract class SatelStateThingHandler extends SatelThingHandler {
             this.requiresRefresh.set(true);
         } else {
             withBridgeHandlerPresent(bridgeHandler -> {
-                if (StringUtils.isEmpty(bridgeHandler.getUserCode())) {
+                if (bridgeHandler.getUserCode().isEmpty()) {
                     logger.info("Cannot control devices without providing valid user code. Command has not been sent.");
                 } else {
                     convertCommand(channelUID, command)
index 457f08e865a3aca34c7f35102b69e904f099c75f..074d92cbefd33517b5019307a0bd8ac2b7efabbb 100644 (file)
@@ -23,7 +23,6 @@ import java.net.SocketTimeoutException;
 import java.util.Random;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.satel.internal.util.StringUtils;
 import org.openhab.core.util.HexUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -67,17 +66,17 @@ public class Ethm1Module extends SatelModule {
 
     @Override
     protected CommunicationChannel connect() throws ConnectionFailureException {
-        logger.info("Connecting to ETHM-1 module at {}:{}", this.host, this.port);
+        logger.info("Connecting to ETHM-1 module at {}:{}", host, port);
 
         try {
             Socket socket = new Socket();
-            socket.connect(new InetSocketAddress(this.host, this.port), this.getTimeout());
+            socket.connect(new InetSocketAddress(host, port), this.getTimeout());
             logger.info("ETHM-1 module connected successfully");
 
-            if (StringUtils.isBlank(this.encryptionKey)) {
+            if (encryptionKey.isBlank()) {
                 return new TCPCommunicationChannel(socket);
             } else {
-                return new EncryptedCommunicationChannel(socket, this.encryptionKey);
+                return new EncryptedCommunicationChannel(socket, encryptionKey);
             }
         } catch (SocketTimeoutException e) {
             throw new ConnectionFailureException("Connection timeout", e);
diff --git a/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/util/StringUtils.java b/bundles/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/util/StringUtils.java
deleted file mode 100644 (file)
index 0661632..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright (c) 2010-2021 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.satel.internal.util;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Replacement class for Apache's StringUtils.
- *
- * @author Krzysztof Goworek - Initial contribution
- *
- */
-@NonNullByDefault
-public class StringUtils {
-
-    /**
-     * Checks if a string is empty or null.
-     *
-     * @param str the string to check
-     * @return <code>true</code> if given string is empty or null
-     */
-    public static boolean isEmpty(@Nullable String str) {
-        return str == null || str.isEmpty();
-    }
-
-    /**
-     * Checks if a string is not empty and not null.
-     *
-     * @param str the string to check
-     * @return <code>true</code> if given string is not empty and not null
-     */
-    public static boolean isNotEmpty(@Nullable String str) {
-        return !isEmpty(str);
-    }
-
-    /**
-     * Checks if a string is null or empty or all characters are whitespace.
-     *
-     * @param str the string to check
-     * @return <code>true</code> if given string is blank
-     */
-    public static boolean isBlank(@Nullable String str) {
-        return str == null || str.isBlank();
-    }
-
-    /**
-     * Checks if a string is not null, not empty and contains at least one non-whitespace character.
-     *
-     * @param str the string to check
-     * @return <code>true</code> if given string is not blank
-     */
-    public static boolean isNotBlank(@Nullable String str) {
-        return !isBlank(str);
-    }
-}
diff --git a/bundles/org.openhab.binding.satel/src/test/java/org/openhab/binding/satel/internal/util/StringUtilsTest.java b/bundles/org.openhab.binding.satel/src/test/java/org/openhab/binding/satel/internal/util/StringUtilsTest.java
deleted file mode 100644 (file)
index 4d35c36..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (c) 2010-2021 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.satel.internal.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Krzysztof Goworek - Initial contribution
- */
-public class StringUtilsTest {
-
-    @Test
-    public void testIsEmpty() {
-        assertFalse(StringUtils.isEmpty("foobar"));
-        assertFalse(StringUtils.isEmpty("  "));
-        assertTrue(StringUtils.isEmpty(""));
-        assertTrue(StringUtils.isEmpty(null));
-    }
-
-    @Test
-    public void testIsNotEmpty() {
-        assertTrue(StringUtils.isNotEmpty("foobar"));
-        assertTrue(StringUtils.isNotEmpty("  "));
-        assertFalse(StringUtils.isNotEmpty(""));
-        assertFalse(StringUtils.isNotEmpty(null));
-    }
-
-    @Test
-    public void testIsBlank() {
-        assertFalse(StringUtils.isBlank("foobar"));
-        assertTrue(StringUtils.isBlank("  "));
-        assertTrue(StringUtils.isBlank(""));
-        assertTrue(StringUtils.isBlank(null));
-    }
-
-    @Test
-    public void testIsNotBlank() {
-        assertTrue(StringUtils.isNotBlank("foobar"));
-        assertFalse(StringUtils.isNotBlank("  "));
-        assertFalse(StringUtils.isNotBlank(""));
-        assertFalse(StringUtils.isNotBlank(null));
-    }
-}
index 910eae9ddd758ce5920907d05c0ca39ac0da9d52..9fb8b60a99c2de50c22d8d61e41dfc0b53c4a1e3 100644 (file)
@@ -31,10 +31,10 @@ import javax.measure.Unit;
 import javax.measure.UnitConverter;
 import javax.measure.quantity.Temperature;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.commons.lang3.text.WordUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.sensibo.internal.CallbackChannelsTypeProvider;
index d8bc7bb1b75ffbcb83ae7e94db7a0279ce376816..0311311bbd79770f483fee235ed4bcbd522f484a 100644 (file)
@@ -16,7 +16,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
index 8c346a6fff22185c31b61dac1d513752c5e8c259..f94bec4c71bc2a6b26773b9dd256feade2d71148 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Optional;
 import javax.measure.Unit;
 import javax.measure.quantity.Temperature;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.sensibo.internal.SensiboTemperatureUnitConverter;
 import org.openhab.binding.sensibo.internal.dto.poddetails.ModeCapabilityDTO;
index cd3820326543477f4c931dd40a033c571900a97d..a298ea412de1e1d50f0cc1ec490a4ec8adf76512 100644 (file)
  */
 package org.openhab.binding.sleepiq.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Configuration class for the SleepIQ cloud.
  *
  * @author Gregory Moyer - Initial contribution
  */
+@NonNullByDefault
 public class SleepIQCloudConfiguration {
     public static final String USERNAME = "username";
     public static final String PASSWORD = "password";
     public static final String POLLING_INTERVAL = "pollingInterval";
 
-    public String username;
-    public String password;
+    public String username = "";
+    public String password = "";
     public int pollingInterval;
 }
index 3d50c1b3bfc17835fe1b4abecf11921e4ad4df6f..1b8a4bf558098ae0488f3b107a614a7134c1a663 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.sleepiq.api.Configuration;
 import org.openhab.binding.sleepiq.api.LoginException;
 import org.openhab.binding.sleepiq.api.SleepIQ;
@@ -214,12 +213,12 @@ public class SleepIQCloudHandler extends ConfigStatusBridgeHandler {
         String username = config.username;
         String password = config.password;
 
-        if (StringUtils.isEmpty(username)) {
+        if (username.isEmpty()) {
             configStatusMessages.add(ConfigStatusMessage.Builder.error(USERNAME)
                     .withMessageKeySuffix(SleepIQConfigStatusMessage.USERNAME_MISSING).withArguments(USERNAME).build());
         }
 
-        if (StringUtils.isEmpty(password)) {
+        if (password.isEmpty()) {
             configStatusMessages.add(ConfigStatusMessage.Builder.error(PASSWORD)
                     .withMessageKeySuffix(SleepIQConfigStatusMessage.PASSWORD_MISSING).withArguments(PASSWORD).build());
         }
index 5fdfb36eb1eca5f9748b77fee2f3356de0ac6ab3..d68872dc0eee2dd851f40986b2cafcfcd0960457 100644 (file)
@@ -25,7 +25,7 @@ import java.util.function.Supplier;
 import javax.measure.Quantity;
 import javax.measure.Unit;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.DefaultLocation;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -92,32 +92,27 @@ public class SmartMeterHandler extends BaseThingHandler {
         cancelRead();
 
         SmartMeterConfiguration config = getConfigAs(SmartMeterConfiguration.class);
-        logger.debug("config port = {}", config.port);
 
-        boolean validConfig = true;
-        String errorMsg = null;
+        String port = config.port;
+        logger.debug("config port = {}", port);
 
-        if (StringUtils.trimToNull(config.port) == null) {
-            errorMsg = "Parameter 'port' is mandatory and must be configured";
-            validConfig = false;
-        }
-
-        if (validConfig) {
+        if (port == null || port.isBlank()) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
+                    "Parameter 'port' is mandatory and must be configured");
+        } else {
             byte[] pullSequence = config.initMessage == null ? null
                     : HexUtils.hexToBytes(StringUtils.deleteWhitespace(config.initMessage));
             int baudrate = config.baudrate == null ? Baudrate.AUTO.getBaudrate()
                     : Baudrate.fromString(config.baudrate).getBaudrate();
             this.conformity = config.conformity == null ? Conformity.NONE : Conformity.valueOf(config.conformity);
             this.smlDevice = MeterDeviceFactory.getDevice(serialPortManagerSupplier, config.mode,
-                    this.thing.getUID().getAsString(), config.port, pullSequence, baudrate, config.baudrateChangeDelay);
+                    this.thing.getUID().getAsString(), port, pullSequence, baudrate, config.baudrateChangeDelay);
             updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.HANDLER_CONFIGURATION_PENDING,
                     "Waiting for messages from device");
 
             smlDevice.addValueChangeListener(channelTypeProvider);
 
             updateOBISValue();
-        } else {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, errorMsg);
         }
     }
 
index 686fe272abf1eed30370c3bb70cdeef35d353321..f616cd4b297a5eb1f742186f333731a80cde3ea4 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.smartmeter.internal.helper;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.io.transport.serial.SerialPort;
 
index 693e1a5a5ab7a1a08d07380af735af2dc9d68a2b..052b31dad01304501154f0232f4826667675f54d 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.solaredge.internal.config;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
index cebc4cec948d1fabd131e52b8a250a7fb5709aee..5822bfc1406fafe842f703f0ae6d82be22cbdb2a 100644 (file)
@@ -29,7 +29,6 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -181,7 +180,7 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
     public synchronized void login() {
         String url;
 
-        if (StringUtils.isEmpty(thingConfig.getEmail()) || StringUtils.isEmpty(thingConfig.getPassword())) {
+        if (thingConfig.getEmail().isEmpty() || thingConfig.getPassword().isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Can not access device as username and/or password are null");
             return;
@@ -575,7 +574,7 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
             throws InterruptedException, ExecutionException, TimeoutException {
         logger.trace("Sending {} to url: {} with data: {}", method.asString(), url, urlParameters);
         Request request = sendRequestBuilder(url, method);
-        if (StringUtils.isNotEmpty(urlParameters)) {
+        if (!urlParameters.isEmpty()) {
             request = request.content(new StringContentProvider(urlParameters), "application/json;charset=UTF-8");
         }
 
index cd089676494fa2b9ff1d6683be2a5bb4a8c39683..a539c715309ca29e9a50c3f2c47a4cb42cef91f7 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.sonos.internal;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
index 3457e90204b341a60a905cb8fae903c09ea486ac..c70bb59332a07a11681f495341c075286ce35381 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.slf4j.Logger;
index df0701e95e93ec6a9d35489526eda17dba6fc2e0..73744d1b2218e857e7e20bed4b8659fc894e0462 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.jupnp.model.meta.RemoteDevice;
 import org.openhab.binding.sonyaudio.internal.SonyAudioBindingConstants;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -61,15 +60,15 @@ public class SonyAudioDiscoveryParticipant implements UpnpDiscoveryParticipant {
 
         ThingUID thingUid = getThingUID(device);
         if (thingUid != null) {
-            String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
-                    : device.getDetails().getFriendlyName();
-            String host = device.getIdentity().getDescriptorURL().getHost();
-            int port = device.getIdentity().getDescriptorURL().getPort();
-            String path = device.getIdentity().getDescriptorURL().getPath();
+            String friendlyName = device.getDetails().getFriendlyName();
+            String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
+            URL descriptorURL = device.getIdentity().getDescriptorURL();
+            String host = descriptorURL.getHost();
+            int port = descriptorURL.getPort();
+            String path = descriptorURL.getPath();
             try {
                 Map<String, Object> properties = getDescription(host, port, path);
-                properties.put(SonyAudioBindingConstants.HOST_PARAMETER,
-                        device.getIdentity().getDescriptorURL().getHost());
+                properties.put(SonyAudioBindingConstants.HOST_PARAMETER, descriptorURL.getHost());
                 result = DiscoveryResultBuilder.create(thingUid).withLabel(label).withProperties(properties).build();
             } catch (IOException e) {
                 return null;
@@ -82,18 +81,20 @@ public class SonyAudioDiscoveryParticipant implements UpnpDiscoveryParticipant {
     public ThingUID getThingUID(RemoteDevice device) {
         ThingUID result = null;
 
-        if (!StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
-                SonyAudioBindingConstants.MANUFACTURER)) {
+        String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+        if (manufacturer == null
+                || !manufacturer.toLowerCase().contains(SonyAudioBindingConstants.MANUFACTURER.toLowerCase())) {
             return result;
         }
 
         logger.debug("Manufacturer matched: search: {}, device value: {}.", SonyAudioBindingConstants.MANUFACTURER,
-                device.getDetails().getManufacturerDetails().getManufacturer());
-        if (!StringUtils.containsIgnoreCase(device.getType().getType(), SonyAudioBindingConstants.UPNP_DEVICE_TYPE)) {
+                manufacturer);
+        String type = device.getType().getType();
+        if (type == null || !type.toLowerCase().contains(SonyAudioBindingConstants.UPNP_DEVICE_TYPE.toLowerCase())) {
             return result;
         }
         logger.debug("Device type matched: search: {}, device value: {}.", SonyAudioBindingConstants.UPNP_DEVICE_TYPE,
-                device.getType().getType());
+                type);
         logger.debug("Device services: {}", device.getServices().toString());
         String deviceModel = device.getDetails().getModelDetails() != null
                 ? device.getDetails().getModelDetails().getModelName()
index dfb66deb438f1433c418d622f6fdd43d5c0452e2..89cfc2ae5769c92bfb71826f22adea0205f48253 100644 (file)
@@ -16,7 +16,6 @@ import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.squeezebox.internal.handler.SqueezeBoxPlayerHandler;
 import org.openhab.core.audio.AudioFormat;
 import org.openhab.core.audio.AudioHTTPServer;
@@ -66,8 +65,8 @@ public class SqueezeBoxAudioSink implements AudioSink {
         this.playerHandler = playerHandler;
         this.audioHTTPServer = audioHTTPServer;
         this.callbackUrl = callbackUrl;
-        if (StringUtils.isNotEmpty(callbackUrl)) {
-            logger.debug("SqueezeBox AudioSink created with callback URL {}", callbackUrl);
+        if (callbackUrl != null && !callbackUrl.isEmpty()) {
+            logger.debug("SqueezeBox AudioSink created with callback URL: {}", callbackUrl);
         }
     }
 
@@ -104,7 +103,7 @@ public class SqueezeBoxAudioSink implements AudioSink {
 
             // Form the URL for streaming the notification from the OH2 web server
             // Use the callback URL if it is set in the binding configuration
-            String host = StringUtils.isEmpty(callbackUrl) ? playerHandler.getHostAndPort() : callbackUrl;
+            String host = callbackUrl == null || callbackUrl.isEmpty() ? playerHandler.getHostAndPort() : callbackUrl;
             if (host == null) {
                 logger.warn("Unable to get host/port from which to stream notification");
                 return;
index 4f97915ac9e19b6b93a08b50eab550693457efb7..6f441b095a7617677e3dd44591d16bad2e719044 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.squeezebox.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Configuration of a server.
  *
@@ -19,11 +21,12 @@ package org.openhab.binding.squeezebox.internal.config;
  * @author Mark Hilbush - Added user ID and password
  *
  */
+@NonNullByDefault
 public class SqueezeBoxServerConfig {
     /**
      * Server ip address
      */
-    public String ipAddress;
+    public String ipAddress = "";
     /**
      * Server web port for REST calls
      */
@@ -35,13 +38,13 @@ public class SqueezeBoxServerConfig {
     /**
      * Language for TTS
      */
-    public String language;
+    public String language = "";
     /*
      * User ID (when authentication enabled in LMS)
      */
-    public String userId;
+    public String userId = "";
     /*
      * User ID (when authentication enabled in LMS)
      */
-    public String password;
+    public String password = "";
 }
index aa02f8e479e9303538ac455f664bca6a21f0ff70..65ca21692610a62992087c0bc44e4e4fbd375601 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.openhab.binding.squeezebox.internal.SqueezeBoxStateDescriptionOptionsProvider;
 import org.openhab.binding.squeezebox.internal.config.SqueezeBoxPlayerConfig;
@@ -276,7 +275,7 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
                 squeezeBoxServerHandler.playUrl(mac, command.toString());
                 break;
             case CHANNEL_SYNC:
-                if (StringUtils.isBlank(command.toString())) {
+                if (command.toString().isBlank()) {
                     squeezeBoxServerHandler.unSyncPlayer(mac);
                 } else {
                     squeezeBoxServerHandler.syncPlayer(mac, command.toString());
@@ -444,7 +443,7 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
     private RawType downloadImage(String mac, String url) {
         // Only get the image if this is my PlayerHandler instance
         if (isMe(mac)) {
-            if (StringUtils.isNotEmpty(url)) {
+            if (url != null && !url.isEmpty()) {
                 String sanitizedUrl = sanitizeUrl(url);
                 RawType image = IMAGE_CACHE.putIfAbsentAndGet(url, () -> {
                     logger.debug("Trying to download the content of URL {}", sanitizedUrl);
index 1f7cbd6d049238052f05b821285c857dc70b8409..fd8e6ae66a3a4aaf25acdbbfcc70d380838b3ae3 100644 (file)
@@ -37,7 +37,6 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.squeezebox.internal.config.SqueezeBoxServerConfig;
 import org.openhab.binding.squeezebox.internal.dto.ButtonDTO;
 import org.openhab.binding.squeezebox.internal.dto.ButtonDTODeserializer;
@@ -333,7 +332,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
      * Login to server
      */
     public void login() {
-        if (StringUtils.isEmpty(userId)) {
+        if (userId.isEmpty()) {
             return;
         }
         // Create basic auth string for jsonrpc interface
@@ -390,7 +389,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
         this.userId = config.userId;
         this.password = config.password;
 
-        if (StringUtils.isEmpty(this.host)) {
+        if (host.isEmpty()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "host is not set");
             return;
         }
@@ -836,7 +835,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
 
         private String constructCoverArtUrl(String mac, boolean coverart, String coverid, String artwork_url) {
             String hostAndPort;
-            if (StringUtils.isNotEmpty(userId)) {
+            if (!userId.isEmpty()) {
                 hostAndPort = "http://" + encode(userId) + ":" + encode(password) + "@" + host + ":" + webport;
             } else {
                 hostAndPort = "http://" + host + ":" + webport;
index 42a9fa66e85d630804728ac8894279a5646cdd16..c95b7165764c7c32c5d87fc1201b91e37a98585e 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.systeminfo.internal.model;
 
 import java.math.BigDecimal;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.library.types.DecimalType;
index 51fa6dfa36eb38e78de458aa506b51f9ecdcec54..21fd7cc4e7dc34b2270e3650063f943fce3f8254 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.unifi.internal;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.unifi.internal.handler.UniFiClientThingHandler;
 
 /**
@@ -42,13 +41,13 @@ public class UniFiClientThingConfig {
     }
 
     public UniFiClientThingConfig tidy() {
-        cid = StringUtils.lowerCase(StringUtils.strip(cid));
-        site = StringUtils.lowerCase(StringUtils.strip(site));
+        cid = cid.trim().toLowerCase();
+        site = site.trim().toLowerCase();
         return this;
     }
 
     public boolean isValid() {
-        return StringUtils.isNotBlank(cid);
+        return !cid.isBlank();
     }
 
     @Override
index 4f05ba2980d8a9e1d57205be87abb0947712675d..d3d14c154f057cc572552314b490b79328f778a9 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.unifi.internal;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler;
 
 /**
@@ -60,7 +59,7 @@ public class UniFiControllerThingConfig {
     }
 
     public boolean isValid() {
-        return StringUtils.isNotBlank(host) && StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password);
+        return !host.isBlank() && !username.isBlank() && !password.isBlank();
     }
 
     @Override
index 0880dc272300b9106c619001ba45b487905fab5d..e5ae0aa7be966fbd60e4aa8ebaf170fb7d0d3267 100644 (file)
@@ -17,7 +17,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,7 +76,7 @@ public abstract class UniFiCache<T> {
     public final void put(T value) {
         for (String prefix : prefixes) {
             String suffix = getSuffix(value, prefix);
-            if (StringUtils.isNotBlank(suffix)) {
+            if (suffix != null && !suffix.isBlank()) {
                 String key = prefix + SEPARATOR + suffix;
                 map.put(key, value);
             }
index 02a08ff58e139afc1f548fde4a586fff010df062..be6df1b3280a3d0a6725c58b918800316ad8c993 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.unifi.internal.api.model;
 
 import java.util.Calendar;
 
-import org.apache.commons.lang.BooleanUtils;
 import org.openhab.binding.unifi.internal.api.UniFiException;
 import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
 import org.openhab.binding.unifi.internal.api.util.UniFiTimestampDeserializer;
@@ -95,7 +94,7 @@ public abstract class UniFiClient {
     public abstract Boolean isWired();
 
     public final Boolean isWireless() {
-        return BooleanUtils.negate(isWired());
+        return isWired() == null ? null : (isWired().booleanValue() ? Boolean.FALSE : Boolean.TRUE);
     }
 
     protected abstract String getDeviceMac();
index 0c47a7a3b0d57a47ae7a7be6d8e172206bbf11b4..6dbdc35c869262c488bbf4db20897f2ee5981b4e 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.unifi.internal.api.model;
 
 import java.util.Collection;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -135,7 +134,7 @@ public class UniFiController {
 
     public @Nullable UniFiSite getSite(@Nullable String id) {
         UniFiSite site = null;
-        if (StringUtils.isNotBlank(id)) {
+        if (id != null && !id.isBlank()) {
             synchronized (this) {
                 site = sitesCache.get(id);
             }
@@ -150,7 +149,7 @@ public class UniFiController {
 
     public @Nullable UniFiDevice getDevice(@Nullable String id) {
         UniFiDevice device = null;
-        if (StringUtils.isNotBlank(id)) {
+        if (id != null && !id.isBlank()) {
             synchronized (this) {
                 device = devicesCache.get(id);
             }
@@ -165,7 +164,7 @@ public class UniFiController {
 
     public @Nullable UniFiClient getClient(@Nullable String id) {
         UniFiClient client = null;
-        if (StringUtils.isNotBlank(id)) {
+        if (id != null && !id.isBlank()) {
             synchronized (this) {
                 // mgb: first check active clients and fallback to insights if not found
                 client = clientsCache.get(id);
index ba81b3ab3ac38bf6eab4d43bb1b6b3a40577ca23..2c74ef19a36301d1a2371ad8b630a10059882fd3 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.unifi.internal.api.model;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
 
 import com.google.gson.annotations.JsonAdapter;
@@ -53,7 +52,7 @@ public class UniFiDevice {
     }
 
     public String getName() {
-        return StringUtils.defaultIfBlank(name, mac);
+        return name == null || name.isBlank() ? mac : name;
     }
 
     public String getMac() {
index c1025fb00991adf461a0c9b8713bb3e766b061e2..d6597e025cc1ec4fc03582994ace992e644f548d 100644 (file)
@@ -12,8 +12,6 @@
  */
 package org.openhab.binding.unifi.internal.api.model;
 
-import org.apache.commons.lang.StringUtils;
-
 import com.google.gson.annotations.SerializedName;
 
 /**
@@ -49,8 +47,7 @@ public class UniFiSite {
     }
 
     public boolean matchesName(String siteName) {
-        return StringUtils.equalsIgnoreCase(desc, siteName) || StringUtils.equalsIgnoreCase(name, siteName)
-                || StringUtils.equalsIgnoreCase(id, siteName);
+        return siteName.equalsIgnoreCase(desc) || siteName.equalsIgnoreCase(name) || siteName.equalsIgnoreCase(id);
     }
 
     @Override
index 25264dff232c3a93e489317c74944240b061c4b1..ddcf072089efdb45b15bc361421caac38bd5ceda 100644 (file)
@@ -14,8 +14,6 @@ package org.openhab.binding.unifi.internal.api.util;
 
 import java.lang.reflect.Type;
 
-import org.apache.commons.lang.StringUtils;
-
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
 import com.google.gson.JsonElement;
@@ -34,6 +32,6 @@ public class UniFiTidyLowerCaseStringDeserializer implements JsonDeserializer<St
     public String deserialize(JsonElement json, Type type, JsonDeserializationContext context)
             throws JsonParseException {
         String s = json.getAsJsonPrimitive().getAsString();
-        return StringUtils.lowerCase(StringUtils.strip(s));
+        return s.trim().toLowerCase();
     }
 }
index 186b799b390c7965ff2b064eb760c88e176ec10a..139e031fb9d11f41866a861ef9351c215b6db840 100644 (file)
@@ -20,7 +20,6 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Calendar;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.unifi.internal.UniFiBindingConstants;
@@ -84,7 +83,7 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
 
     private static boolean belongsToSite(UniFiClient client, String siteName) {
         boolean result = true; // mgb: assume true = proof by contradiction
-        if (StringUtils.isNotEmpty(siteName)) {
+        if (!siteName.isEmpty()) {
             UniFiSite site = client.getSite();
             // mgb: if the 'site' can't be found or the name doesn't match...
             if (site == null || !site.matchesName(siteName)) {
@@ -166,21 +165,21 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
 
             // :site
             case CHANNEL_SITE:
-                if (clientHome && site != null && StringUtils.isNotBlank(site.getDescription())) {
+                if (clientHome && site != null && site.getDescription() != null && !site.getDescription().isBlank()) {
                     state = StringType.valueOf(site.getDescription());
                 }
                 break;
 
             // :macAddress
             case CHANNEL_MAC_ADDRESS:
-                if (clientHome && StringUtils.isNotBlank(client.getMac())) {
+                if (clientHome && client.getMac() != null && !client.getMac().isBlank()) {
                     state = StringType.valueOf(client.getMac());
                 }
                 break;
 
             // :ipAddress
             case CHANNEL_IP_ADDRESS:
-                if (clientHome && StringUtils.isNotBlank(client.getIp())) {
+                if (clientHome && client.getIp() != null && !client.getIp().isBlank()) {
                     state = StringType.valueOf(client.getIp());
                 }
                 break;
@@ -235,14 +234,14 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
             // :ap
             case CHANNEL_AP:
                 UniFiDevice device = client.getDevice();
-                if (clientHome && device != null && StringUtils.isNotBlank(device.getName())) {
+                if (clientHome && device != null && device.getName() != null && !device.getName().isBlank()) {
                     state = StringType.valueOf(device.getName());
                 }
                 break;
 
             // :essid
             case CHANNEL_ESSID:
-                if (clientHome && StringUtils.isNotBlank(client.getEssid())) {
+                if (clientHome && client.getEssid() != null && !client.getEssid().isBlank()) {
                     state = StringType.valueOf(client.getEssid());
                 }
                 break;
index 6ec33fea4343e7e0f34780dc45ab3571c6aac6b2..e54fbaff877cd6dbc008857f6d9006b4c39cb4e0 100644 (file)
@@ -18,7 +18,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
index 425057b156a2bf58f599ac389d3a0980720b0bd2..8d4b109f50ef79b2500b160e76659ce282814ed9 100644 (file)
@@ -25,7 +25,7 @@ import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntry;
index e8db774605a812998c4cd02873a1282bd4d4514b..37116b6932e7ec6a82696c6c7e4f1d1d10ec415f 100644 (file)
@@ -20,7 +20,14 @@ import java.math.RoundingMode;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.*;
+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.Objects;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -31,7 +38,6 @@ import javax.measure.Unit;
 import javax.measure.quantity.Dimensionless;
 import javax.measure.quantity.Temperature;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -112,13 +118,13 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
     public Collection<ConfigStatusMessage> getConfigStatus() {
         Collection<ConfigStatusMessage> status = new ArrayList<>();
         VenstarThermostatConfiguration config = getConfigAs(VenstarThermostatConfiguration.class);
-        if (StringUtils.isBlank(config.username)) {
+        if (config.username.isBlank()) {
             log.warn("username is empty");
             status.add(ConfigStatusMessage.Builder.error(CONFIG_USERNAME).withMessageKeySuffix(EMPTY_INVALID)
                     .withArguments(CONFIG_USERNAME).build());
         }
 
-        if (StringUtils.isBlank(config.password)) {
+        if (config.password.isBlank()) {
             log.warn("password is empty");
             status.add(ConfigStatusMessage.Builder.error(CONFIG_PASSWORD).withMessageKeySuffix(EMPTY_INVALID)
                     .withArguments(CONFIG_PASSWORD).build());
index dd562f28526502568437cf35b2cd2c866425c5c1..f147b0a26ca1714e698fa1aa66c8de4af39f42a3 100644 (file)
@@ -16,7 +16,7 @@ import java.io.IOException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpResponseException;
index e13fbe9ca5d5381208b9c811e2695f270a99091d..4659d7dbfe7484d928ab8e69372fdb1e67e5fa84 100644 (file)
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
 
 import javax.imageio.ImageIO;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -120,14 +119,15 @@ public class WeatherCompanyForecastHandler extends WeatherCompanyAbstractHandler
 
     private boolean isValidLocation() {
         boolean validLocation = false;
-        String locationType = getConfigAs(WeatherCompanyForecastConfig.class).locationType;
+        WeatherCompanyForecastConfig config = getConfigAs(WeatherCompanyForecastConfig.class);
+        String locationType = config.locationType;
         if (locationType == null) {
             return validLocation;
         }
         switch (locationType) {
             case CONFIG_LOCATION_TYPE_POSTAL_CODE:
-                String postalCode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).postalCode);
-                if (postalCode == null) {
+                String postalCode = config.postalCode;
+                if (postalCode == null || postalCode.isBlank()) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Postal code is not set");
                 } else {
                     locationQueryString = "&postalKey=" + postalCode.replace(" ", "");
@@ -135,8 +135,8 @@ public class WeatherCompanyForecastHandler extends WeatherCompanyAbstractHandler
                 }
                 break;
             case CONFIG_LOCATION_TYPE_GEOCODE:
-                String geocode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).geocode);
-                if (geocode == null) {
+                String geocode = config.geocode;
+                if (geocode == null || geocode.isBlank()) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Geocode is not set");
                 } else {
                     locationQueryString = "&geocode=" + geocode.replace(" ", "");
@@ -144,8 +144,8 @@ public class WeatherCompanyForecastHandler extends WeatherCompanyAbstractHandler
                 }
                 break;
             case CONFIG_LOCATION_TYPE_IATA_CODE:
-                String iataCode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).iataCode);
-                if (iataCode == null) {
+                String iataCode = config.iataCode;
+                if (iataCode == null || iataCode.isBlank()) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "IATA code is not set");
                 } else {
                     locationQueryString = "&iataCode=" + iataCode.replace(" ", "").toUpperCase();
@@ -160,15 +160,16 @@ public class WeatherCompanyForecastHandler extends WeatherCompanyAbstractHandler
     }
 
     private void setLanguage() {
-        String language = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).language);
-        if (language == null) {
+        WeatherCompanyForecastConfig config = getConfigAs(WeatherCompanyForecastConfig.class);
+        String language = config.language;
+        if (language == null || language.isBlank()) {
             // Nothing in the thing config, so try to get a match from the openHAB locale
             String derivedLanguage = WeatherCompanyAbstractHandler.lookupLanguage(localeProvider.getLocale());
             languageQueryString = "&language=" + derivedLanguage;
             logger.debug("Language not set in thing config, using {}", derivedLanguage);
         } else {
             // Use what is set in the thing config
-            languageQueryString = "&language=" + language;
+            languageQueryString = "&language=" + language.trim();
         }
     }
 
index 2d46b4fcca7f7c64d6d065e0af915173cee609be..6bd80003286c6f9bc12c1101399fbff7d3489657 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Objects;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
@@ -104,7 +103,9 @@ public class WeatherCompanyObservationsHandler extends WeatherCompanyAbstractHan
      * Build the URL for requesting the PWS current observations
      */
     private @Nullable String buildPwsUrl() {
-        if (StringUtils.isEmpty(getConfigAs(WeatherCompanyObservationsConfig.class).pwsStationId)) {
+        WeatherCompanyObservationsConfig config = getConfigAs(WeatherCompanyObservationsConfig.class);
+        String pwsStationId = config.pwsStationId;
+        if (pwsStationId == null || pwsStationId.isEmpty()) {
             return null;
         }
         String apiKey = getApiKey();
@@ -116,7 +117,7 @@ public class WeatherCompanyObservationsHandler extends WeatherCompanyAbstractHan
         // Set response type as JSON
         sb.append("&format=json");
         // Set PWS station Id from config
-        sb.append("&stationId=").append(getConfigAs(WeatherCompanyObservationsConfig.class).pwsStationId);
+        sb.append("&stationId=").append(pwsStationId);
         // Set API key from config
         sb.append("&apiKey=").append(apiKey);
         String url = sb.toString();
index 535661bb1a2b967958f122b15e3b39ff7c5108a1..368bb103cc2c2ef835192b6a0a9ca217f30a0140 100644 (file)
@@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.handler.WemoBridgeHandler;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
index 1e000d8dbe29f971e284030ee596199d60ccf510..2e5ebbe1c192377137b41dcfdeb5aa087f919076 100644 (file)
@@ -30,8 +30,8 @@ import java.util.concurrent.TimeUnit;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index f8699e50b9c474ab3b15ad47167bff33c7aab35b..4ca69f11012e910402b31e2f4ac5d29189190471 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index a645ed5a2ef91f8fb5a1ec59f3b66ce9bfe65721..cfd6fa622abacfd8eca1390d69e61d6c627f7bb2 100644 (file)
@@ -26,7 +26,7 @@ import java.util.TimeZone;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index 1f2d34c783c116e7a7b9bf4c41706966a3a6c12c..d1fe489b7542715a3fa5e1cff46a42008b90fe2f 100644 (file)
@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.net.http.HttpUtil;
index 4ef7c2ebcdc59ba062c100dea18bb6d1b9d31b8f..0017e9395a4b994bae0aa07a76ed5705d4390602 100644 (file)
@@ -29,8 +29,8 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index f0753be553d82ee8b445269c2e8cb41e6cc96b2a..59c0969680b7389ee4ff2f31fcc34bef8ace6e9a 100644 (file)
@@ -21,8 +21,8 @@ import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index 03cdbcd95600533e79c0f5b6a12c86ca6d78b092..c8ac1f286295d12a9dc015d4df396dfc4f681a30 100644 (file)
@@ -25,8 +25,8 @@ import java.util.concurrent.TimeUnit;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.wemo.internal.http.WemoHttpCall;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
index 319c918bc535d80df9138187d1d3efd31f7b65c7..35df29a30f91124bc0b7455e0ddd16ec76d2064f 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.yamahareceiver.internal.config;
 
 import java.util.Optional;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -65,7 +64,7 @@ public class YamahaBridgeConfig {
 
     public Optional<String> getHostWithPort() {
         final String str = host;
-        if (StringUtils.isEmpty(str)) {
+        if (str == null || str.isEmpty()) {
             return Optional.empty();
         }
         return Optional.of(str + ":" + port);
index 38168dc869a5d99935dec8684a040ac5a4490b6c..ae1e3422be62b4342b11c52cc6ef12c6395ead15 100644 (file)
@@ -26,7 +26,6 @@ import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
 import org.openhab.binding.yamahareceiver.internal.config.YamahaUtils;
@@ -216,7 +215,7 @@ public class DeviceDescriptorXML {
             elements.forEach(e -> {
                 String tag = e.getAttribute("YNC_Tag");
 
-                if (StringUtils.isNotEmpty(tag)) {
+                if (!tag.isEmpty()) {
                     T key = converter.apply(tag);
                     if (key != null) {
                         V value = factory.apply(key, e);
index adc577ab749af789c593f8be54c0d8f7ab2daa06..81d12cb2f6ec4d972b84ef2511b932396c89517e 100644 (file)
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
@@ -136,7 +135,7 @@ public class DeviceInformationXML implements DeviceInformation {
             // Retrieve Main_Zone basic status, from which we will know this AVR supports Zone_B feature.
             Node basicStatusNode = getZoneResponse(con, Main_Zone, ZONE_BASIC_STATUS_CMD, ZONE_BASIC_STATUS_PATH);
             String power = getNodeContentOrEmpty(basicStatusNode, "Power_Control/Zone_B_Power_Info");
-            if (StringUtils.isNotEmpty(power)) {
+            if (!power.isEmpty()) {
                 logger.debug("Zone_2 emulation enabled via Zone_B");
                 state.zones.add(Zone_2);
                 state.features.add(Feature.ZONE_B);
index dec885e734dbad7986938e2cdf3a8bd96c78bed2..8d63de8a7ed1c9a4d9cad6898c2f12283922987f 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputConverter;
@@ -74,7 +73,7 @@ public class InputConverterXML implements InputConverter {
     private Map<String, String> createMapFromSetting(String setting) {
         Map<String, String> map = new HashMap<>();
 
-        if (!StringUtils.isEmpty(setting)) {
+        if (setting != null && !setting.isEmpty()) {
             String[] entries = setting.split(","); // will contain KEY=VALUE entires
             for (String entry : entries) {
                 String[] keyValue = entry.split("="); // split the KEY=VALUE string
index 23bad8df170aba3c8dc4dd429a06cfa529426550..fa31fec42a5466c2fe0231cc51c901784c58ff8b 100644 (file)
@@ -19,7 +19,6 @@ import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLUtils.
 
 import java.io.IOException;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.config.YamahaBridgeConfig;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPlayControl;
@@ -244,8 +243,7 @@ public class InputWithPlayControlXML extends AbstractInputControlXML implements
 
         // Spotify and NET RADIO input supports song cover image (at least on RX-S601D)
         String songImageUrl = getNodeContentOrEmpty(node, "Play_Info/Album_ART/URL");
-        msg.songImageUrl = StringUtils.isNotEmpty(songImageUrl)
-                ? String.format("http://%s%s", con.getHost(), songImageUrl)
+        msg.songImageUrl = !songImageUrl.isEmpty() ? String.format("http://%s%s", con.getHost(), songImageUrl)
                 : bridgeConfig.getAlbumUrl();
 
         logger.trace("Playback: {}, Station: {}, Artist: {}, Album: {}, Song: {}, SongImageUrl: {}", msg.playbackMode,
index 0e6a3a9a478febe729abbbb1a4040723dacd56bf..eb0a811048ff442f94f7ad2e830d8fd04db08bad 100644 (file)
@@ -18,8 +18,8 @@ import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLUtils.
 
 import java.io.IOException;
 
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPresetControl;
 import org.openhab.binding.yamahareceiver.internal.protocol.ReceivedMessageParseException;
@@ -116,7 +116,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
                 String value = getNodeContentOrDefault(itemNode, "Param", String.valueOf(i));
 
                 // For RX-V3900 when a preset slot is not used, this is how it looks
-                if (StringUtils.isEmpty(title) && "Not Used".equalsIgnoreCase(value)) {
+                if (title.isEmpty() && "Not Used".equalsIgnoreCase(value)) {
                     continue;
                 }
 
@@ -130,7 +130,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
         String presetValue = getNodeContentOrEmpty(response, preset.getPath());
 
         // fall back to second method of obtaining current preset (works for Tuner on RX-V3900)
-        if (StringUtils.isEmpty(presetValue)) {
+        if (presetValue.isEmpty()) {
             try {
                 Node presetResponse = getResponse(con, wrInput(preset.apply(GET_PARAM)), inputElement);
                 presetValue = getNodeContentOrEmpty(presetResponse, preset.getPath());
@@ -146,7 +146,7 @@ public class InputWithPresetControlXML extends AbstractInputControlXML implement
     }
 
     private int convertToPresetNumber(String presetValue) {
-        if (StringUtils.isNotEmpty(presetValue)) {
+        if (!presetValue.isEmpty()) {
             if (StringUtils.isNumeric(presetValue)) {
                 return Integer.parseInt(presetValue);
             } else {
index 18a20730195552e8d7e947c5317273fc6e6b8408..01eea31e74a601c4c974188bb3dd2c7142fc06c6 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLUtils.
 
 import java.io.IOException;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPresetControl;
 import org.openhab.binding.yamahareceiver.internal.protocol.InputWithTunerBandControl;
@@ -172,7 +171,7 @@ public class InputWithTunerDABControlXML extends AbstractInputControlXML
         // store last state of band
         bandState = msgForBand;
 
-        if (StringUtils.isEmpty(msgForBand.band)) {
+        if (msgForBand.band.isEmpty()) {
             logger.warn("Band is unknown for input {}, therefore preset and playback information will not be available",
                     inputID);
         } else {
index e5ae04280f5af493b57faaf7fa5f00626d532095..d89e382fb3154010f965cf967cc690687d554863 100644 (file)
@@ -26,7 +26,6 @@ import java.nio.charset.UnsupportedCharsetException;
 import java.util.Arrays;
 import java.util.Optional;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -183,7 +182,7 @@ public class XMLConnection extends AbstractConnection {
                 .filter(x -> x.toLowerCase().startsWith(HEADER_CHARSET_PART))
                 .map(x -> x.substring(HEADER_CHARSET_PART.length() + 1, x.length() - 1)).findFirst();
 
-        if (charsetName.isPresent() && !StringUtils.isEmpty(charsetName.get())) {
+        if (charsetName.isPresent() && !charsetName.get().isEmpty()) {
             try {
                 charset = Charset.forName(charsetName.get());
             } catch (UnsupportedCharsetException | IllegalCharsetNameException e) {
index f8548f988313fc24dcb68cd0b77113da72f44bb6..5a43d6f0ecf08a8be854c190203e7878ac88afca 100644 (file)
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.util.function.Supplier;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
 import org.openhab.binding.yamahareceiver.internal.config.YamahaZoneConfig;
 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
@@ -135,7 +134,7 @@ public class ZoneControlXML implements ZoneControl {
                     ZONE_BASIC_STATUS_PATH);
             String surroundProgram = getNodeContentOrEmpty(basicStatusNode, "Surr/Pgm_Sel/Pgm");
 
-            if (StringUtils.isNotEmpty(surroundProgram)) {
+            if (!surroundProgram.isEmpty()) {
                 surroundSelProgram = new CommandTemplate(
                         "<Surr><Pgm_Sel><Straight>Off</Straight><Pgm>%s</Pgm></Pgm_Sel></Surr>", "Surr/Pgm_Sel/Pgm");
                 logger.debug("Zone {} - adjusting command to: {}", getZone(), surroundSelProgram);
@@ -287,7 +286,7 @@ public class ZoneControlXML implements ZoneControl {
 
         value = getNodeContentOrEmpty(statusNode, inputSel.getPath());
         state.inputID = inputConverterSupplier.get().fromStateName(value);
-        if (StringUtils.isBlank(state.inputID)) {
+        if (state.inputID == null || state.inputID.isBlank()) {
             throw new ReceivedMessageParseException("Expected inputID. Failed to read Input/Input_Sel");
         }
 
index 8a620bfa94c610503dcf6ba9dabe15ac2f032adc..3912e28a5ed0b8e29044e06b9236bb0f71c99a75 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.yamahareceiver.internal.state;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.binding.yamahareceiver.internal.protocol.xml.InputWithNavigationControlXML;
 
 /**
@@ -37,7 +36,7 @@ public class NavigationControlState implements Invalidateable {
     public String getAllItemLabels() {
         StringBuilder sb = new StringBuilder();
         for (String item : items) {
-            if (StringUtils.isNotEmpty(item)) {
+            if (item != null && !item.isEmpty()) {
                 sb.append(item);
                 sb.append(',');
             }
index 5ceb22305f2ed1261de44f43bb07d82466a98d1c..9a9971f5eced9fd5ae3742897c0d3aecc9b0ed2f 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.zway.internal.config.ZWayBridgeConfiguration;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.thing.Bridge;
@@ -387,7 +386,8 @@ public class ZWayBridgeHandler extends BaseBridgeHandler implements IZWayApiCall
          ****************************************/
 
         // Z-Way IP address
-        if (StringUtils.trimToNull(config.getZWayIpAddress()) == null) {
+        String zWayIpAddress = config.getZWayIpAddress();
+        if (zWayIpAddress == null || zWayIpAddress.isBlank()) {
             config.setZWayIpAddress("localhost"); // default value
         }
 
@@ -397,19 +397,22 @@ public class ZWayBridgeHandler extends BaseBridgeHandler implements IZWayApiCall
         }
 
         // Z-Way Protocol
-        if (StringUtils.trimToNull(config.getZWayProtocol()) == null) {
+        String zWayProtocol = config.getZWayProtocol();
+        if (zWayProtocol == null || zWayProtocol.isBlank()) {
             config.setZWayProtocol("http");
         }
 
         // Z-Way Password
-        if (StringUtils.trimToNull(config.getZWayPassword()) == null) {
+        String zWayPassword = config.getZWayPassword();
+        if (zWayPassword == null || zWayPassword.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "The connection to the Z-Way Server can't established, because the Z-Way password is missing. Please set a Z-Way password.");
             return null;
         }
 
         // Z-Way Username
-        if (StringUtils.trimToNull(config.getZWayUsername()) == null) {
+        String zWayUsername = config.getZWayUsername();
+        if (zWayUsername == null || zWayUsername.isBlank()) {
             config.setZWayUsername("admin"); // default value
         }
 
index fa4173ccdb9a44d062e64399f7677be4a57aae16..63335021b0d7f4996260d75cd63cc69314e456ee 100644 (file)
@@ -19,7 +19,6 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.lang3.StringUtils;
 import org.openhab.binding.zway.internal.config.ZWayZAutomationDeviceConfiguration;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
@@ -140,7 +139,8 @@ public class ZWayZAutomationDeviceHandler extends ZWayDeviceHandler {
     private ZWayZAutomationDeviceConfiguration loadAndCheckConfiguration() {
         ZWayZAutomationDeviceConfiguration config = getConfigAs(ZWayZAutomationDeviceConfiguration.class);
 
-        if (StringUtils.trimToNull(config.getDeviceId()) == null) {
+        String deviceId = config.getDeviceId();
+        if (deviceId == null || deviceId.isBlank()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "Z-Wave device couldn't create, because the device id is missing.");
             return null;
index 1a650b67679089a81b5beabcb815b9f20cda2216..ea090f36897e5f2e181ff14c3d1b44d3a35f83ad 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.action;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.events.EventPublisher;
 import org.openhab.core.items.Item;
 import org.openhab.core.items.events.ItemCommandEvent;
@@ -42,7 +41,8 @@ public class SetModeAction extends Action {
         if (device.getType() != DeviceType.THERMOSTAT) {
             return false;
         }
-        return StringUtils.isNotBlank(device.getLinks().get("curmode"));
+        String curmode = device.getLinks().get("curmode");
+        return curmode != null && !curmode.isBlank();
     }
 
     @Override
index f5d43a022dbc873178a36ca3f222d46025a64953..54875b55c188961388bc143f6ff1af3bf0041f16 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.action;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.events.EventPublisher;
 import org.openhab.core.items.Item;
 import org.openhab.core.items.events.ItemCommandEvent;
@@ -39,7 +38,8 @@ public class StopShutterAction extends Action {
 
     @Override
     public boolean supports(AbstractDevice device, Item item) {
-        return device.getType() == DeviceType.SHUTTER && StringUtils.isNotBlank(device.getLinks().get("stopper"));
+        String stopper = device.getLinks().get("stopper");
+        return device.getType() == DeviceType.SHUTTER && stopper != null && !stopper.isBlank();
     }
 
     @Override
index 5e580fd3727d0d4767e8cd834e5668917e62e75d..27badd74e92493abb1e0794f83b13eedacb521bf 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.model.device;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.types.State;
@@ -49,7 +48,7 @@ public class ElectricityDevice extends AbstractNumericValueDevice {
     public void stateUpdated(Item item, State newState) {
         super.stateUpdated(item, newState);
 
-        DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+        DecimalType value = item.getStateAs(DecimalType.class);
 
         if (getLinks().containsKey(LINK_WATTS) || getUnit().equalsIgnoreCase(LINK_KWH)) {
             addParam(new NumericValueParam(ParamType.KWH, getUnit(), value));
@@ -93,7 +92,8 @@ public class ElectricityDevice extends AbstractNumericValueDevice {
         }
 
         NumericValueParam wattsParam = new NumericValueParam(ParamType.WATTS, valueParam.getUnit(), null);
-        if (StringUtils.isEmpty(wattsParam.getUnit())) {
+        String unit = wattsParam.getUnit();
+        if (unit == null || unit.isEmpty()) {
             wattsParam.setUnit("W");
         }
         wattsParam.setValue(valueParam.getValue());
@@ -108,7 +108,8 @@ public class ElectricityDevice extends AbstractNumericValueDevice {
         }
 
         NumericValueParam kwhParam = new NumericValueParam(ParamType.KWH, valueParam.getUnit(), null);
-        if (StringUtils.isEmpty(kwhParam.getUnit())) {
+        String unit = kwhParam.getUnit();
+        if (unit == null || unit.isEmpty()) {
             kwhParam.setUnit("KWh");
         }
         kwhParam.setValue(valueParam.getValue());
index 94e9220ede2d6ed0259545ce69f917854495eb7f..00924d6573f1c50bd918e060487e8039d2d18d52 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.model.device;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.types.State;
@@ -54,7 +53,8 @@ public class RainDevice extends AbstractNumericValueDevice {
             }
 
             NumericValueParam accumParam = new NumericValueParam(ParamType.ACCUMULATION, valueParam.getUnit(), null);
-            if (StringUtils.isEmpty(accumParam.getUnit())) {
+            String unit = accumParam.getUnit();
+            if (unit == null || unit.isBlank()) {
                 accumParam.setUnit("mm");
             }
 
@@ -67,7 +67,7 @@ public class RainDevice extends AbstractNumericValueDevice {
     public void stateUpdated(Item item, State newState) {
         super.stateUpdated(item, newState);
 
-        DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+        DecimalType value = item.getStateAs(DecimalType.class);
         addParam(new NumericValueParam(ParamType.RAIN_VALUE, getUnit(), value));
     }
 }
index bba4da69846b51fe979d6bc95f0be880bcc6dd43..fc2668ca88d7b91cfcb6a3450b935fb0ac18878e 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.io.imperihome.internal.model.device;
 
 import java.math.BigDecimal;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.HSBType;
 import org.openhab.core.library.types.PercentType;
index 06df992fb1c5b3969d7c6bf32b378ef8f259a325..1aa598303fcc54494f89898cb962b05797908684 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.model.device;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
@@ -44,17 +43,17 @@ public class TrippableDevice extends AbstractDevice {
         boolean tripped = false;
 
         if (item.getStateAs(OpenClosedType.class) != null) {
-            OpenClosedType state = (OpenClosedType) item.getStateAs(OpenClosedType.class);
+            OpenClosedType state = item.getStateAs(OpenClosedType.class);
             tripped = state == OpenClosedType.CLOSED;
         } else if (item.getStateAs(OnOffType.class) != null) {
-            OnOffType state = (OnOffType) item.getStateAs(OnOffType.class);
+            OnOffType state = item.getStateAs(OnOffType.class);
             tripped = state == OnOffType.ON;
         } else if (item.getStateAs(DecimalType.class) != null) {
-            DecimalType state = (DecimalType) item.getStateAs(DecimalType.class);
-            tripped = state.intValue() != 0;
+            DecimalType state = item.getStateAs(DecimalType.class);
+            tripped = state != null && state.intValue() != 0;
         } else if (item.getStateAs(StringType.class) != null) {
-            StringType state = (StringType) item.getStateAs(StringType.class);
-            tripped = StringUtils.isNotBlank(state.toString()) && !state.toString().trim().equals("ok");
+            StringType state = item.getStateAs(StringType.class);
+            tripped = state != null && !state.toString().isBlank() && !state.toString().trim().equals("ok");
         } else {
             logger.debug("Can't interpret state {} as tripped status", item.getState());
         }
index b659902127bc4196ee959124ce0cb8c1f0ee0898..9728013765025b3d4621e6c12479d7f5d0db4869 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.imperihome.internal.model.device;
 
-import org.apache.commons.lang.StringUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.types.State;
@@ -54,7 +53,8 @@ public class WindDevice extends AbstractNumericValueDevice {
             }
 
             NumericValueParam dirParam = new NumericValueParam(ParamType.DIRECTION, valueParam.getUnit(), null);
-            if (StringUtils.isEmpty(dirParam.getUnit())) {
+            String unit = dirParam.getUnit();
+            if (unit == null || unit.isEmpty()) {
                 dirParam.setUnit("Degrees");
             }
 
@@ -67,7 +67,7 @@ public class WindDevice extends AbstractNumericValueDevice {
     public void stateUpdated(Item item, State newState) {
         super.stateUpdated(item, newState);
 
-        DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+        DecimalType value = item.getStateAs(DecimalType.class);
         addParam(new NumericValueParam(ParamType.SPEED, getUnit(), value));
     }
 }
index 04b352913fd8deb37d70f9032f976f778d34b0f6..52143bc2e23c932a452b5d0505530a0ef9cb5184 100644 (file)
@@ -20,8 +20,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.BooleanUtils;
 import org.openhab.core.items.Item;
 import org.openhab.core.items.ItemRegistry;
 import org.openhab.core.items.ItemRegistryChangeListener;
@@ -144,11 +143,12 @@ public class ItemProcessor implements ItemRegistryChangeListener {
 
         String icon = issTags.get(TagType.ICON).get(0);
         if (!icon.toLowerCase().startsWith("http")) {
-            if (StringUtils.isEmpty(config.getRootUrl())) {
+            String rootUrl = config.getRootUrl();
+            if (rootUrl == null || rootUrl.isEmpty()) {
                 logger.error("Can't set icon; 'openhab.rootUrl' not set in configuration");
                 return;
             }
-            icon = config.getRootUrl() + "icon/" + icon;
+            icon = rootUrl + "icon/" + icon;
         }
 
         device.addParam(new DeviceParam(ParamType.DEFAULT_ICON, icon));
@@ -214,8 +214,9 @@ public class ItemProcessor implements ItemRegistryChangeListener {
             return issTags.get(TagType.LABEL).get(0);
         }
 
-        if (StringUtils.isNotBlank(item.getLabel())) {
-            String label = item.getLabel().trim();
+        String label = item.getLabel();
+        if (label != null && !label.isBlank()) {
+            label = label.trim();
             if (label.matches("\\[.*\\]$")) {
                 label = label.substring(0, label.indexOf('['));
             }
index 86627336d16b789f17920584603afc46532994b7..4e750474da79f4b0b128394d96f0e76cdd62d67b 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import javax.servlet.ServletException;
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.binding.BindingInfoRegistry;
@@ -375,8 +374,7 @@ public class NeeoService implements EventSubscriber, NetworkAddressChangeListene
      * @param brainId the non-empty brain id
      * @return the servlet for the brainId or null if none
      */
-    @Nullable
-    public NeeoBrainServlet getServlet(String brainId) {
+    public @Nullable NeeoBrainServlet getServlet(String brainId) {
         NeeoUtil.requireNotEmpty(brainId, "brainId cannot be empty");
 
         final String url = NeeoUtil.getServletUrl(brainId);
@@ -389,11 +387,10 @@ public class NeeoService implements EventSubscriber, NetworkAddressChangeListene
      * @param servletUrl a non-null, non-empty servlet URL
      * @return the servlet for the URL or null if not found
      */
-    @Nullable
-    private NeeoBrainServlet getServletByUrl(String servletUrl) {
+    private @Nullable NeeoBrainServlet getServletByUrl(String servletUrl) {
         NeeoUtil.requireNotEmpty(servletUrl, "ServletURL cannot be empty");
         for (NeeoBrainServlet servlet : servlets) {
-            if (StringUtils.equalsIgnoreCase(servletUrl, servlet.getServletUrl())) {
+            if (servletUrl.equalsIgnoreCase(servlet.getServletUrl())) {
                 return servlet;
             }
         }
@@ -410,9 +407,8 @@ public class NeeoService implements EventSubscriber, NetworkAddressChangeListene
         return Collections.singleton(ItemStateChangedEvent.TYPE);
     }
 
-    @Nullable
     @Override
-    public EventFilter getEventFilter() {
+    public @Nullable EventFilter getEventFilter() {
         return eventFilter;
     }
 
index 74f785b1d9068783b011eb9a71c19aefe0d9619c..4fbc6c674e3d2a6a125440680a7b35e074c020b1 100644 (file)
@@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.events.Event;
@@ -55,8 +55,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
     private final String servletUrl;
 
     /** Any event filters */
-    @Nullable
-    private final List<EventFilter> eventFilters;
+    private final @Nullable List<EventFilter> eventFilters;
 
     /**
      * Creates a servlet to serve the status/definitions web pages
@@ -112,7 +111,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
         final String pathInfo = NeeoUtil.decodeURIComponent(req.getPathInfo());
 
         // invalid path - probably someone typed the path in manually
-        if (StringUtils.isEmpty(pathInfo)) {
+        if (pathInfo.isEmpty()) {
             return;
         }
 
@@ -158,8 +157,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
      * @param paths the non-null, non-empty paths
      * @return the service that can handle the path or null if none can
      */
-    @Nullable
-    protected ServletService getService(String[] paths) {
+    protected @Nullable ServletService getService(String[] paths) {
         Objects.requireNonNull(paths, "paths cannot be null");
         if (paths.length == 0) {
             throw new IllegalArgumentException("paths cannot be of 0 length");
@@ -213,8 +211,7 @@ public abstract class AbstractServlet extends HttpServlet implements AutoCloseab
      *
      * @return the possibly null event filters;
      */
-    @Nullable
-    public List<EventFilter> getEventFilters() {
+    public @Nullable List<EventFilter> getEventFilters() {
         return eventFilters;
     }
 
index 2baefba2d3513bac7be188a840d9c76be1aafd4e..9322ca082825356ab066a2ed333284efee10e337 100644 (file)
@@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicReference;
 
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.http.HttpStatus;
@@ -521,11 +520,11 @@ public class NeeoApi implements AutoCloseable {
         }
 
         for (NeeoRecipe recipe : GSON.fromJson(resp.getContent(), NeeoRecipe[].class)) {
-            if (StringUtils.equalsIgnoreCase(recipe.getUid(), deviceKey)) {
+            if (deviceKey.equalsIgnoreCase(recipe.getUid())) {
                 final NeeoRecipeUrls urls = recipe.getUrls();
                 final String url = urls == null ? null : (on ? urls.getSetPowerOn() : urls.getSetPowerOff());
 
-                if (url != null && StringUtils.isNotEmpty(url)) {
+                if (url != null && !url.isEmpty()) {
                     final HttpResponse cmdResp = rqst.sendGetCommand(url);
                     if (cmdResp.getHttpCode() != HttpStatus.OK_200) {
                         throw cmdResp.createException();
index 1156915cdb5a9cf9af242048620103d21f326ff5..4cbf9420ee3f0617d8fe52394edf35ebb75f5968 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.thing.Thing;
@@ -122,7 +121,7 @@ public class NeeoDeviceDefinitions {
             // filter for only things that are still valid
             final ThingRegistry thingRegistry = context.getThingRegistry();
             for (NeeoDevice device : uidToDevice.values()) {
-                if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, device.getUid().getBindingId())) {
+                if (NeeoConstants.NEEOIO_BINDING_ID.equalsIgnoreCase(device.getUid().getBindingId())) {
                     devices.add(device);
                 } else {
                     if (thingRegistry.get(device.getUid().asThingUID()) != null) {
@@ -176,7 +175,7 @@ public class NeeoDeviceDefinitions {
         final List<NeeoDevice> devices = new ArrayList<>();
         for (NeeoDevice device : exposeAll || exposeNeeoBinding ? getAllDevices() : uidToDevice.values()) {
             if (device.getExposedChannels().length > 0 && !NeeoDeviceType.EXCLUDE.equals(device.getType())
-                    && StringUtils.isNotEmpty(device.getType().toString())) {
+                    && !device.getType().toString().isEmpty()) {
                 devices.add(device);
             }
         }
@@ -242,7 +241,7 @@ public class NeeoDeviceDefinitions {
         for (NeeoDevice device : uidToDevice.values()) {
             if (keys.isBound(device.getUid())) {
                 for (NeeoDeviceChannel channel : device.getExposedChannels()) {
-                    if (itemName == null || StringUtils.equalsIgnoreCase(itemName, channel.getItemName())) {
+                    if (itemName == null || itemName.equalsIgnoreCase(channel.getItemName())) {
                         channels.add(new AbstractMap.SimpleImmutableEntry<>(device, channel));
                     }
                 }
@@ -287,7 +286,7 @@ public class NeeoDeviceDefinitions {
     public List<NeeoDevice> getAllDevices() {
         final List<NeeoDevice> devices = new ArrayList<>();
         for (Entry<NeeoThingUID, NeeoDevice> entry : uidToDevice.entrySet()) {
-            if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, entry.getKey().getBindingId())) {
+            if (NeeoConstants.NEEOIO_BINDING_ID.equalsIgnoreCase(entry.getKey().getBindingId())) {
                 devices.add(entry.getValue());
             } else {
                 final Thing thing = context.getThingRegistry().get(entry.getKey().asThingUID());
index 3fa7e277bf5084c338df3a416ae39528855f09ab..8a8347ec7bd2c9010f6a3af5b9a171cda024327c 100644 (file)
@@ -20,10 +20,10 @@ import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jetty.http.HttpStatus;
 import org.openhab.core.thing.ThingUID;
@@ -178,7 +178,7 @@ public class NeeoDeviceKeys {
             sb.append("[");
             sb.append(entry.getKey());
             sb.append("=");
-            sb.append(StringUtils.join(entries.toArray()));
+            sb.append(entries.stream().map(Object::toString).collect(Collectors.joining()));
             sb.append("]");
         }
 
index 022da5e1092591241a5079b0558506ce5a492311..cee7d4ffa029f057c1dd0500296a8b88a9553c2a 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -138,7 +137,7 @@ public class NeeoItemValueConverter {
             return new NeeoItemValue(convertedState == UpDownType.UP);
 
         } else if (convertedState instanceof DecimalType) {
-            if (StringUtils.isEmpty(format) || channel.getType() == NeeoCapabilityType.SLIDER) {
+            if (format == null || format.isEmpty() || channel.getType() == NeeoCapabilityType.SLIDER) {
                 return new NeeoItemValue(((DecimalType) convertedState).toBigDecimal());
             }
         } else if (convertedState instanceof UnDefType) {
@@ -150,7 +149,7 @@ public class NeeoItemValueConverter {
         // Formatting must use the actual state (not converted state) to avoid
         // issues where a decimal converted to string or otherwise
         String itemValue;
-        if (format != null && StringUtils.isNotEmpty(format)) {
+        if (format != null && !format.isEmpty()) {
             if (state instanceof UnDefType) {
                 itemValue = formatUndefined(format);
             } else if (state instanceof Type) {
@@ -230,7 +229,7 @@ public class NeeoItemValueConverter {
         Objects.requireNonNull(item, "item cannot be null");
         Objects.requireNonNull(eventType, "eventType cannot be null");
 
-        if (actionValue == null || StringUtils.isEmpty(actionValue)) {
+        if (actionValue == null || actionValue.isEmpty()) {
             return null;
         }
 
@@ -265,9 +264,9 @@ public class NeeoItemValueConverter {
                 }
                 break;
             case "switch":
-                if (StringUtils.equalsIgnoreCase("true", actionValue)) {
+                if ("true".equalsIgnoreCase(actionValue)) {
                     return OnOffType.ON;
-                } else if (StringUtils.equalsIgnoreCase("false", actionValue)) {
+                } else if ("false".equalsIgnoreCase(actionValue)) {
                     return OnOffType.OFF;
                 }
                 break;
index 3bee22d7bcc74b941f5681c254db4fb1ed5c4e0a..db872cf80e8a8637bedf1658996b461d389d51fa 100644 (file)
@@ -24,7 +24,6 @@ import java.util.concurrent.Future;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -210,7 +209,7 @@ public class NeeoUtil {
         resp.setContentType("application/json");
         resp.setCharacterEncoding("UTF-8");
         final PrintWriter pw = resp.getWriter();
-        if (StringUtils.isEmpty(str)) {
+        if (str.isEmpty()) {
             pw.print("{}");
         } else {
             pw.print(str);
@@ -267,7 +266,7 @@ public class NeeoUtil {
      */
     public static void requireNotEmpty(String value, String msg) {
         Objects.requireNonNull(value, msg);
-        if (StringUtils.isEmpty(value)) {
+        if (value.isEmpty()) {
             throw new IllegalArgumentException(msg);
         }
     }
@@ -318,7 +317,7 @@ public class NeeoUtil {
 
         if (cmd.isEnum()) {
             for (Command cmdEnum : cmd.getEnumConstants()) {
-                if (StringUtils.equalsIgnoreCase(((Enum<?>) cmdEnum).name(), enumName)) {
+                if (((Enum<?>) cmdEnum).name().equalsIgnoreCase(enumName)) {
                     return cmdEnum;
                 }
             }
@@ -347,14 +346,14 @@ public class NeeoUtil {
     public static String getLabel(@Nullable Item item, @Nullable ChannelType channelType) {
         if (item != null) {
             final String label = item.getLabel();
-            if (label != null && StringUtils.isNotEmpty(label)) {
+            if (label != null && !label.isEmpty()) {
                 return label;
             }
         }
 
         if (channelType != null) {
             final String label = channelType.getLabel();
-            if (StringUtils.isNotEmpty(label)) {
+            if (!label.isEmpty()) {
                 return label;
             }
         }
@@ -374,8 +373,8 @@ public class NeeoUtil {
         if (item != null) {
             final StateDescription sd = item.getStateDescription();
             final String format = sd == null ? null : sd.getPattern();
-            if (StringUtils.isEmpty(format)) {
-                if (StringUtils.equalsIgnoreCase("datetime", item.getType())) {
+            if (format == null || format.isEmpty()) {
+                if ("datetime".equalsIgnoreCase(item.getType())) {
                     return "%tF %<tT";
                 }
             } else {
@@ -385,8 +384,8 @@ public class NeeoUtil {
 
         if (channelType != null) {
             final String format = channelType.getState() == null ? null : channelType.getState().getPattern();
-            if (StringUtils.isEmpty(format)) {
-                if (StringUtils.equalsIgnoreCase("datetime", channelType.getItemType())) {
+            if (format == null || format.isEmpty()) {
+                if ("datetime".equalsIgnoreCase(channelType.getItemType())) {
                     return "%tF %<tT";
                 }
             } else {
@@ -406,7 +405,7 @@ public class NeeoUtil {
     public static String getUniqueLabel(Set<String> labels, String itemLabel) {
         Objects.requireNonNull(labels, "labels cannot be null");
 
-        String label = StringUtils.isEmpty(itemLabel) ? "NA" : itemLabel;
+        String label = itemLabel.isEmpty() ? "NA" : itemLabel;
         int idx = 0;
         if (labels.contains(label)) {
             do {
@@ -432,7 +431,7 @@ public class NeeoUtil {
 
         if (groupId != null) {
             for (ChannelGroupDefinition cgd : thingType.getChannelGroupDefinitions()) {
-                if (StringUtils.equals(groupId, cgd.getId())) {
+                if (Objects.equals(groupId, cgd.getId())) {
                     return cgd.getLabel();
                 }
             }
index b1abc54cae6b65aeca763e58f215ce1f1d061467..b492f38ae6df8fe3cb073fe1bf3536480a22d226 100644 (file)
@@ -20,7 +20,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -101,8 +101,9 @@ class OpenHabToDeviceConverter {
                         .getChannelType(channel.getChannelTypeUID());
 
                 NeeoCapabilityType type = NeeoCapabilityType.EXCLUDE;
-                if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOBINDING_BINDING_ID, thingUID.getBindingId())) {
-                    if (StringUtils.startsWithIgnoreCase(thingUID.getAsString(), NeeoConstants.NEEOBINDING_DEVICE_ID)) {
+                if (NeeoConstants.NEEOBINDING_BINDING_ID.equalsIgnoreCase(thingUID.getBindingId())) {
+                    if (thingUID.getAsString().toLowerCase()
+                            .startsWith(NeeoConstants.NEEOBINDING_DEVICE_ID.toLowerCase())) {
                         // all device channels are currently macros - so buttons are appropriate
                         type = NeeoCapabilityType.BUTTON;
                     } else {
@@ -127,7 +128,7 @@ class OpenHabToDeviceConverter {
             return null;
         }
 
-        if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOBINDING_BINDING_ID, thing.getUID().getBindingId())) {
+        if (NeeoConstants.NEEOBINDING_BINDING_ID.equalsIgnoreCase(thing.getUID().getBindingId())) {
             final Map<String, String> properties = thing.getProperties();
             /** The following properties have matches in org.openhab.binding.neeo.NeeoDeviceHandler.java */
             String neeoType = properties.get("Type");
@@ -145,7 +146,7 @@ class OpenHabToDeviceConverter {
             final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay);
 
             final String dc = properties.get("Device Capabilities");
-            final String[] deviceCapabilities = StringUtils.isEmpty(dc) ? new String[0] : StringUtils.split(dc, ',');
+            final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ',');
 
             try {
                 return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0,
@@ -174,9 +175,9 @@ class OpenHabToDeviceConverter {
      * @param value a possibly null, possibly empty value to parse
      * @return an Integer or null if not a number
      */
-    @Nullable
-    private static Integer parseInteger(String value) {
-        if (StringUtils.isEmpty(value)) {
+
+    private static @Nullable Integer parseInteger(String value) {
+        if (value.isEmpty()) {
             return null;
         }
         try {
@@ -194,7 +195,7 @@ class OpenHabToDeviceConverter {
      */
     @Nullable
     List<NeeoDeviceChannel> getNeeoDeviceChannel(String itemName) {
-        if (StringUtils.isEmpty(itemName)) {
+        if (itemName.isEmpty()) {
             return null;
         }
 
index 0d7a517bcaee2ae77bd740062f4912e5cb927c14..0931f2ed4fa15f5dbcb1e50a14850a4bfa6dda67 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.io.neeo.internal;
 import java.util.Objects;
 import java.util.UUID;
 
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.binding.BindingInfoRegistry;
 import org.openhab.core.events.EventPublisher;
index 4f8c81ddb14efac1e8cbc931b3004549435a6699..a5f1864068ec727bc1012831090a1540b70fa48b 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.binding.BindingInfo;
@@ -104,7 +104,7 @@ public class TokenSearch {
             final Thing thing = context.getThingRegistry().get(device.getUid().asThingUID());
             if (thing != null) {
                 final String location = thing.getLocation();
-                if (location != null && StringUtils.isNotEmpty(location)) {
+                if (location != null && !location.isEmpty()) {
                     score += search(location, needles);
                 }
 
@@ -160,13 +160,13 @@ public class TokenSearch {
         int arrayLength = needles.length;
         for (int i = 0; i < arrayLength; i++) {
             String needle = needles[i];
-            int stringPos = StringUtils.indexOfIgnoreCase(haystack, needle);
+            int stringPos = haystack.toLowerCase().indexOf(needle.toLowerCase());
             int tokenScore = 0;
             if (stringPos > -1) {
                 if (needle.length() < 2) {
                     tokenScore = 1;
                 } else {
-                    if (StringUtils.equalsIgnoreCase(haystack, needle)) {
+                    if (haystack.equalsIgnoreCase(needle)) {
                         tokenScore = 6;
                     } else if (stringPos == 0) {
                         tokenScore = 2;
index 546ffcbee86b79d3177709ca9dfe4f6607ad1b93..674d3f4c258f1a7c9ca1d07832840fb1f3352348 100644 (file)
@@ -36,7 +36,6 @@ import javax.jmdns.ServiceInfo;
 import javax.jmdns.ServiceListener;
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.common.ThreadPoolManager;
@@ -142,9 +141,9 @@ public class MdnsBrainDiscovery extends AbstractBrainDiscovery {
                     final String[] ipAddresses = gson.fromJson(json, String[].class);
                     if (ipAddresses != null) {
                         logger.debug("Restoring discovery from {}: {}", file.getAbsolutePath(),
-                                StringUtils.join(ipAddresses, ','));
+                                String.join(",", ipAddresses));
                         for (String ipAddress : ipAddresses) {
-                            if (StringUtils.isNotBlank(ipAddress)) {
+                            if (!ipAddress.isBlank()) {
                                 addDiscovered(ipAddress, false);
                             }
                         }
@@ -184,7 +183,7 @@ public class MdnsBrainDiscovery extends AbstractBrainDiscovery {
     @Nullable
     private Entry<String, InetAddress> getNeeoBrainInfo(ServiceInfo info) {
         Objects.requireNonNull(info, "info cannot be null");
-        if (!StringUtils.equals("neeo", info.getApplication())) {
+        if (!"neeo".equals(info.getApplication())) {
             logger.debug("A non-neeo application was found for the NEEO MDNS: {}", info);
             return null;
         }
@@ -338,7 +337,7 @@ public class MdnsBrainDiscovery extends AbstractBrainDiscovery {
         systemsLock.lock();
         try {
             final Optional<NeeoSystemInfo> sysInfo = systems.keySet().stream()
-                    .filter(e -> StringUtils.equals(servletUrl, NeeoUtil.getServletUrl(e.getHostname()))).findFirst();
+                    .filter(e -> servletUrl.equals(NeeoUtil.getServletUrl(e.getHostname()))).findFirst();
             if (sysInfo.isPresent()) {
                 systems.remove(sysInfo.get());
                 fireRemoved(sysInfo.get());
@@ -371,7 +370,7 @@ public class MdnsBrainDiscovery extends AbstractBrainDiscovery {
         try {
             NeeoSystemInfo foundInfo = null;
             for (NeeoSystemInfo existingSysInfo : systems.keySet()) {
-                if (StringUtils.equals(existingSysInfo.getHostname(), brainInfo.getKey())) {
+                if (existingSysInfo.getHostname().equals(brainInfo.getKey())) {
                     foundInfo = existingSysInfo;
                     break;
                 }
@@ -398,7 +397,7 @@ public class MdnsBrainDiscovery extends AbstractBrainDiscovery {
             final List<String> ipAddresses = systems.values().stream().map(e -> e.getHostAddress())
                     .collect(Collectors.toList());
 
-            logger.debug("Saving brain's discovered to {}: {}", file.toPath(), StringUtils.join(ipAddresses, ','));
+            logger.debug("Saving brain's discovered to {}: {}", file.toPath(), String.join(",", ipAddresses));
 
             final String json = gson.toJson(ipAddresses);
             final byte[] contents = json.getBytes(StandardCharsets.UTF_8);
index 7a686cd6aa9f04740031f778e4d29e3237842fb3..3f030052575cd0b4f54f6faae3dc4607ab6575f4 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
@@ -58,11 +57,11 @@ public enum ItemSubType {
      * @return the ItemSubType type
      */
     public static ItemSubType parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return NONE;
         }
         for (ItemSubType enm : ItemSubType.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return enm;
             }
         }
@@ -77,11 +76,11 @@ public enum ItemSubType {
      * @return true if valid, false otherwise
      */
     public static boolean isValid(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return true;
         }
         for (ItemSubType enm : ItemSubType.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return true;
             }
         }
index 7b5c91683093cd1d7c994a78ae9ea1dad6d6f385..0f8bdbc43cedb4f19ff6da00e721bdcf63d51d55 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
@@ -57,11 +56,11 @@ public enum ListUiAction {
      * @return the ListUiAction type
      */
     public static ListUiAction parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return CLOSE;
         }
         for (ListUiAction enm : ListUiAction.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return enm;
             }
         }
@@ -76,11 +75,11 @@ public enum ListUiAction {
      * @return true if valid, false otherwise
      */
     public static boolean isValid(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return true;
         }
         for (ListUiAction enm : ListUiAction.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return true;
             }
         }
index 1df5f8272df29d65964317eb38b978cfdc16a6de..7714773d6785eeca1a3dc781c730e766815f556a 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -110,28 +109,28 @@ public class NeeoButtonGroup {
      */
     @Nullable
     public static NeeoButtonGroup parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return null;
         }
 
         // note: if we add more - might want to switch this into a loop
-        if (StringUtils.equalsIgnoreCase(text, POWERONOFF.text)) {
+        if (text.equalsIgnoreCase(POWERONOFF.text)) {
             return POWERONOFF;
         }
 
-        if (StringUtils.equalsIgnoreCase(text, VOLUMES.text)) {
+        if (text.equalsIgnoreCase(VOLUMES.text)) {
             return VOLUMES;
         }
 
-        if (StringUtils.equalsIgnoreCase(text, CHANNELS.text)) {
+        if (text.equalsIgnoreCase(CHANNELS.text)) {
             return CHANNELS;
         }
 
-        if (StringUtils.equalsIgnoreCase(text, CURSORUPDOWN.text)) {
+        if (text.equalsIgnoreCase(CURSORUPDOWN.text)) {
             return CURSORUPDOWN;
         }
 
-        if (StringUtils.equalsIgnoreCase(text, CURSORLEFTRIGHT.text)) {
+        if (text.equalsIgnoreCase(CURSORLEFTRIGHT.text)) {
             return CURSORLEFTRIGHT;
         }
 
@@ -145,7 +144,7 @@ public class NeeoButtonGroup {
      * @return true if matches, false otherwise
      */
     public boolean equals(String text) {
-        return StringUtils.equalsIgnoreCase(this.text, text);
+        return this.text.equalsIgnoreCase(text);
     }
 
     @Override
index 4a7ef256ea137888bb52ff02a0e52a2331c0ee57..6e00472234cf469dd1d66047af316af7ce409ed7 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.thing.type.ChannelType;
@@ -72,11 +71,11 @@ public enum NeeoCapabilityType {
      * @return the NeeoCapabilityType type
      */
     public static NeeoCapabilityType parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return EXCLUDE;
         }
         for (NeeoCapabilityType enm : NeeoCapabilityType.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return enm;
             }
         }
@@ -91,11 +90,12 @@ public enum NeeoCapabilityType {
      * @return the best guess {@link NeeoCapabilityType}
      */
     public static NeeoCapabilityType guessType(@Nullable ChannelType channelType) {
-        if (channelType == null || StringUtils.isEmpty(channelType.getItemType())) {
+        String itemType = channelType == null ? null : channelType.getItemType();
+        if (channelType == null || itemType == null || itemType.isEmpty()) {
             return NeeoCapabilityType.EXCLUDE;
         }
 
-        switch (channelType.getItemType().toLowerCase()) {
+        switch (itemType.toLowerCase()) {
             case "switch":
             case "contact":
             case "rollershutter":
index 46324dd25058e6695d4fac0d5e5ebc5d96c76077..e18440764ceed7e5ed336dd3e853ebc1772faae8 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -72,14 +71,13 @@ public class NeeoDevice {
     /**
      * The specific name for the device, if null - NEEO will default it based on the type (ie "ACCESSORY", etc)
      */
-    @Nullable
-    private final String specificName;
+
+    private final @Nullable String specificName;
 
     /**
      * The icon name to assign. If null, NEEO will default it to a standard icon based on the type
      */
-    @Nullable
-    private final String iconName;
+    private final @Nullable String iconName;
 
     /**
      * The driver version for the device
@@ -173,7 +171,7 @@ public class NeeoDevice {
         this.driverVersion = driverVersion;
         this.type = type;
         this.manufacturer = manufacturer;
-        this.name = name == null || StringUtils.isEmpty(name) ? "(N/A)" : name;
+        this.name = name == null || name.isEmpty() ? "(N/A)" : name;
         this.specificName = specificName;
         this.iconName = iconName;
         this.channels.addAll(channels);
@@ -224,8 +222,7 @@ public class NeeoDevice {
      *
      * @return a possibly null, possibly empty specific name
      */
-    @Nullable
-    public String getSpecificName() {
+    public @Nullable String getSpecificName() {
         return specificName;
     }
 
@@ -234,8 +231,7 @@ public class NeeoDevice {
      *
      * @return a possibly null, possibly empty icon name
      */
-    @Nullable
-    public String getIconName() {
+    public @Nullable String getIconName() {
         return iconName;
     }
 
@@ -262,8 +258,7 @@ public class NeeoDevice {
      *
      * @return a possibly null {@link NeeoDeviceTiming}
      */
-    @Nullable
-    public NeeoDeviceTiming getDeviceTiming() {
+    public @Nullable NeeoDeviceTiming getDeviceTiming() {
         if (supportTiming(this)) {
             return timing;
         }
@@ -287,8 +282,7 @@ public class NeeoDevice {
     public NeeoDeviceChannel[] getExposedChannels() {
         final List<NeeoDeviceChannel> exposedChannels = new ArrayList<>(channels.size());
         for (NeeoDeviceChannel channel : channels) {
-            if (channel.getType() != NeeoCapabilityType.EXCLUDE
-                    && StringUtils.isNotEmpty(channel.getType().toString())) {
+            if (channel.getType() != NeeoCapabilityType.EXCLUDE && !channel.getType().toString().isEmpty()) {
                 exposedChannels.add(channel);
             }
         }
@@ -308,8 +302,8 @@ public class NeeoDevice {
         for (NeeoDeviceChannel channel : channels) {
 
             final boolean notExcluded = channel.getType() != NeeoCapabilityType.EXCLUDE;
-            final boolean notEmpty = StringUtils.isNotEmpty(channel.getType().toString());
-            final boolean isItemMatch = StringUtils.equalsIgnoreCase(itemName, channel.getItemName());
+            final boolean notEmpty = !channel.getType().toString().isEmpty();
+            final boolean isItemMatch = itemName.equalsIgnoreCase(channel.getItemName());
 
             logger.trace("isExposed(channel): {} --- notExcluded({}) -- notEmpty({}) -- isItemMatch({}) -- {}",
                     itemName, notExcluded, notEmpty, isItemMatch, channel);
@@ -330,13 +324,12 @@ public class NeeoDevice {
      * @param channelNbr the channel nbr
      * @return the channel or null if none found
      */
-    @Nullable
-    public NeeoDeviceChannel getChannel(String itemName, ItemSubType subType, int channelNbr) {
+    public @Nullable NeeoDeviceChannel getChannel(String itemName, ItemSubType subType, int channelNbr) {
         NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
         Objects.requireNonNull(subType, "subType cannot be null");
 
         for (NeeoDeviceChannel channel : channels) {
-            if (StringUtils.equalsIgnoreCase(itemName, channel.getItemName()) && channel.getSubType() == subType
+            if (itemName.equalsIgnoreCase(channel.getItemName()) && channel.getSubType() == subType
                     && channel.getChannelNbr() == channelNbr) {
                 return channel;
             }
@@ -351,11 +344,10 @@ public class NeeoDevice {
      * @param context the non-null service context
      * @return the new {@link NeeoDevice} or null if the {@link Thing} doesn't exist anymore
      */
-    @Nullable
-    public NeeoDevice merge(ServiceContext context) {
+    public @Nullable NeeoDevice merge(ServiceContext context) {
         Objects.requireNonNull(context, "context cannot be null");
 
-        if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, uid.getBindingId())) {
+        if (NeeoConstants.NEEOIO_BINDING_ID.equals(uid.getBindingId())) {
             return this;
         }
 
index 02f938f887b8f3c5010f6df44527e129063741e5..1959915e9b6e251447255f914a2deb726035e591 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.type.ChannelKind;
 
@@ -50,11 +49,11 @@ public enum NeeoDeviceChannelKind {
      * @return the NeeoDeviceChannelKind type
      */
     public static NeeoDeviceChannelKind parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return ITEM;
         }
         for (NeeoDeviceChannelKind enm : NeeoDeviceChannelKind.values()) {
-            if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+            if (text.equalsIgnoreCase(enm.text)) {
                 return enm;
             }
         }
index 00b389815c70e3da196e9b425cc2a20204dae349..5695a6eb06526072d98e31f097530bfc5caf86a2 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.items.Item;
 import org.openhab.core.library.types.PercentType;
@@ -64,7 +63,7 @@ public class NeeoDeviceChannelRange {
         }
         this.minValue = minValue;
         this.maxValue = maxValue;
-        this.unit = StringUtils.isEmpty(unit) ? UNIT_NUMBER : unit;
+        this.unit = unit.isEmpty() ? UNIT_NUMBER : unit;
     }
 
     /**
index 2a365259cd99df42eacf6b30e0ddf48a564daa1f..33446c0ddd73c576de9ede69255290978949c9cc 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -51,7 +50,7 @@ public class NeeoDeviceType {
      */
     private NeeoDeviceType(final String text) {
         Objects.requireNonNull(text, "text is required");
-        this.text = StringUtils.equalsIgnoreCase(text, ACCESSORY) ? ACCESSOIRE.text : text;
+        this.text = text.equalsIgnoreCase(ACCESSORY) ? ACCESSOIRE.text : text;
     }
 
     /**
@@ -61,11 +60,11 @@ public class NeeoDeviceType {
      * @return the possibly null NeeoDeviceType
      */
     public static NeeoDeviceType parse(final String text) {
-        if (StringUtils.isEmpty(text)) {
+        if (text.isEmpty()) {
             return EXCLUDE;
         }
 
-        if (StringUtils.equalsIgnoreCase(text, ACCESSOIRE.text) || StringUtils.equalsIgnoreCase(text, ACCESSORY)) {
+        if (text.equalsIgnoreCase(ACCESSOIRE.text) || text.equalsIgnoreCase(ACCESSORY)) {
             return ACCESSOIRE;
         }
 
@@ -82,7 +81,7 @@ public class NeeoDeviceType {
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
-        return StringUtils.equals(text, ((NeeoDeviceType) obj).text);
+        return text.equals(((NeeoDeviceType) obj).text);
     }
 
     @Override
index ba5e820810e1b369096f8a0085fb95d36dea23dc..e41a91ae2868ea06a3d05e3571094fcda7a71bd9 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.neeo.internal.models;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.NeeoUtil;
@@ -29,16 +28,13 @@ public class NeeoDirectoryResultItem {
     private final String title;
 
     /** The URI to the thumbnail representing the item */
-    @Nullable
-    private final String thumbnailUri;
+    private final @Nullable String thumbnailUri;
 
     /** The browse identifier (reflected back in a request if this item is a container) */
-    @Nullable
-    private final String browseIdentifier;
+    private final @Nullable String browseIdentifier;
 
     /** The action identifier (reflected back in a request if this is a leaf) */
-    @Nullable
-    private final String actionIdentifier;
+    private final @Nullable String actionIdentifier;
 
     /** Whether the item is queueable (no explanation posted by NEEO) */
     private final boolean isQueueable;
@@ -57,7 +53,8 @@ public class NeeoDirectoryResultItem {
             @Nullable String actionIdentifier, boolean isQueueable) {
         NeeoUtil.requireNotEmpty(title, "title cannot be empty");
 
-        if (StringUtils.isEmpty(browseIdentifier) && StringUtils.isEmpty(actionIdentifier)) {
+        if ((browseIdentifier == null || browseIdentifier.isEmpty())
+                && (actionIdentifier == null || actionIdentifier.isEmpty())) {
             throw new IllegalArgumentException("Either browserIdentifier or actionIdentifier must be specified");
         }
 
index 704cf053ba54e61859603e51650eb84f7f4426e7..ebb15b2d485d9297f568c7f57eb7cf38daee6c69 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.neeo.internal.models;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.NeeoUtil;
@@ -43,7 +42,7 @@ public class NeeoNotification {
         NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
 
         this.type = deviceKey + ":" + itemName;
-        this.data = data == null || (data instanceof String && StringUtils.isEmpty(data.toString())) ? "-" : data;
+        this.data = data == null || (data instanceof String && data.toString().isEmpty()) ? "-" : data;
     }
 
     /**
index 1afea29233c386adf72ad6e4d5f3f6891c84a6b5..86905e1ee7f6e4507265a33b0efedc987b8228f9 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.io.neeo.internal.models;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.NeeoConstants;
@@ -56,14 +55,13 @@ public class NeeoSensorNotification {
         NeeoUtil.requireNotEmpty(deviceKey, "deviceKey cannot be empty");
         NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
 
-        this.type = overrideType == null || StringUtils.isEmpty(overrideType)
-                ? NeeoConstants.NEEO_SENSOR_NOTIFICATION_TYPE
+        this.type = overrideType == null || overrideType.isEmpty() ? NeeoConstants.NEEO_SENSOR_NOTIFICATION_TYPE
                 : overrideType;
         this.data = new SensorNotificationData(
                 deviceKey + ":" + itemName
-                        + (StringUtils.endsWithIgnoreCase(itemName, NeeoConstants.NEEO_SENSOR_SUFFIX) ? ""
+                        + (itemName.toLowerCase().endsWith(NeeoConstants.NEEO_SENSOR_SUFFIX.toLowerCase()) ? ""
                                 : NeeoConstants.NEEO_SENSOR_SUFFIX),
-                data == null || (data instanceof String && StringUtils.isEmpty(data.toString())) ? "-" : data);
+                data == null || (data instanceof String && data.toString().isEmpty()) ? "-" : data);
     }
 
     /**
index 3f6b0c4d1b93459ccc62aec173abb253b1cd1c74..6f01d8df5d4ad7ebc3a0558d6d2d495921ebe6ef 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.io.neeo.internal.models;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.NeeoUtil;
@@ -81,7 +80,7 @@ public class NeeoSystemInfo {
      * @return true if greater than or equal, false otherwise
      */
     public boolean isFirmwareGreaterOrEqual(String checkFirmwareVersion) {
-        if (StringUtils.isEmpty(checkFirmwareVersion)) {
+        if (checkFirmwareVersion.isEmpty()) {
             return true;
         }
 
@@ -136,6 +135,6 @@ public class NeeoSystemInfo {
             return false;
         }
 
-        return StringUtils.equals(hostname, ((NeeoSystemInfo) obj).hostname);
+        return hostname.equals(((NeeoSystemInfo) obj).hostname);
     }
 }
index 26adb3a10ee693c58bafcdeed71c696e03f4e169..5ae24800bce474aa0ef56953f9c0cf58712b92e9 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.io.neeo.internal.models;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.io.neeo.internal.NeeoConstants;
index 3b513b6b9969013e49886797f176d42f57097399..f85e95c90dfbed37a2f4104d2cc49367e098e1e5 100644 (file)
@@ -16,7 +16,6 @@ import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.NeeoConstants;
@@ -90,16 +89,16 @@ public class NeeoBrainDeviceSerializer implements JsonSerializer<NeeoDevice> {
         jsonObject.add("device", deviceObj);
 
         final String specificName = device.getSpecificName();
-        if (specificName != null && StringUtils.isNotEmpty(specificName)) {
+        if (specificName != null && !specificName.isEmpty()) {
             deviceObj.addProperty("specificname", specificName);
             jsonObject.addProperty("specificname", specificName);
-        } else if (StringUtils.isNotEmpty(deviceName)) {
+        } else if (!deviceName.isEmpty()) {
             deviceObj.addProperty("specificname", deviceName);
             jsonObject.addProperty("specificname", deviceName);
         }
 
         final String iconName = device.getIconName();
-        if (iconName != null && StringUtils.isNotEmpty(iconName)) {
+        if (iconName != null && !iconName.isEmpty()) {
             deviceObj.addProperty("icon", iconName);
             jsonObject.addProperty("icon", iconName);
         }
@@ -113,19 +112,19 @@ public class NeeoBrainDeviceSerializer implements JsonSerializer<NeeoDevice> {
 
             final String uniqueItemName = channel.getUniqueItemName();
             final String sensorItemName = uniqueItemName
-                    + (StringUtils.endsWithIgnoreCase(uniqueItemName, NeeoConstants.NEEO_SENSOR_SUFFIX) ? ""
+                    + (uniqueItemName.toLowerCase().endsWith(NeeoConstants.NEEO_SENSOR_SUFFIX.toLowerCase()) ? ""
                             : NeeoConstants.NEEO_SENSOR_SUFFIX);
 
             if (capabilityType == NeeoCapabilityType.BUTTON) {
-                final String name = StringUtils.isEmpty(channel.getLabel()) ? uniqueItemName : channel.getLabel();
+                final String name = channel.getLabel().isEmpty() ? uniqueItemName : channel.getLabel();
 
                 if (channel.getKind() == NeeoDeviceChannelKind.TRIGGER) {
                     final String path = compPath + "/button/trigger";
                     capabilities.add(createBase(name, channel.getLabel(), capabilityType.toString(), path));
                 } else {
                     final String value = channel.getValue();
-                    final String path = compPath + "/button/" + (value == null || StringUtils.isEmpty(value) ? "on"
-                            : NeeoUtil.encodeURIComponent(value.trim()));
+                    final String path = compPath + "/button/"
+                            + (value == null || value.isEmpty() ? "on" : NeeoUtil.encodeURIComponent(value.trim()));
                     capabilities.add(createBase(name, channel.getLabel(), capabilityType.toString(), path));
                 }
             } else if (capabilityType == NeeoCapabilityType.SENSOR_POWER) {
@@ -187,8 +186,7 @@ public class NeeoBrainDeviceSerializer implements JsonSerializer<NeeoDevice> {
                 }
             } else if (capabilityType == NeeoCapabilityType.IMAGEURL) {
                 final String value = channel.getValue();
-                final String size = (value == null || StringUtils.isEmpty(value) ? "large" : value.trim())
-                        .toLowerCase();
+                final String size = (value == null || value.isEmpty() ? "large" : value.trim()).toLowerCase();
 
                 final JsonObject jo = createBase(uniqueItemName, channel.getLabel(), capabilityType.toString(),
                         compPath + "/image/actor", "sensor", new JsonPrimitive(sensorItemName));
@@ -277,7 +275,7 @@ public class NeeoBrainDeviceSerializer implements JsonSerializer<NeeoDevice> {
         compObj.addProperty("type", type);
 
         compObj.addProperty("path", NeeoUtil.encodeURIComponent(path));
-        if (sensor != null && StringUtils.isNotEmpty(sensorName)) {
+        if (sensor != null && sensorName != null && !sensorName.isEmpty()) {
             if (sensor instanceof JsonPrimitive) {
                 compObj.addProperty(sensorName, sensor.getAsString());
             } else {
index e81b1bb50d3004af38c850cfd7206bb1a371ef8f..6c1bbcc13342b6fa1cb48b6e149c63bf38da4d40 100644 (file)
@@ -16,7 +16,6 @@ import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.items.Item;
@@ -99,12 +98,13 @@ public class NeeoDeviceChannelSerializer
                 final Item item = localContext.getItemRegistry().getItem(chnl.getItemName());
                 itemType = item.getType();
 
-                if (StringUtils.isNotEmpty(item.getLabel())) {
-                    itemLabel = item.getLabel();
+                String label = item.getLabel();
+                if (label != null && !label.isEmpty()) {
+                    itemLabel = label;
                 }
 
                 for (Class<? extends Command> cmd : item.getAcceptedCommandTypes()) {
-                    if (!StringUtils.equalsIgnoreCase(cmd.getSimpleName(), "refreshtype")) {
+                    if (!cmd.getSimpleName().equalsIgnoreCase("refreshtype")) {
                         commandTypes.add(cmd.getSimpleName().toLowerCase());
                     }
                 }
@@ -127,7 +127,7 @@ public class NeeoDeviceChannelSerializer
                 itemType = "N/A";
             }
 
-            if (StringUtils.isNotEmpty(itemLabel)) {
+            if (!itemLabel.isEmpty()) {
                 switch (chnl.getSubType()) {
                     case HUE:
                         itemType += " (Hue)";
@@ -172,7 +172,7 @@ public class NeeoDeviceChannelSerializer
         final JsonObject jo = (JsonObject) elm;
         final String itemName = NeeoUtil.getString(jo, "itemName");
 
-        if (itemName == null || StringUtils.isEmpty(itemName)) {
+        if (itemName == null || itemName.isEmpty()) {
             throw new JsonParseException("Element requires an itemName attribute: " + elm);
         }
 
@@ -201,19 +201,17 @@ public class NeeoDeviceChannelSerializer
                 final boolean labelVisible = jo.has("labelVisible") ? jo.get("labelVisible").getAsBoolean() : true;
 
                 return new NeeoDeviceChannelText(kind, itemName, channelNbr, capType, itemSubType,
-                        label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range,
-                        labelVisible);
+                        label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range, labelVisible);
             } else if (capType == NeeoCapabilityType.DIRECTORY) {
                 final NeeoDeviceChannelDirectoryListItem[] listItems = jo.has("listItems")
                         ? context.deserialize(jo.get("listItems"), NeeoDeviceChannelDirectoryListItem[].class)
                         : new NeeoDeviceChannelDirectoryListItem[0];
 
                 return new NeeoDeviceChannelDirectory(kind, itemName, channelNbr, capType, itemSubType,
-                        label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range,
-                        listItems);
+                        label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range, listItems);
             } else {
                 return new NeeoDeviceChannel(kind, itemName, channelNbr, capType, itemSubType,
-                        label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range);
+                        label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range);
             }
         } catch (NullPointerException | IllegalArgumentException e) {
             throw new JsonParseException(e);
index c3e9713d80a1486a30c85868c650c85aee6a4de7..4af87314ebcfd5d732ab3909b760d0c7b11327e1 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Objects;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.io.neeo.NeeoService;
 import org.openhab.io.neeo.internal.NeeoBrainServlet;
@@ -69,11 +68,9 @@ public class BrainDashboardService extends DefaultServletService {
      */
     @Override
     public boolean canHandleRoute(String[] paths) {
-        return paths.length >= 1 && (StringUtils.equalsIgnoreCase(paths[0], "brainstatus")
-                || StringUtils.equalsIgnoreCase(paths[0], "addbrain")
-                || StringUtils.equalsIgnoreCase(paths[0], "removebrain")
-                || StringUtils.equalsIgnoreCase(paths[0], "getlog")
-                || StringUtils.equalsIgnoreCase(paths[0], "blinkled"));
+        return paths.length >= 1 && (paths[0].equalsIgnoreCase("brainstatus") || paths[0].equalsIgnoreCase("addbrain")
+                || paths[0].equalsIgnoreCase("removebrain") || paths[0].equalsIgnoreCase("getlog")
+                || paths[0].equalsIgnoreCase("blinkled"));
     }
 
     /**
@@ -88,13 +85,13 @@ public class BrainDashboardService extends DefaultServletService {
         Objects.requireNonNull(resp, "resp cannot be null");
 
         try {
-            if (StringUtils.equalsIgnoreCase(paths[0], "brainstatus")) {
+            if (paths[0].equalsIgnoreCase("brainstatus")) {
                 final List<BrainStatus> status = new ArrayList<>();
                 for (NeeoBrainServlet servlet : service.getServlets()) {
                     status.add(servlet.getBrainStatus());
                 }
                 NeeoUtil.write(resp, gson.toJson(status));
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "blinkled")) {
+            } else if (paths[0].equalsIgnoreCase("blinkled")) {
                 final String brainId = req.getParameter("brainid");
                 if (brainId == null) {
                     NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
@@ -112,7 +109,7 @@ public class BrainDashboardService extends DefaultServletService {
                         }
                     }
                 }
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "getlog")) {
+            } else if (paths[0].equalsIgnoreCase("getlog")) {
                 final String brainId = req.getParameter("brainid");
                 if (brainId == null) {
                     NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
@@ -131,7 +128,7 @@ public class BrainDashboardService extends DefaultServletService {
                     }
                 }
             } else {
-                logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+                logger.debug("Unknown get path: {}", String.join(",", paths));
             }
         } catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
             logger.debug("Exception handling get: {}", e.getMessage(), e);
@@ -154,7 +151,7 @@ public class BrainDashboardService extends DefaultServletService {
         }
 
         try {
-            if (StringUtils.equalsIgnoreCase(paths[0], "removebrain")) {
+            if (paths[0].equalsIgnoreCase("removebrain")) {
                 final BrainInfo info = gson.fromJson(req.getReader(), BrainInfo.class);
                 final String brainId = info.getBrainId();
                 if (brainId == null) {
@@ -165,7 +162,7 @@ public class BrainDashboardService extends DefaultServletService {
                     NeeoUtil.write(resp,
                             gson.toJson(new ReturnStatus("BrainID (" + brainId + ") could not be removed")));
                 }
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "addbrain")) {
+            } else if (paths[0].equalsIgnoreCase("addbrain")) {
                 final BrainInfo info = gson.fromJson(req.getReader(), BrainInfo.class);
                 final String brainIp = info.getBrainIp();
                 if (brainIp == null) {
@@ -177,7 +174,7 @@ public class BrainDashboardService extends DefaultServletService {
                             "Brain (" + brainIp + ") could not be added - no brain at that IP Address")));
                 }
             } else {
-                logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+                logger.debug("Unknown get path: {}", String.join(",", paths));
             }
         } catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
             logger.debug("Exception handling get: {}", e.getMessage(), e);
index 30eab839be8664356613fc976c8758496ee832b7..31efdb718cfdfb85678d02f1a6e3273b972942d9 100644 (file)
@@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.io.neeo.internal.NeeoConstants;
 import org.openhab.io.neeo.internal.NeeoUtil;
@@ -60,7 +59,7 @@ public class NeeoBrainSearchService extends DefaultServletService {
     private final ServiceContext context;
 
     /** The last search results */
-    private final ConcurrentHashMap<Integer, NeeoThingUID> lastSearchResults = new ConcurrentHashMap<>();
+    private final Map<Integer, NeeoThingUID> lastSearchResults = new ConcurrentHashMap<>();
 
     /**
      * Constructs the service from the given {@link ServiceContext}.
@@ -85,7 +84,7 @@ public class NeeoBrainSearchService extends DefaultServletService {
      */
     @Override
     public boolean canHandleRoute(String[] paths) {
-        return paths.length >= 1 && StringUtils.equalsIgnoreCase(paths[0], "db");
+        return paths.length >= 1 && paths[0].equalsIgnoreCase("db");
     }
 
     /**
@@ -103,17 +102,17 @@ public class NeeoBrainSearchService extends DefaultServletService {
         Objects.requireNonNull(paths, "paths cannot be null");
         Objects.requireNonNull(resp, "resp cannot be null");
         if (paths.length < 2) {
-            throw new IllegalArgumentException("paths must have atleast 2 elements: " + StringUtils.join(paths));
+            throw new IllegalArgumentException("paths must have atleast 2 elements: " + String.join("", paths));
         }
 
-        final String path = StringUtils.lowerCase(paths[1]);
+        final String path = paths[1].toLowerCase();
 
-        if (StringUtils.equalsIgnoreCase(path, "search")) {
+        if (path.equalsIgnoreCase("search")) {
             String queryString = req.getQueryString();
             if (queryString != null) {
                 doSearch(queryString, resp);
             }
-        } else if (StringUtils.equalsIgnoreCase(path, "adapterdefinition") && paths.length >= 3) {
+        } else if (path.equalsIgnoreCase("adapterdefinition") && paths.length >= 3) {
             doAdapterDefinition(paths[2], resp);
         } else {
             doQuery(path, resp);
@@ -131,7 +130,7 @@ public class NeeoBrainSearchService extends DefaultServletService {
         Objects.requireNonNull(queryString, "queryString cannot be null");
         Objects.requireNonNull(resp, "resp cannot be null");
 
-        final int idx = StringUtils.indexOf(queryString, '=');
+        final int idx = queryString.indexOf("=");
 
         if (idx >= 0 && idx + 1 < queryString.length()) {
             final String search = NeeoUtil.decodeURIComponent(queryString.substring(idx + 1));
index 1c12dbf3bd1d190e866ed3e5056f607b22ec8805..75a24602653bf01794e89332d1ce2ed9bac16229 100644 (file)
@@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.client.ClientBuilder;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -142,13 +141,12 @@ public class NeeoBrainService extends DefaultServletService {
             return false;
         }
 
-        if (StringUtils.equalsIgnoreCase(paths[0], "device")) {
+        if (paths[0].equalsIgnoreCase("device")) {
             return true;
         }
 
         final String lastPath = paths.length >= 2 ? paths[1] : null;
-        return StringUtils.equalsIgnoreCase(lastPath, "subscribe")
-                || StringUtils.equalsIgnoreCase(lastPath, "unsubscribe");
+        return "subscribe".equalsIgnoreCase(lastPath) || "unsubscribe".equalsIgnoreCase(lastPath);
     }
 
     @Override
@@ -160,19 +158,19 @@ public class NeeoBrainService extends DefaultServletService {
             throw new IllegalArgumentException("paths cannot be empty");
         }
 
-        final boolean hasDeviceStart = StringUtils.equalsIgnoreCase(paths[0], "device");
+        final boolean hasDeviceStart = paths[0].equalsIgnoreCase("device");
 
         if (hasDeviceStart) {
             final PathInfo pathInfo = new PathInfo(paths);
 
-            if (StringUtils.equalsIgnoreCase("directory", pathInfo.getComponentType())) {
+            if ("directory".equalsIgnoreCase(pathInfo.getComponentType())) {
                 handleDirectory(req, resp, pathInfo);
             } else {
-                logger.debug("Unknown/unhandled brain service device route (POST): {}", StringUtils.join(paths, '/'));
+                logger.debug("Unknown/unhandled brain service device route (POST): {}", String.join("/", paths));
 
             }
         } else {
-            logger.debug("Unknown/unhandled brain service route (POST): {}", StringUtils.join(paths, '/'));
+            logger.debug("Unknown/unhandled brain service route (POST): {}", String.join("/", paths));
         }
     }
 
@@ -192,26 +190,27 @@ public class NeeoBrainService extends DefaultServletService {
         // 4. Old subscribe path: /{thingUID}/subscribe or unsubscribe/{deviceid}/{devicekey}
         // 4. Old unsubscribe path: /{thingUID}/subscribe or unsubscribe/{deviceid}
 
-        final boolean hasDeviceStart = StringUtils.equalsIgnoreCase(paths[0], "device");
-        if (hasDeviceStart && (paths.length >= 3 && !StringUtils.equalsIgnoreCase(paths[2], "subscribe")
-                && !StringUtils.equalsIgnoreCase(paths[2], "unsubscribe"))) {
+        final boolean hasDeviceStart = paths[0].equalsIgnoreCase("device");
+        if (hasDeviceStart && (paths.length >= 3 && !paths[2].equalsIgnoreCase("subscribe")
+                && !paths[2].equalsIgnoreCase("unsubscribe"))) {
             try {
                 final PathInfo pathInfo = new PathInfo(paths);
 
-                if (StringUtils.isEmpty(pathInfo.getActionValue())) {
+                String actionValue = pathInfo.getActionValue();
+                if (actionValue == null || actionValue.isEmpty()) {
                     handleGetValue(resp, pathInfo);
                 } else {
                     handleSetValue(resp, pathInfo);
                 }
             } catch (IllegalArgumentException e) {
-                logger.debug("Bad path: {} - {}", StringUtils.join(paths), e.getMessage(), e);
+                logger.debug("Bad path: {} - {}", String.join("", paths), e.getMessage(), e);
             }
         } else {
             int idx = hasDeviceStart ? 1 : 0;
 
             if (idx + 2 < paths.length) {
                 final String adapterName = paths[idx++];
-                final String action = StringUtils.lowerCase(paths[idx++]);
+                final String action = paths[idx++].toLowerCase();
                 idx++; // deviceId/default - not used
 
                 switch (action) {
@@ -220,7 +219,7 @@ public class NeeoBrainService extends DefaultServletService {
                             final String deviceKey = paths[idx++];
                             handleSubscribe(resp, adapterName, deviceKey);
                         } else {
-                            logger.debug("No device key set for a subscribe action: {}", StringUtils.join(paths, '/'));
+                            logger.debug("No device key set for a subscribe action: {}", String.join("/", paths));
                         }
                         break;
                     case "unsubscribe":
@@ -231,7 +230,7 @@ public class NeeoBrainService extends DefaultServletService {
                 }
 
             } else {
-                logger.debug("Unknown/unhandled brain service route (GET): {}", StringUtils.join(paths, '/'));
+                logger.debug("Unknown/unhandled brain service route (GET): {}", String.join("/", paths));
             }
         }
     }
@@ -384,7 +383,7 @@ public class NeeoBrainService extends DefaultServletService {
         if (device != null) {
             final NeeoDeviceChannel channel = device.getChannel(pathInfo.getItemName(), pathInfo.getSubType(),
                     pathInfo.getChannelNbr());
-            if (StringUtils.equalsIgnoreCase("action", pathInfo.getActionValue())) {
+            if ("action".equalsIgnoreCase(pathInfo.getActionValue())) {
                 final NeeoDirectoryRequestAction discoveryAction = gson.fromJson(req.getReader(),
                         NeeoDirectoryRequestAction.class);
 
@@ -515,13 +514,11 @@ public class NeeoBrainService extends DefaultServletService {
                 if (state instanceof OnOffType) {
                     Boolean recipeState = null;
                     final String label = channel.getLabel();
-                    if (StringUtils.equalsIgnoreCase(NeeoButtonGroup.POWERONOFF.getText(), label)) {
+                    if (NeeoButtonGroup.POWERONOFF.getText().equalsIgnoreCase(label)) {
                         recipeState = state == OnOffType.ON;
-                    } else if (state == OnOffType.ON
-                            && StringUtils.equalsIgnoreCase(ButtonInfo.POWERON.getLabel(), label)) {
+                    } else if (state == OnOffType.ON && ButtonInfo.POWERON.getLabel().equalsIgnoreCase(label)) {
                         recipeState = true;
-                    } else if (state == OnOffType.OFF
-                            && StringUtils.equalsIgnoreCase(ButtonInfo.POWEROFF.getLabel(), label)) {
+                    } else if (state == OnOffType.OFF && ButtonInfo.POWEROFF.getLabel().equalsIgnoreCase(label)) {
                         recipeState = false;
                     }
 
index cd722dd2dbd5e5210a64f12da122c3a2a52b6384..dd41472e7015d3661fd391a8e5a68738af3db170 100644 (file)
@@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.io.neeo.NeeoService;
@@ -84,14 +83,14 @@ public class ThingDashboardService extends DefaultServletService {
      */
     @Override
     public boolean canHandleRoute(String[] paths) {
-        return paths.length >= 1 && (StringUtils.equalsIgnoreCase(paths[0], "thingstatus")
-                || StringUtils.equalsIgnoreCase(paths[0], "getchannel")
-                || StringUtils.equalsIgnoreCase(paths[0], "getvirtualdevice")
-                || StringUtils.equalsIgnoreCase(paths[0], "restoredevice")
-                || StringUtils.equalsIgnoreCase(paths[0], "refreshdevice")
-                || StringUtils.equalsIgnoreCase(paths[0], "deletedevice")
-                || StringUtils.equalsIgnoreCase(paths[0], "exportrules")
-                || StringUtils.equalsIgnoreCase(paths[0], "updatedevice"));
+        return paths.length >= 1 && (paths[0].equalsIgnoreCase("thingstatus") //
+                || paths[0].equalsIgnoreCase("getchannel") //
+                || paths[0].equalsIgnoreCase("getvirtualdevice") //
+                || paths[0].equalsIgnoreCase("restoredevice") //
+                || paths[0].equalsIgnoreCase("refreshdevice") //
+                || paths[0].equalsIgnoreCase("deletedevice") //
+                || paths[0].equalsIgnoreCase("exportrules") //
+                || paths[0].equalsIgnoreCase("updatedevice"));
     }
 
     /**
@@ -106,10 +105,10 @@ public class ThingDashboardService extends DefaultServletService {
         Objects.requireNonNull(resp, "resp cannot be null");
 
         try {
-            if (StringUtils.equalsIgnoreCase(paths[0], "thingstatus")) {
+            if (paths[0].equalsIgnoreCase("thingstatus")) {
                 final List<NeeoDevice> devices = context.getDefinitions().getAllDevices();
                 NeeoUtil.write(resp, gson.toJson(devices));
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "getchannel")) {
+            } else if (paths[0].equalsIgnoreCase("getchannel")) {
                 final String itemName = NeeoUtil.decodeURIComponent(req.getParameter("itemname"));
                 final List<NeeoDeviceChannel> channels = context.getDefinitions().getNeeoDeviceChannel(itemName);
                 if (channels == null) {
@@ -117,13 +116,13 @@ public class ThingDashboardService extends DefaultServletService {
                 } else {
                     NeeoUtil.write(resp, gson.toJson(new ReturnStatus(channels)));
                 }
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "getvirtualdevice")) {
+            } else if (paths[0].equalsIgnoreCase("getvirtualdevice")) {
                 final NeeoThingUID uid = context.generate(NeeoConstants.VIRTUAL_THING_TYPE);
                 final NeeoDevice device = new NeeoDevice(uid, 0, NeeoDeviceType.EXCLUDE, "NEEO Integration",
                         "New Virtual Thing", new ArrayList<>(), null, null, null, null);
                 NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
             } else {
-                logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+                logger.debug("Unknown get path: {}", String.join(",", paths));
             }
         } catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
             logger.debug("Exception handling get: {}", e.getMessage(), e);
@@ -146,7 +145,7 @@ public class ThingDashboardService extends DefaultServletService {
         }
 
         try {
-            if (StringUtils.equalsIgnoreCase(paths[0], "updatedevice")) {
+            if (paths[0].equalsIgnoreCase("updatedevice")) {
                 final NeeoDevice device = gson.fromJson(req.getReader(), NeeoDevice.class);
                 context.getDefinitions().put(device);
 
@@ -155,7 +154,7 @@ public class ThingDashboardService extends DefaultServletService {
                 }
 
                 NeeoUtil.write(resp, gson.toJson(ReturnStatus.SUCCESS));
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "restoredevice")) {
+            } else if (paths[0].equalsIgnoreCase("restoredevice")) {
                 final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
                 context.getDefinitions().remove(uid);
                 final NeeoDevice device = context.getDefinitions().getDevice(uid);
@@ -164,7 +163,7 @@ public class ThingDashboardService extends DefaultServletService {
                 } else {
                     NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
                 }
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "refreshdevice")) {
+            } else if (paths[0].equalsIgnoreCase("refreshdevice")) {
                 final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
                 final NeeoDevice device = context.getDefinitions().getDevice(uid);
                 if (device == null) {
@@ -172,12 +171,12 @@ public class ThingDashboardService extends DefaultServletService {
                 } else {
                     NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
                 }
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "deletedevice")) {
+            } else if (paths[0].equalsIgnoreCase("deletedevice")) {
                 final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
                 final boolean deleted = context.getDefinitions().remove(uid);
                 NeeoUtil.write(resp, gson.toJson(new ReturnStatus(
                         deleted ? null : "Device " + uid + " was not found (possibly already deleted?)")));
-            } else if (StringUtils.equalsIgnoreCase(paths[0], "exportrules")) {
+            } else if (paths[0].equalsIgnoreCase("exportrules")) {
                 final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
                 final NeeoDevice device = context.getDefinitions().getDevice(uid);
                 if (device == null) {
@@ -186,7 +185,7 @@ public class ThingDashboardService extends DefaultServletService {
                     writeExampleRules(resp, device);
                 }
             } else {
-                logger.debug("Unknown post path: {}", StringUtils.join(paths, ','));
+                logger.debug("Unknown post path: {}", String.join(",", paths));
             }
         } catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
             logger.debug("Exception handling post: {}", e.getMessage(), e);
index 0c6737a591af1bf4dd427f2a73e19d0073babfe4..e6561a3cfead17093971afbc11fc4822caeecb1a 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.servletservices.models;
 
 import java.util.Objects;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.models.ItemSubType;
@@ -47,8 +46,7 @@ public class PathInfo {
     private final String componentSubType;
 
     /** The action value */
-    @Nullable
-    private final String actionValue;
+    private final @Nullable String actionValue;
 
     /**
      * Creates the path info object from the route path
@@ -89,7 +87,7 @@ public class PathInfo {
         componentType = paths[idx++];
 
         // actor/sensor/buttoncmd
-        if (StringUtils.equalsIgnoreCase("button", componentType)) {
+        if ("button".equalsIgnoreCase(componentType)) {
             componentSubType = "actor";
             actionValue = paths[idx++];
         } else {
index d9025996f0f361a7688f1a1123d8d0feb48969d5..95161c402c52c21869e947c6852feb58a60d831e 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.io.neeo.internal.servletservices.models;
 
 import java.util.List;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.io.neeo.internal.models.NeeoDevice;
@@ -36,16 +35,13 @@ public class ReturnStatus {
     private final boolean success;
 
     /** The optional message if not successful */
-    @Nullable
-    private final String message;
+    private final @Nullable String message;
 
     /** The optional device if successful */
-    @Nullable
-    private final NeeoDevice device;
+    private final @Nullable NeeoDevice device;
 
     /** The optional channel if successful */
-    @Nullable
-    private final List<NeeoDeviceChannel> channels;
+    private final @Nullable List<NeeoDeviceChannel> channels;
 
     /**
      * Creates a return status of true or not (with no message or device)
@@ -81,7 +77,7 @@ public class ReturnStatus {
      * @param message the possibly null, possibly empty message
      */
     public ReturnStatus(@Nullable String message) {
-        this(StringUtils.isEmpty(message), message, null, null);
+        this(message == null || message.isEmpty(), message, null, null);
     }
 
     /**
@@ -124,8 +120,7 @@ public class ReturnStatus {
      *
      * @return the possibly empty, possibly null message
      */
-    @Nullable
-    public String getMessage() {
+    public @Nullable String getMessage() {
         return message;
     }
 
@@ -134,8 +129,7 @@ public class ReturnStatus {
      *
      * @return the possibly null device
      */
-    @Nullable
-    public NeeoDevice getDevice() {
+    public @Nullable NeeoDevice getDevice() {
         return device;
     }
 
@@ -144,8 +138,7 @@ public class ReturnStatus {
      *
      * @return the possibly null channel
      */
-    @Nullable
-    public List<NeeoDeviceChannel> getChannels() {
+    public @Nullable List<NeeoDeviceChannel> getChannels() {
         return channels;
     }
 
index 2d98f92b76311978ad4be35391b3a13c7587b142..ce75928971e73396eb5a23c09eab92aec4b40c99 100644 (file)
@@ -10,7 +10,6 @@ Fragment-Host: org.openhab.binding.astro
 #
 -runbundles: \
        javax.measure.unit-api;version='[1.0.0,1.0.1)',\
-       org.apache.commons.lang;version='[2.6.0,2.6.1)',\
        org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
        org.apache.felix.scr;version='[2.1.10,2.1.11)',\
        org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
@@ -44,4 +43,5 @@ Fragment-Host: org.openhab.binding.astro
        org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
        org.objenesis;version='[3.1.0,3.1.1)',\
        org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
-       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+       org.apache.commons.lang3;version='[3.9.0,3.9.1)'
index b45bde948f7b8aa3504fa34fe853039dcc50cc8d..05088103b065c1becb44e829a23040b5903a0b1e 100644 (file)
@@ -20,7 +20,6 @@ Fragment-Host: org.openhab.binding.max
        ch.qos.logback.core;version='[1.2.3,1.2.4)',\
        com.google.gson;version='[2.8.2,2.8.3)',\
        javax.measure.unit-api;version='[1.0.0,1.0.1)',\
-       org.apache.commons.lang;version='[2.6.0,2.6.1)',\
        org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
        org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
        org.apache.felix.scr;version='[2.1.10,2.1.11)',\
@@ -58,4 +57,5 @@ Fragment-Host: org.openhab.binding.max
        junit-platform-engine;version='[1.7.0,1.7.1)',\
        junit-platform-launcher;version='[1.7.0,1.7.1)',\
        org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
-       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+       org.apache.commons.lang3;version='[3.9.0,3.9.1)'
index 89fcb922f58965b1426afa0fab4065743b7719ce..1379be94dc1390acfea10ef2778aacb9973bdf30 100644 (file)
@@ -20,7 +20,6 @@ Fragment-Host: org.openhab.binding.ntp
        ch.qos.logback.core;version='[1.2.3,1.2.4)',\
        com.google.gson;version='[2.8.2,2.8.3)',\
        javax.measure.unit-api;version='[1.0.0,1.0.1)',\
-       org.apache.commons.lang;version='[2.6.0,2.6.1)',\
        org.apache.commons.commons-net;version='[3.7.2,3.7.3)',\
        org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
        org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
index d90dae0fa60c97647c388d2604994aee5affd347..e0e548c2981a3a5c6007091d31ace1b18aa20461 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Collections;
 import java.util.Locale;
 import java.util.TimeZone;
 
-import org.apache.commons.lang.StringUtils;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
@@ -450,9 +449,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
     }
 
     private String getStringChannelTimeZoneFromItemRegistry() {
-        String itemState = getItemState(ACCEPTED_ITEM_TYPE_STRING).toString();
-        String timeZoneFromItemRegistry = StringUtils.substringAfterLast(itemState, " ");
-        return timeZoneFromItemRegistry;
+        return getItemState(ACCEPTED_ITEM_TYPE_STRING).toString().split(" ")[2];
     }
 
     private void assertFormat(String initialDate, String formatPattern) {
index a37e4c978de045d7e7d9e8c1ad57317e2d2c7734..840fef836c951a849009baa02eb6dfb90b1d1254 100644 (file)
@@ -20,7 +20,6 @@ Fragment-Host: org.openhab.binding.systeminfo
 -runbundles: \
        com.google.gson;version='[2.8.2,2.8.3)',\
        javax.measure.unit-api;version='[1.0.0,1.0.1)',\
-       org.apache.commons.lang;version='[2.6.0,2.6.1)',\
        org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
        org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
        org.apache.felix.scr;version='[2.1.10,2.1.11)',\
@@ -66,4 +65,5 @@ Fragment-Host: org.openhab.binding.systeminfo
        org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
        org.objenesis;version='[3.1.0,3.1.1)',\
        org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
-       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+       org.apache.commons.lang3;version='[3.9.0,3.9.1)'
index 731ba026197f5d854d736955639ba80f59ffe251..34bebcdb3e6ce29391200f0f165e4ff19322ddef 100644 (file)
@@ -19,7 +19,6 @@ Fragment-Host: org.openhab.binding.wemo
        ch.qos.logback.core;version='[1.2.3,1.2.4)',\
        com.google.gson;version='[2.8.2,2.8.3)',\
        javax.measure.unit-api;version='[1.0.0,1.0.1)',\
-       org.apache.commons.lang;version='[2.6.0,2.6.1)',\
        org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
        org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
        org.apache.felix.scr;version='[2.1.10,2.1.11)',\
@@ -77,4 +76,5 @@ Fragment-Host: org.openhab.binding.wemo
        org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
        org.objenesis;version='[3.1.0,3.1.1)',\
        org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
-       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+       biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+       org.apache.commons.lang3;version='[3.9.0,3.9.1)'