]> git.basschouten.com Git - openhab-addons.git/commitdiff
Java 17 features (T-Z) (#15576)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Thu, 21 Sep 2023 05:58:53 +0000 (07:58 +0200)
committerGitHub <noreply@github.com>
Thu, 21 Sep 2023 05:58:53 +0000 (07:58 +0200)
- add missing @override
- Java style array syntax
- remove redundant modifiers
- always move String constants to left side in comparisons
- simplify lambda expressions and return statements
- use replace instead of replaceAll w/o regex
- instanceof matching and multiline strings
- remove null check before instanceof

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
277 files changed:
bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/message/AnalogMessage.java
bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ApiPageEntry.java
bundles/org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema/ChangerX2Entry.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/CapabilitiesSupport.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/TadoBindingConstants.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/adapter/TadoZoneStateAdapter.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/api/TadoApiTypeUtils.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/builder/TerminationConditionBuilder.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHandlerFactory.java
bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java
bundles/org.openhab.binding.tankerkoenig/src/main/java/org/openhab/binding/tankerkoenig/internal/TankerkoenigBindingConstants.java
bundles/org.openhab.binding.tankerkoenig/src/main/java/org/openhab/binding/tankerkoenig/internal/TankerkoenigHandlerFactory.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoCloudConnector.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoDeviceHttpApi.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoBridgeHandler.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoDevice.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoLightStrip.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartBulb.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/helpers/PayloadBuilder.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/helpers/TapoUtils.java
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java
bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java
bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoBridgeHandler.java
bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java
bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java
bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java
bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/TelegramHandlerFactory.java
bundles/org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action/TelegramActions.java
bundles/org.openhab.binding.teleinfo/src/main/java/org/openhab/binding/teleinfo/internal/TeleinfoDiscoveryService.java
bundles/org.openhab.binding.teleinfo/src/main/java/org/openhab/binding/teleinfo/internal/handler/TeleinfoAbstractControllerHandler.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/TellstickHandlerFactory.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/core/TelldusCoreDeviceController.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/discovery/TellstickDiscoveryService.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/handler/TelldusDevicesHandler.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/live/TelldusLiveDeviceController.java
bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalDeviceController.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaChannelSelectorProxy.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaAccountHandler.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/Vehicle.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/VehicleData.java
bundles/org.openhab.binding.tivo/src/main/java/org/openhab/binding/tivo/internal/TiVoHandlerFactory.java
bundles/org.openhab.binding.tivo/src/main/java/org/openhab/binding/tivo/internal/discovery/TiVoDiscoveryParticipant.java
bundles/org.openhab.binding.tivo/src/main/java/org/openhab/binding/tivo/internal/handler/TiVoHandler.java
bundles/org.openhab.binding.tivo/src/main/java/org/openhab/binding/tivo/internal/service/TivoStatusData.java
bundles/org.openhab.binding.tivo/src/main/java/org/openhab/binding/tivo/internal/service/TivoStatusProvider.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandAlarmSensorHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBSensorHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBaseUnitHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandBridgeHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandDimmerHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandRestClient.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandShutterHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandSwitchHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandThermostatHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandWallControllerHandler.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/TouchWandWebSockets.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/discovery/TouchWandControllerDiscoveryService.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/discovery/TouchWandUnitDiscoveryService.java
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/dto/AlarmSensorUnitDataDeserializer.java
bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDevice.java
bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/DimmerDevice.java
bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/SwitchDevice.java
bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/handler/TPLinkSmartHomeActions.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/FritzboxActions.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/Tr064DiscoveryService.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/Tr064HandlerFactory.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/Tr064RootHandler.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfile.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPConnector.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/util/Util.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/TradfriBindingConstants.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryService.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriAirPurifierHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriBlindHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriGatewayHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriLightHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/handler/TradfriPlugHandler.java
bundles/org.openhab.binding.tradfri/src/main/java/org/openhab/binding/tradfri/internal/model/TradfriAirPurifierData.java
bundles/org.openhab.binding.twitter/src/main/java/org/openhab/binding/twitter/internal/TwitterHandler.java
bundles/org.openhab.binding.twitter/src/main/java/org/openhab/binding/twitter/internal/action/TwitterActions.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/action/UniFiSiteActions.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/UniFiControllerRequest.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiVoucher.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiControllerThingHandler.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiSiteThingHandler.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiThingDiscoveryService.java
bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiWlanThingHandler.java
bundles/org.openhab.binding.unifiedremote/src/main/java/org/openhab/binding/unifiedremote/internal/UnifiedRemoteBindingConstants.java
bundles/org.openhab.binding.upb/src/main/java/org/openhab/binding/upb/internal/UPBController.java
bundles/org.openhab.binding.upb/src/main/java/org/openhab/binding/upb/internal/handler/UPBThingHandler.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpDynamicCommandDescriptionProvider.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/UpnpDynamicStateDescriptionProvider.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandler.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandler.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandler.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/StringUtils.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/UpnpControlUtil.java
bundles/org.openhab.binding.upnpcontrol/src/test/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpHandlerTest.java
bundles/org.openhab.binding.upnpcontrol/src/test/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpRendererHandlerTest.java
bundles/org.openhab.binding.upnpcontrol/src/test/java/org/openhab/binding/upnpcontrol/internal/handler/UpnpServerHandlerTest.java
bundles/org.openhab.binding.urtsi/src/main/java/org/openhab/binding/urtsi/internal/UrtsiHandlerFactory.java
bundles/org.openhab.binding.urtsi/src/main/java/org/openhab/binding/urtsi/internal/handler/RtsDeviceHandler.java
bundles/org.openhab.binding.urtsi/src/main/java/org/openhab/binding/urtsi/internal/handler/UrtsiDeviceHandler.java
bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVBindingConstants.java
bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVHandlerFactory.java
bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandler.java
bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandlerFactory.java
bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/svdrp/SVDRPChannel.java
bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/svdrp/SVDRPClientImpl.java
bundles/org.openhab.binding.vdr/src/test/java/org/openhab/binding/vdr/internal/SVDRPEpgEventTest.java
bundles/org.openhab.binding.vdr/src/test/java/org/openhab/binding/vdr/internal/SVDRPTimerListTest.java
bundles/org.openhab.binding.vektiva/src/main/java/org/openhab/binding/vektiva/internal/VektivaHandlerFactory.java
bundles/org.openhab.binding.vektiva/src/main/java/org/openhab/binding/vektiva/internal/handler/VektivaSmarwiHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/VelbusBindingConstants.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/discovery/VelbusThingDiscoveryService.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBlindsHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusBridgeHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusDimmerHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusMemoHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusRelayHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusRelayWithInputHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusSensorHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusSensorWithAlarmClockHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusThermostatHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusThingHandler.java
bundles/org.openhab.binding.velbus/src/main/java/org/openhab/binding/velbus/internal/handler/VelbusVMB4ANHandler.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/action/VeluxActions.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/json/JCgetFirmware.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/json/JCgetLANConfig.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/bridge/json/JCgetWLANConfig.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/factory/VeluxHandlerFactory.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/ChannelActuatorPosition.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/handler/VeluxBridgeHandler.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxProduct.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxProductPosition.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/things/VeluxProductType.java
bundles/org.openhab.binding.velux/src/main/java/org/openhab/binding/velux/internal/utils/ManifestInformation.java
bundles/org.openhab.binding.velux/src/test/java/org/openhab/binding/velux/test/TestNotificationsAndDatabase.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/VenstarThermostatBindingConstants.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/VenstarThermostatHandlerFactory.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/discovery/VenstarThermostatDiscoveryService.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarFanStateSerializer.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/Communicator.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/discovery/VentaDeviceDiscovery.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/VerisureSession.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/discovery/VerisureThingDiscoveryService.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureAlarmThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureBridgeHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureBroadbandConnectionThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureClimateDeviceThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureDoorWindowThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureEventLogThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureGatewayThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureMiceDetectionThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureSmartLockThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureSmartPlugThingHandler.java
bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureUserPresenceThingHandler.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/api/VeSyncV2ApiHelper.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/discovery/VeSyncDiscoveryService.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncBaseDeviceHandler.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncBridgeHandler.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirHumidifierHandler.java
bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirPurifierHandler.java
bundles/org.openhab.binding.vesync/src/main/test/org/openhab/binding/vesync/internal/handler/requests/VesyncAuthenticatedRequestTest.java
bundles/org.openhab.binding.vesync/src/main/test/org/openhab/binding/vesync/internal/handler/requests/VesyncRequestManagedDeviceBypassV2Test.java
bundles/org.openhab.binding.vesync/src/main/test/org/openhab/binding/vesync/internal/handler/responses/VesyncLoginResponseTest.java
bundles/org.openhab.binding.vesync/src/main/test/org/openhab/binding/vesync/internal/handler/responses/VesyncManagedDevicesPageTest.java
bundles/org.openhab.binding.vesync/src/main/test/org/openhab/binding/vesync/internal/handler/responses/v1/VesyncV1AirPurifierDeviceDetailsTest.java
bundles/org.openhab.binding.vitotronic/src/main/java/org/openhab/binding/vitotronic/internal/VitotronicBindingConstants.java
bundles/org.openhab.binding.vitotronic/src/main/java/org/openhab/binding/vitotronic/internal/handler/VitotronicThingHandler.java
bundles/org.openhab.binding.vizio/src/main/java/org/openhab/binding/vizio/internal/VizioBindingConstants.java
bundles/org.openhab.binding.vizio/src/main/java/org/openhab/binding/vizio/internal/VizioHandlerFactory.java
bundles/org.openhab.binding.vizio/src/main/java/org/openhab/binding/vizio/internal/console/VizioCommandExtension.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/VolvoOnCallException.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/action/VolvoOnCallActions.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/discovery/VolvoVehicleDiscoveryService.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/dto/PostResponse.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/dto/Status.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/dto/TyrePressure.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VehicleHandler.java
bundles/org.openhab.binding.volvooncall/src/main/java/org/openhab/binding/volvooncall/internal/handler/VolvoOnCallBridgeHandler.java
bundles/org.openhab.binding.warmup/src/main/java/org/openhab/binding/warmup/internal/api/MyWarmupApi.java
bundles/org.openhab.binding.warmup/src/main/java/org/openhab/binding/warmup/internal/discovery/WarmupDiscoveryService.java
bundles/org.openhab.binding.warmup/src/main/java/org/openhab/binding/warmup/internal/handler/MyWarmupAccountHandler.java
bundles/org.openhab.binding.warmup/src/main/java/org/openhab/binding/warmup/internal/handler/RoomHandler.java
bundles/org.openhab.binding.weathercompany/src/main/java/org/openhab/binding/weathercompany/internal/handler/WeatherCompanyAbstractHandler.java
bundles/org.openhab.binding.weatherunderground/src/main/java/org/openhab/binding/weatherunderground/internal/WeatherUndergroundBindingConstants.java
bundles/org.openhab.binding.weatherunderground/src/main/java/org/openhab/binding/weatherunderground/internal/discovery/WeatherUndergroundDiscoveryService.java
bundles/org.openhab.binding.weatherunderground/src/main/java/org/openhab/binding/weatherunderground/internal/handler/WeatherUndergroundBridgeHandler.java
bundles/org.openhab.binding.weatherunderground/src/main/java/org/openhab/binding/weatherunderground/internal/json/WeatherUndergroundJsonCurrent.java
bundles/org.openhab.binding.weatherunderground/src/main/java/org/openhab/binding/weatherunderground/internal/json/WeatherUndergroundJsonUtils.java
bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsActions.java
bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandler.java
bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandlerFactory.java
bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/api/WebexTeamsApi.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/WebThingBindingConstants.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/WebThingHandler.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/client/ConsumedThingImpl.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/client/DescriptionLoader.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/client/dto/WebThingDescription.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeConverters.java
bundles/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link/TypeMapping.java
bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/WemoUtil.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/WemoBridgeHandler.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/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.wifiled/src/main/java/org/openhab/binding/wifiled/internal/WiFiLEDBindingConstants.java
bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/WiFiLEDHandlerFactory.java
bundles/org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler/WiFiLEDHandler.java
bundles/org.openhab.binding.windcentrale/src/main/java/org/openhab/binding/windcentrale/internal/WindcentraleDiscoveryService.java
bundles/org.openhab.binding.windcentrale/src/test/java/org/openhab/binding/windcentrale/internal/dto/DataUtil.java
bundles/org.openhab.binding.wlanthermo/src/main/java/org/openhab/binding/wlanthermo/internal/api/esp32/WlanThermoEsp32CommandHandler.java
bundles/org.openhab.binding.wlanthermo/src/main/java/org/openhab/binding/wlanthermo/internal/api/mini/WlanThermoMiniCommandHandler.java
bundles/org.openhab.binding.wlanthermo/src/main/java/org/openhab/binding/wlanthermo/internal/api/nano/WlanThermoNanoV1CommandHandler.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedActions.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedDiscoveryService.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedSegmentDiscoveryService.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/api/WledApiV084.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/handlers/WLedBridgeHandler.java
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/handlers/WLedSegmentHandler.java
bundles/org.openhab.binding.wolfsmartset/src/main/java/org/openhab/binding/wolfsmartset/internal/api/WolfSmartsetApi.java
bundles/org.openhab.binding.wolfsmartset/src/main/java/org/openhab/binding/wolfsmartset/internal/discovery/WolfSmartsetAccountDiscoveryService.java
bundles/org.openhab.binding.wolfsmartset/src/main/java/org/openhab/binding/wolfsmartset/internal/discovery/WolfSmartsetSystemDiscoveryService.java
bundles/org.openhab.binding.wolfsmartset/src/main/java/org/openhab/binding/wolfsmartset/internal/handler/WolfSmartsetAccountBridgeHandler.java
bundles/org.openhab.binding.wolfsmartset/src/main/java/org/openhab/binding/wolfsmartset/internal/handler/WolfSmartsetSystemBridgeHandler.java
bundles/org.openhab.binding.wundergroundupdatereceiver/src/main/java/org/openhab/binding/wundergroundupdatereceiver/internal/WundergroundUpdateReceiverServlet.java
bundles/org.openhab.binding.wundergroundupdatereceiver/src/test/java/org/openhab/binding/wundergroundupdatereceiver/internal/WundergroundUpdateReceiverDiscoveryServiceTest.java
bundles/org.openhab.binding.xmltv/src/main/java/org/openhab/binding/xmltv/internal/discovery/XmlTVDiscoveryService.java
bundles/org.openhab.binding.xmltv/src/main/java/org/openhab/binding/xmltv/internal/handler/XmlTVHandler.java
bundles/org.openhab.binding.xmltv/src/main/java/org/openhab/binding/xmltv/internal/jaxb/Programme.java
bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/XMPPClientHandlerFactory.java
bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientHandler.java
bundles/org.openhab.binding.yamahamusiccast/src/main/java/org/openhab/binding/yamahamusiccast/internal/YamahaMusiccastHandler.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/ChannelsTypeProviderAvailableInputs.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/ChannelsTypeProviderPreset.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/YamahaReceiverBindingConstants.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/discovery/YamahaDiscoveryParticipant.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/handler/YamahaBridgeHandler.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/InputWithNavigationControlXML.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/protocol/xml/XMLProtocolService.java
bundles/org.openhab.binding.yamahareceiver/src/main/java/org/openhab/binding/yamahareceiver/internal/state/NavigationControlState.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/handler/YeelightHandlerBase.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/CeilingDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/CtBulbDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/DesklampDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/DeviceBase.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/MonoDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/PitayaDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/device/WonderDevice.java
bundles/org.openhab.binding.yeelight/src/main/java/org/openhab/binding/yeelight/internal/lib/services/DeviceManager.java
bundles/org.openhab.binding.yioremote/src/main/java/org/openhab/binding/yioremote/internal/YIOremoteBindingConstants.java
bundles/org.openhab.binding.yioremote/src/main/java/org/openhab/binding/yioremote/internal/YIOremoteDockHandler.java
bundles/org.openhab.binding.yioremote/src/main/java/org/openhab/binding/yioremote/internal/YIOremoteHandlerFactory.java
bundles/org.openhab.binding.zoneminder/src/main/java/org/openhab/binding/zoneminder/internal/action/ZmActions.java
bundles/org.openhab.binding.zoneminder/src/main/java/org/openhab/binding/zoneminder/internal/discovery/MonitorDiscoveryService.java
bundles/org.openhab.binding.zoneminder/src/main/java/org/openhab/binding/zoneminder/internal/handler/ZmBridgeHandler.java
bundles/org.openhab.binding.zoneminder/src/main/java/org/openhab/binding/zoneminder/internal/handler/ZmMonitorHandler.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/ZWayBindingConstants.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/converter/ZWayDeviceStateConverter.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/discovery/ZWayBridgeDiscoveryService.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/discovery/ZWayDeviceDiscoveryService.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/ZWayDeviceHandler.java
bundles/org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler/ZWayZWaveDeviceHandler.java

index e07c8afc57ca82fb168d4001b873c7339b71ac4a..e23da979cc798ef559b50f833cf82c4d125bc0a1 100644 (file)
@@ -93,8 +93,7 @@ public final class AnalogMessage extends Message {
     public AnalogValue getAnalogValue(int portNumber) {
         // Get the internal index for portNumber within the message
         int idx = (portNumber - 1) % 4;
-        AnalogValue value = new AnalogValue(this.getValue(idx), getMeasureType(idx));
-        return value;
+        return new AnalogValue(this.getValue(idx), getMeasureType(idx));
     }
 
     /**
index 7aaffdb87ffe9e3c10329ccb48b4f4b5e7221552..0c42c4c8ce49175ca739e6305c62d62c493ab2a0 100644 (file)
@@ -26,7 +26,7 @@ import org.openhab.core.types.State;
 @NonNullByDefault
 public class ApiPageEntry {
 
-    static enum Type {
+    enum Type {
         READ_ONLY_SWITCH(true),
         READ_ONLY_NUMERIC(true),
         NUMERIC_FORM(false),
index fecdcce5a3d6dc3ad7e79c0caa1269681813b7e7..0b15c8ba52342dfc40fbc459bae4c3db82a10712 100644 (file)
@@ -30,7 +30,7 @@ public class ChangerX2Entry {
     public static final String NUMBER_MAX = "max";
     public static final String NUMBER_STEP = "step";
 
-    static enum OptionType {
+    enum OptionType {
         NUMBER,
         SELECT,
     }
index c4b061e0062d1f5349ee1807d343c2eed2d7abee..573668de71ee7fbcdced55127b0f9861c4ba23f8 100644 (file)
@@ -73,12 +73,12 @@ public class CapabilitiesSupport {
         // iterate over all mode capability elements and build the superset of their inner capabilities
         allCapabilities.forEach(e -> {
             if (e != null) {
-                light |= e.getLight() != null ? e.getLight().size() > 0 : false;
-                swing |= e.getSwings() != null ? e.getSwings().size() > 0 : false;
-                fanLevel |= e.getFanLevel() != null ? e.getFanLevel().size() > 0 : false;
-                fanSpeed |= e.getFanSpeeds() != null ? e.getFanSpeeds().size() > 0 : false;
-                verticalSwing |= e.getVerticalSwing() != null ? e.getVerticalSwing().size() > 0 : false;
-                horizontalSwing |= e.getHorizontalSwing() != null ? e.getHorizontalSwing().size() > 0 : false;
+                light |= e.getLight() != null ? !e.getLight().isEmpty() : false;
+                swing |= e.getSwings() != null ? !e.getSwings().isEmpty() : false;
+                fanLevel |= e.getFanLevel() != null ? !e.getFanLevel().isEmpty() : false;
+                fanSpeed |= e.getFanSpeeds() != null ? !e.getFanSpeeds().isEmpty() : false;
+                verticalSwing |= e.getVerticalSwing() != null ? !e.getVerticalSwing().isEmpty() : false;
+                horizontalSwing |= e.getHorizontalSwing() != null ? !e.getHorizontalSwing().isEmpty() : false;
             }
         });
     }
index bee2a393e9b999d13ff0d3037267c75ae06c22b0..2607a289e2411796362cdf4278423f20243759f5 100644 (file)
@@ -36,7 +36,7 @@ public class TadoBindingConstants {
     // List of all Channel IDs
     public static final String PROPERTY_HOME_TEMPERATURE_UNIT = "temperatureUnit";
 
-    public static enum TemperatureUnit {
+    public enum TemperatureUnit {
         CELSIUS,
         FAHRENHEIT
     }
@@ -52,7 +52,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_HVAC_MODE = "hvacMode";
 
-    public static enum HvacMode {
+    public enum HvacMode {
         OFF,
         HEAT,
         COOL,
@@ -69,7 +69,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_FAN_SPEED = "fanspeed";
 
-    public static enum FanSpeed {
+    public enum FanSpeed {
         LOW,
         MIDDLE,
         HIGH,
@@ -78,7 +78,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_FAN_LEVEL = "fanLevel";
 
-    public static enum FanLevel {
+    public enum FanLevel {
         SILENT,
         LEVEL1,
         LEVEL2,
@@ -90,7 +90,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_HORIZONTAL_SWING = "horizontalSwing";
 
-    public static enum HorizontalSwing {
+    public enum HorizontalSwing {
         OFF,
         ON,
         LEFT,
@@ -103,7 +103,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_VERTICAL_SWING = "verticalSwing";
 
-    public static enum VerticalSwing {
+    public enum VerticalSwing {
         OFF,
         ON,
         UP,
@@ -116,7 +116,7 @@ public class TadoBindingConstants {
 
     public static final String CHANNEL_ZONE_OPERATION_MODE = "operationMode";
 
-    public static enum OperationMode {
+    public enum OperationMode {
         SCHEDULE,
         TIMER,
         MANUAL,
@@ -141,7 +141,7 @@ public class TadoBindingConstants {
     public static final String PROPERTY_ZONE_NAME = "name";
     public static final String PROPERTY_ZONE_TYPE = "type";
 
-    public static enum ZoneType {
+    public enum ZoneType {
         HEATING,
         AIR_CONDITIONING,
         HOT_WATER
index c38358a411f673300540ee31468f06d210a80fba..c770340a6451dee4b9867bd8cc5238ff8f76976f 100644 (file)
@@ -221,7 +221,7 @@ public class TadoZoneStateAdapter {
                 break;
         }
 
-        return power.getValue().equals("ON");
+        return "ON".equals(power.getValue());
     }
 
     private static DecimalType toDecimalType(double value) {
index f63d88742544140ae4086cde389425fd31c91cfc..cc2069e75ad3630ed6c31f2b6db55ca81ba2291c 100644 (file)
@@ -226,8 +226,8 @@ public class TadoApiTypeUtils {
             @Nullable GenericZoneCapabilities capabilities) {
         AirConditioningCapabilities acCapabilities;
 
-        if (capabilities instanceof AirConditioningCapabilities) {
-            acCapabilities = (AirConditioningCapabilities) capabilities;
+        if (capabilities instanceof AirConditioningCapabilities conditioningCapabilities) {
+            acCapabilities = conditioningCapabilities;
         } else {
             acCapabilities = new AirConditioningCapabilities();
         }
index 02586f3645c38351f3723afd2045ff67fe675a25..e600f2f44feff0ada2eda354fd5232893082aa09 100644 (file)
@@ -84,8 +84,7 @@ public class TerminationConditionBuilder {
     }
 
     private OverlayTerminationCondition getDefaultTerminationCondition() throws IOException, ApiException {
-        OverlayTerminationCondition defaultTerminationCondition = zoneHandler.getDefaultTerminationCondition();
-        return defaultTerminationCondition;
+        return zoneHandler.getDefaultTerminationCondition();
     }
 
     private TimerTerminationCondition getCurrentOrDefaultTimerTermination(ZoneStateProvider zoneStateProvider)
index 781401896b60c4bd016f3dce7195df41d866f2cf..7b0678108471e15393dc949e36327fbc520ea6f1 100644 (file)
@@ -14,10 +14,7 @@ package org.openhab.binding.tado.internal.handler;
 
 import static org.openhab.binding.tado.internal.TadoBindingConstants.*;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Set;
@@ -48,8 +45,8 @@ import org.osgi.service.component.annotations.Reference;
 @Component(configurationPid = "binding.tado", service = ThingHandlerFactory.class)
 public class TadoHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_HOME, THING_TYPE_ZONE, THING_TYPE_MOBILE_DEVICE)));
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_HOME, THING_TYPE_ZONE,
+            THING_TYPE_MOBILE_DEVICE);
 
     private final Map<ThingUID, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>();
 
index cc9f0ed2704545cc10f97cfd1632167fe9b6d871..faa86f2f7d91ab7071c677730c8eadda35ab2a1e 100644 (file)
@@ -179,8 +179,8 @@ public class TadoHomeHandler extends BaseBridgeHandler {
         switch (id) {
             case TadoBindingConstants.CHANNEL_HOME_PRESENCE_MODE:
                 HomePresence presence = new HomePresence();
-                presence.setHomePresence(command.toFullString().toUpperCase().equals("ON")
-                        || command.toFullString().toUpperCase().equals("HOME") ? PresenceState.HOME
+                presence.setHomePresence("ON".equals(command.toFullString().toUpperCase())
+                        || "HOME".equals(command.toFullString().toUpperCase()) ? PresenceState.HOME
                                 : PresenceState.AWAY);
                 try {
                     api.updatePresenceLock(homeId, presence);
index 6d3463ffe3527398b5bab847f2e51a9e3bb6e0e9..e8ef99a1069c6214fe9e3fb06c2c90e2c626f5b4 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.tankerkoenig.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -33,8 +32,8 @@ public class TankerkoenigBindingConstants {
     public static final ThingTypeUID THING_TYPE_TANKSTELLE = new ThingTypeUID(BINDING_ID, "station");
     public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "webservice");
 
-    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(BRIDGE_THING_TYPE);
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_TANKSTELLE);
+    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_TANKSTELLE);
 
     // List of all Channel ids
     public static final String CHANNEL_DIESEL = "diesel";
index 21a1175949501d9859f8bed07234a051f8ba0eb9..0b686addbe7388a3e4c8c0a5bebcc3432abbd031 100644 (file)
@@ -53,8 +53,7 @@ public class TankerkoenigHandlerFactory extends BaseThingHandlerFactory {
     protected @Nullable ThingHandler createHandler(Thing thing) {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
         if (thingTypeUID.equals(BRIDGE_THING_TYPE)) {
-            WebserviceHandler handler = new WebserviceHandler((Bridge) thing);
-            return handler;
+            return new WebserviceHandler((Bridge) thing);
         } else if (thingTypeUID.equals(THING_TYPE_TANKSTELLE)) {
             return new StationHandler(thing);
         }
index d0284ad3123021ad2215c278681a0c82419ff975..5a2381423b2deb0e7dfa944d75f7e21aa7416ba0 100644 (file)
@@ -84,8 +84,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof TapoBridgeHandler) {
-            TapoBridgeHandler tapoBridge = (TapoBridgeHandler) handler;
+        if (handler instanceof TapoBridgeHandler tapoBridge) {
             tapoBridge.setDiscoveryService(this);
             this.bridge = tapoBridge;
         }
index 81cf005e91128df8d4a4c5f47933578fa6f56dfe..468948e074088e055abb237ed9b8a4903f4b4302 100644 (file)
@@ -222,8 +222,7 @@ public class TapoCloudConnector {
         httpRequest.content(new StringContentProvider(payload, CONTENT_CHARSET), CONTENT_TYPE_JSON);
 
         try {
-            ContentResponse httpResponse = httpRequest.send();
-            return httpResponse;
+            return httpRequest.send();
         } catch (InterruptedException e) {
             logger.debug("({}) sending request interrupted: {}", uid, e.toString());
             handleError(new TapoErrorHandler(e));
index 26ed25aebaee15cd6d074810940ba48a8b7cbc38..e1c06b3af797ba88a8b5e00b51f0373eb59b515a 100644 (file)
@@ -158,7 +158,7 @@ public class TapoDeviceHttpApi {
             String payload = plBuilder.getPayload();
 
             /* send request (create ) */
-            logger.trace("({}) create handhsake with payload: {}", uid, payload.toString());
+            logger.trace("({}) create handhsake with payload: {}", uid, payload);
             ContentResponse response = sendRequest(this.deviceURL, payload);
             if (response != null && getErrorCode(response) == 0) {
                 String encryptedKey = getKeyFromResponse(response);
@@ -308,8 +308,7 @@ public class TapoDeviceHttpApi {
         httpRequest.content(new StringContentProvider(payload, CONTENT_CHARSET), CONTENT_TYPE_JSON);
 
         try {
-            ContentResponse httpResponse = httpRequest.send();
-            return httpResponse;
+            return httpRequest.send();
         } catch (InterruptedException e) {
             logger.debug("({}) sending request interrupted: {}", uid, e.toString());
             handleError(new TapoErrorHandler(e));
index a1582e18214e677e557a9cad52844450610884d4..de19b13ce3aa2e69d12aaa5f2756deb49fa64789 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.tapocontrol.internal.device;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -114,7 +114,7 @@ public class TapoBridgeHandler extends BaseBridgeHandler {
      */
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TapoDiscoveryService.class);
+        return Set.of(TapoDiscoveryService.class);
     }
 
     /**
index d62bd192c0f0567442af979dc3f22fe233230b41..50d42e1d172475231ee6a991bce2802e38c6dbf8 100644 (file)
@@ -140,7 +140,7 @@ public abstract class TapoDevice extends BaseThingHandler {
         TapoErrorHandler configErr = new TapoErrorHandler();
 
         /* check bridge */
-        if (bridge == null || !(bridge instanceof TapoBridgeHandler)) {
+        if (!(bridge instanceof TapoBridgeHandler)) {
             configErr.raiseError(ERR_CONFIG_NO_BRIDGE);
             return configErr;
         }
index 29f1a9c59e0bc309b59b6d1f607082070912b7e4..f453cd87cb16832b20e8836b9beda244f2482139 100644 (file)
@@ -76,24 +76,24 @@ public class TapoLightStrip extends TapoDevice {
                     refreshInfo = true;
                     break;
                 case CHANNEL_BRIGHTNESS:
-                    if (command instanceof PercentType) {
-                        Float percent = ((PercentType) command).floatValue();
+                    if (command instanceof PercentType percentCommand) {
+                        Float percent = percentCommand.floatValue();
                         setBrightness(percent.intValue()); // 0..100% = 0..100
                         refreshInfo = true;
-                    } else if (command instanceof DecimalType) {
-                        setBrightness(((DecimalType) command).intValue());
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        setBrightness(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR_TEMP:
-                    if (command instanceof DecimalType) {
-                        setColorTemp(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        setColorTemp(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR:
-                    if (command instanceof HSBType) {
-                        setColor((HSBType) command);
+                    if (command instanceof HSBType hsbCommand) {
+                        setColor(hsbCommand);
                         refreshInfo = true;
                     }
                     break;
@@ -163,11 +163,11 @@ public class TapoLightStrip extends TapoDevice {
         TapoLightEffect lightEffect = deviceInfo.getLightEffect();
         switch (channel) {
             case CHANNEL_FX_BRIGHTNESS:
-                if (command instanceof PercentType) {
-                    Float percent = ((PercentType) command).floatValue();
+                if (command instanceof PercentType percentCommand) {
+                    Float percent = percentCommand.floatValue();
                     lightEffect.setBrightness(percent.intValue()); // 0..100% = 0..100
-                } else if (command instanceof DecimalType) {
-                    lightEffect.setBrightness(((DecimalType) command).intValue());
+                } else if (command instanceof DecimalType decimalCommand) {
+                    lightEffect.setBrightness(decimalCommand.intValue());
                 }
                 break;
             case CHANNEL_FX_COLORS:
index d55c2c27d9e8e51e3e5402306ccd9652888fd042..fc76768ac3080e50614614fa0d6f44e84d5d2edc 100644 (file)
@@ -71,24 +71,24 @@ public class TapoSmartBulb extends TapoDevice {
                     refreshInfo = true;
                     break;
                 case CHANNEL_BRIGHTNESS:
-                    if (command instanceof PercentType) {
-                        Float percent = ((PercentType) command).floatValue();
+                    if (command instanceof PercentType percentCommand) {
+                        Float percent = percentCommand.floatValue();
                         setBrightness(percent.intValue()); // 0..100% = 0..100
                         refreshInfo = true;
-                    } else if (command instanceof DecimalType) {
-                        setBrightness(((DecimalType) command).intValue());
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        setBrightness(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR_TEMP:
-                    if (command instanceof DecimalType) {
-                        setColorTemp(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        setColorTemp(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR:
-                    if (command instanceof HSBType) {
-                        setColor((HSBType) command);
+                    if (command instanceof HSBType hsbCommand) {
+                        setColor(hsbCommand);
                         refreshInfo = true;
                     }
                     break;
index 083e73f45f550ff0dfc59f123eebdbc97955911f..20b80f78b47c60a39f43597b30195aac33583962 100644 (file)
@@ -70,24 +70,24 @@ public class TapoUniversalDevice extends TapoDevice {
                     refreshInfo = true;
                     break;
                 case CHANNEL_BRIGHTNESS:
-                    if (command instanceof PercentType) {
-                        Float percent = ((PercentType) command).floatValue();
+                    if (command instanceof PercentType percentCommand) {
+                        Float percent = percentCommand.floatValue();
                         setBrightness(percent.intValue()); // 0..100% = 0..100
                         refreshInfo = true;
-                    } else if (command instanceof DecimalType) {
-                        setBrightness(((DecimalType) command).intValue());
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        setBrightness(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR_TEMP:
-                    if (command instanceof DecimalType) {
-                        setColorTemp(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        setColorTemp(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR:
-                    if (command instanceof HSBType) {
-                        setColor((HSBType) command);
+                    if (command instanceof HSBType hsbCommand) {
+                        setColor(hsbCommand);
                         refreshInfo = true;
                     }
                     break;
@@ -173,6 +173,7 @@ public class TapoUniversalDevice extends TapoDevice {
      * 
      * @param responseBody
      */
+    @Override
     public void responsePasstrough(String responseBody) {
         logger.debug("({}) received response {}", uid, responseBody);
         publishState(getChannelID(CHANNEL_GROUP_DEBUG, CHANNEL_RESPONSE), getStringType(responseBody));
@@ -224,6 +225,7 @@ public class TapoUniversalDevice extends TapoDevice {
      * @param channelID String channelID
      * @return String channel-name
      */
+    @Override
     protected String getChannelFromID(ChannelUID channelID) {
         String channel = channelID.getIdWithoutGroup();
         channel = channel.replace(CHANNEL_GROUP_ACTUATOR + "#", "");
index 810347e2a7c51bfd21d4056bfee76de2f85dacf9..06ac60316a9beeb2314fa26d5fd84c1262ad23b8 100644 (file)
@@ -44,10 +44,10 @@ public class PayloadBuilder {
      * @param value parameter value (typeOf Bool,Number or String)
      */
     public void addParameter(String name, Object value) {
-        if (value instanceof Boolean) {
-            this.parameters.addProperty(name, (Boolean) value);
-        } else if (value instanceof Number) {
-            this.parameters.addProperty(name, (Number) value);
+        if (value instanceof Boolean bool) {
+            this.parameters.addProperty(name, bool);
+        } else if (value instanceof Number number) {
+            this.parameters.addProperty(name, number);
         } else {
             this.parameters.addProperty(name, value.toString());
         }
index 72db563011c2db9417ab3358939c9ea2c8d0bdd1..83cd3f86e1d25e69ee4f2e228ee75da62aa5ecab 100644 (file)
@@ -82,8 +82,7 @@ public class TapoUtils {
      */
     public static String formatMac(String mac, char newDivisionChar) {
         String unformatedMac = unformatMac(mac);
-        String formatedMac = unformatedMac.replaceAll("(.{2})", "$1" + newDivisionChar).substring(0, 17);
-        return formatedMac;
+        return unformatedMac.replaceAll("(.{2})", "$1" + newDivisionChar).substring(0, 17);
     }
 
     /**
index 65d0cfcb8f4271ed67b15478b2b536a2be7481f6..209b0576147c99c46354759eb159ac30cac5bfbf 100644 (file)
@@ -34,7 +34,7 @@ public class TapoLightEffect {
     private Boolean custom = false;
     private Integer brightness = 0;
     private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000]
-    private Color displayColors[] = { Color.WHITE };
+    private Color[] displayColors = { Color.WHITE };
 
     private JsonObject jsonObject = new JsonObject();
 
index 26f377033be6e9121335813bef1573f14cae5996..0f49a5e3dfc06afc2b272934de0f4c3c6ff09c80 100644 (file)
@@ -84,8 +84,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof TapoBridgeHandler) {
-            TapoBridgeHandler tapoBridge = (TapoBridgeHandler) handler;
+        if (handler instanceof TapoBridgeHandler tapoBridge) {
             tapoBridge.setDiscoveryService(this);
             this.bridge = tapoBridge;
         }
index 9357d4bbdbb42f15b468d39b732209125a82f08a..2654ce9cb863e3d1b1c5ab662b1aff7b29d7ef7b 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.tapocontrol.internal.device;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -116,7 +116,7 @@ public class TapoBridgeHandler extends BaseBridgeHandler {
      */
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TapoDiscoveryService.class);
+        return Set.of(TapoDiscoveryService.class);
     }
 
     /**
index 257466f5ec7b4b275ea5c24251321f8c33d84a78..36bece8ac7417364ecbef36b9ef7884aa2e03cac 100644 (file)
@@ -70,24 +70,24 @@ public class TapoUniversalDevice extends TapoDevice {
                     refreshInfo = true;
                     break;
                 case CHANNEL_BRIGHTNESS:
-                    if (command instanceof PercentType) {
-                        Float percent = ((PercentType) command).floatValue();
+                    if (command instanceof PercentType percentCommand) {
+                        Float percent = percentCommand.floatValue();
                         setBrightness(percent.intValue()); // 0..100% = 0..100
                         refreshInfo = true;
-                    } else if (command instanceof DecimalType) {
-                        setBrightness(((DecimalType) command).intValue());
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        setBrightness(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR_TEMP:
-                    if (command instanceof DecimalType) {
-                        setColorTemp(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        setColorTemp(decimalCommand.intValue());
                         refreshInfo = true;
                     }
                     break;
                 case CHANNEL_COLOR:
-                    if (command instanceof HSBType) {
-                        setColor((HSBType) command);
+                    if (command instanceof HSBType hsbCommand) {
+                        setColor(hsbCommand);
                         refreshInfo = true;
                     }
                     break;
@@ -173,6 +173,7 @@ public class TapoUniversalDevice extends TapoDevice {
      * 
      * @param responseBody
      */
+    @Override
     public void responsePasstrough(String responseBody) {
         logger.info("({}) received response {}", uid, responseBody);
         publishState(getChannelID(CHANNEL_GROUP_DEBUG, CHANNEL_RESPONSE), getStringType(responseBody));
@@ -224,6 +225,7 @@ public class TapoUniversalDevice extends TapoDevice {
      * @param channelID String channelID
      * @return String channel-name
      */
+    @Override
     protected String getChannelFromID(ChannelUID channelID) {
         String channel = channelID.getIdWithoutGroup();
         channel = channel.replace(CHANNEL_GROUP_ACTUATOR + "#", "");
index 0e4e9fe49f36d5b2b373a49819d6da03378079ef..857eab04c28efaea3a4c6d850da114d1453813e3 100644 (file)
@@ -34,7 +34,7 @@ public class TapoLightEffect {
     private Integer custom = 0;
     private Integer brightness = 0;
     private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000]
-    private Color displayColors[] = { Color.WHITE };
+    private Color[] displayColors = { Color.WHITE };
 
     private JsonObject jsonObject = new JsonObject();
 
index 627363113dd4e4fd45a40aed6cad778354cc0704..27fbb6d85619703b090464e1a67b512573f43021 100644 (file)
@@ -22,12 +22,12 @@ import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -473,7 +473,7 @@ public class TelegramHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TelegramActions.class);
+        return Set.of(TelegramActions.class);
     }
 
     /**
index 709982b8857db6cc3e4bc081e2ae4757b4793f37..968703484786942d70f9ec1905a4a6badde4fb13 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.telegram.internal;
 
 import static org.openhab.binding.telegram.internal.TelegramBindingConstants.TELEGRAM_THING;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -40,7 +39,7 @@ import org.osgi.service.component.annotations.Reference;
 @Component(configurationPid = "binding.telegram", service = ThingHandlerFactory.class)
 public class TelegramHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(TELEGRAM_THING);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(TELEGRAM_THING);
 
     private final HttpClient httpClient;
 
index 4f3dedc4e256c6dae18f641c71f1b1de724b1eea..3b43d4a4e34d5a28e0aa4d093c362569cef17dde 100644 (file)
@@ -672,11 +672,11 @@ public class TelegramActions implements ThingActions {
 
     public static boolean sendTelegramAnswer(ThingActions actions, @Nullable String chatId, @Nullable String replyId,
             @Nullable String message) {
-        if (actions instanceof TelegramActions) {
+        if (actions instanceof TelegramActions telegramActions) {
             if (chatId == null) {
                 return false;
             }
-            return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), replyId, message);
+            return telegramActions.sendTelegramAnswer(Long.valueOf(chatId), replyId, message);
         } else {
             throw new IllegalArgumentException("Actions is not an instance of TelegramActions");
         }
@@ -689,11 +689,11 @@ public class TelegramActions implements ThingActions {
 
     public static boolean sendTelegramAnswer(ThingActions actions, @Nullable String chatId, @Nullable String callbackId,
             @Nullable String messageId, @Nullable String message) {
-        if (actions instanceof TelegramActions) {
+        if (actions instanceof TelegramActions telegramActions) {
             if (chatId == null) {
                 return false;
             }
-            return ((TelegramActions) actions).sendTelegramAnswer(Long.valueOf(chatId), callbackId,
+            return telegramActions.sendTelegramAnswer(Long.valueOf(chatId), callbackId,
                     messageId != null ? Long.parseLong(messageId) : null, message);
         } else {
             throw new IllegalArgumentException("Actions is not an instance of TelegramActions");
index fdf05c0f04702ca8e4ce0b2f7dd0b95114f0496d..ac8d1529b688935e7810b5681940a4d88881301e 100644 (file)
@@ -187,8 +187,8 @@ public class TeleinfoDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof TeleinfoAbstractControllerHandler) {
-            controllerHandler = (TeleinfoAbstractControllerHandler) handler;
+        if (handler instanceof TeleinfoAbstractControllerHandler teleinfoAbstractControllerHandler) {
+            controllerHandler = teleinfoAbstractControllerHandler;
         }
     }
 
index f15d4e4d96496eec6172d8f365163ae8aa95f934..308e1235c8f115ef9fe6454e8311e04f70d34d57 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.binding.teleinfo.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
@@ -52,6 +51,6 @@ public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandle
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TeleinfoDiscoveryService.class);
+        return Set.of(TeleinfoDiscoveryService.class);
     }
 }
index 302085dacb9decc8c4c2481e6bc0b3d9d67ab902..aa4ce7c1f8a2720cfc47959596e65c7aa97d88bb 100644 (file)
@@ -120,8 +120,8 @@ public class TellstickHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof TelldusBridgeHandler) {
-            unregisterDeviceDiscoveryService((TelldusBridgeHandler) thingHandler);
+        if (thingHandler instanceof TelldusBridgeHandler telldusBridgeHandler) {
+            unregisterDeviceDiscoveryService(telldusBridgeHandler);
         }
     }
 }
index c7687c5bcc8c37c71a4bdbd2645b28b1741cf3c8..e04878168af790bff6b1d67ba441656a9e709d93 100644 (file)
@@ -156,10 +156,10 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
                     turnOn(device);
                 } else if (command == OnOffType.OFF) {
                     turnOff(device);
-                } else if (command instanceof PercentType) {
-                    dim(device, (PercentType) command);
-                } else if (command instanceof IncreaseDecreaseType) {
-                    increaseDecrease(device, ((IncreaseDecreaseType) command));
+                } else if (command instanceof PercentType percentCommand) {
+                    dim(device, percentCommand);
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    increaseDecrease(device, increaseDecreaseCommand);
                 }
             } else if (device instanceof SwitchableDevice) {
                 if (command == OnOffType.ON) {
@@ -198,29 +198,29 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
         double value = command.doubleValue();
 
         // 0 means OFF and 100 means ON
-        if (value == 0 && dev instanceof SwitchableDevice) {
-            ((SwitchableDevice) dev).off();
-        } else if (value == 100 && dev instanceof SwitchableDevice) {
-            ((SwitchableDevice) dev).on();
-        } else if (dev instanceof DimmableDevice) {
+        if (value == 0 && dev instanceof SwitchableDevice device) {
+            device.off();
+        } else if (value == 100 && dev instanceof SwitchableDevice device) {
+            device.on();
+        } else if (dev instanceof DimmableDevice device) {
             long tdVal = Math.round((value / 100) * 255);
-            ((DimmableDevice) dev).dim((int) tdVal);
+            device.dim((int) tdVal);
         } else {
             throw new TelldusBindingException("Cannot send DIM to " + dev);
         }
     }
 
     private void turnOff(Device dev) throws TellstickException {
-        if (dev instanceof SwitchableDevice) {
-            ((SwitchableDevice) dev).off();
+        if (dev instanceof SwitchableDevice device) {
+            device.off();
         } else {
             throw new TelldusBindingException("Cannot send OFF to " + dev);
         }
     }
 
     private void turnOn(Device dev) throws TellstickException {
-        if (dev instanceof SwitchableDevice) {
-            ((SwitchableDevice) dev).on();
+        if (dev instanceof SwitchableDevice device) {
+            device.on();
         } else {
             throw new TelldusBindingException("Cannot send ON to " + dev);
         }
index 0f2216527c887441650aed70140506fbbe4f2a09..83ae3e257ac36c4604b7a0e1a729264ecd8221be 100644 (file)
@@ -135,16 +135,16 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
                 } else if (device instanceof SwitchableDevice) {
                     thingUID = new ThingUID(TellstickBindingConstants.SWITCH_THING_TYPE, bridge.getUID(),
                             device.getUUId());
-                } else if (device instanceof TellstickNetDevice) {
-                    if ((((TellstickNetDevice) device).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
+                } else if (device instanceof TellstickNetDevice netDevice) {
+                    if ((netDevice.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
                         thingUID = new ThingUID(TellstickBindingConstants.DIMMER_THING_TYPE, bridge.getUID(),
                                 device.getUUId());
                     } else {
                         thingUID = new ThingUID(TellstickBindingConstants.SWITCH_THING_TYPE, bridge.getUID(),
                                 device.getUUId());
                     }
-                } else if (device instanceof TellstickLocalDeviceDTO) {
-                    if ((((TellstickLocalDeviceDTO) device).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
+                } else if (device instanceof TellstickLocalDeviceDTO localDevice) {
+                    if ((localDevice.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
                         thingUID = new ThingUID(TellstickBindingConstants.DIMMER_THING_TYPE, bridge.getUID(),
                                 device.getUUId());
                     } else {
@@ -162,8 +162,7 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
     private ThingTypeUID findSensorType(Device device) {
         logger.debug("Device: {}", device);
         ThingTypeUID sensorThingId;
-        if (device instanceof TellstickSensor) {
-            TellstickSensor sensor = (TellstickSensor) device;
+        if (device instanceof TellstickSensor sensor) {
             logger.debug("Sensor: {}", device);
             if (sensor.getData(DataType.WINDAVERAGE) != null || sensor.getData(DataType.WINDGUST) != null
                     || sensor.getData(DataType.WINDDIRECTION) != null) {
@@ -173,8 +172,7 @@ public class TellstickDiscoveryService extends AbstractDiscoveryService implemen
             } else {
                 sensorThingId = TellstickBindingConstants.SENSOR_THING_TYPE;
             }
-        } else if (device instanceof TellstickNetSensor) {
-            TellstickNetSensor sensor = (TellstickNetSensor) device;
+        } else if (device instanceof TellstickNetSensor sensor) {
             if (sensor.isSensorOfType(LiveDataType.WINDAVERAGE) || sensor.isSensorOfType(LiveDataType.WINDDIRECTION)
                     || sensor.isSensorOfType(LiveDataType.WINDGUST)) {
                 sensorThingId = TellstickBindingConstants.WINDSENSOR_THING_TYPE;
index c3c2cdf9e2bec265aff995e58d9217c0a049d131..b1fef0d7c70ce33d42ed422f7eea1cbc53318d03 100644 (file)
@@ -241,29 +241,29 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
     }
 
     private boolean isSensor() {
-        return (getThing().getThingTypeUID().equals(TellstickBindingConstants.SENSOR_THING_TYPE)
+        return getThing().getThingTypeUID().equals(TellstickBindingConstants.SENSOR_THING_TYPE)
                 || getThing().getThingTypeUID().equals(TellstickBindingConstants.RAINSENSOR_THING_TYPE)
                 || getThing().getThingTypeUID().equals(TellstickBindingConstants.WINDSENSOR_THING_TYPE)
-                || getThing().getThingTypeUID().equals(TellstickBindingConstants.POWERSENSOR_THING_TYPE));
+                || getThing().getThingTypeUID().equals(TellstickBindingConstants.POWERSENSOR_THING_TYPE);
     }
 
     private void updateSensorStates(Device dev) {
-        if (dev instanceof TellstickSensor) {
+        if (dev instanceof TellstickSensor sensor) {
             updateStatus(ThingStatus.ONLINE);
-            for (DataType type : ((TellstickSensor) dev).getData().keySet()) {
-                updateSensorDataState(type, ((TellstickSensor) dev).getData(type));
+            for (DataType type : sensor.getData().keySet()) {
+                updateSensorDataState(type, sensor.getData(type));
             }
-        } else if (dev instanceof TellstickNetSensor) {
-            if (((TellstickNetSensor) dev).getOnline()) {
+        } else if (dev instanceof TellstickNetSensor netSensor) {
+            if (netSensor.getOnline()) {
                 updateStatus(ThingStatus.ONLINE);
             } else {
                 updateStatus(ThingStatus.OFFLINE);
             }
-            for (DataTypeValue type : ((TellstickNetSensor) dev).getData()) {
+            for (DataTypeValue type : netSensor.getData()) {
                 updateSensorDataState(type);
             }
-        } else if (dev instanceof TellstickLocalSensorDTO) {
-            for (LocalDataTypeValueDTO type : ((TellstickLocalSensorDTO) dev).getData()) {
+        } else if (dev instanceof TellstickLocalSensorDTO localSensor) {
+            for (LocalDataTypeValueDTO type : localSensor.getData()) {
                 updateSensorDataState(type);
             }
         }
@@ -283,14 +283,11 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
         if (device.getUUId().equals(deviceId)) {
             if (event instanceof TellstickDeviceEvent) {
                 updateDeviceState(device);
-            } else if (event instanceof TellstickNetSensorEvent) {
-                TellstickNetSensorEvent sensorevent = (TellstickNetSensorEvent) event;
+            } else if (event instanceof TellstickNetSensorEvent sensorevent) {
                 updateSensorDataState(sensorevent.getDataTypeValue());
-            } else if (event instanceof TellstickLocalSensorEventDTO) {
-                TellstickLocalSensorEventDTO sensorevent = (TellstickLocalSensorEventDTO) event;
+            } else if (event instanceof TellstickLocalSensorEventDTO sensorevent) {
                 updateSensorDataState(sensorevent.getDataTypeValue());
-            } else if (event instanceof TellstickSensorEvent) {
-                TellstickSensorEvent sensorevent = (TellstickSensorEvent) event;
+            } else if (event instanceof TellstickSensorEvent sensorevent) {
                 updateSensorDataState(sensorevent.getDataType(), sensorevent.getData());
             } else {
                 logger.debug("Unhandled Device {}.", device.getDeviceType());
@@ -356,7 +353,7 @@ public class TelldusDevicesHandler extends BaseThingHandler implements DeviceSta
                         new QuantityType<>(new BigDecimal(dataType.getValue()), WIND_SPEED_UNIT_MS));
                 break;
             case WATT:
-                if (dataType.getUnit() != null && dataType.getUnit().equals("A")) {
+                if ("A".equals(dataType.getUnit())) {
                     updateState(ampereChannel, new QuantityType<>(new BigDecimal(dataType.getValue()), ELECTRIC_UNIT));
                 } else {
                     updateState(wattChannel, new QuantityType<>(new BigDecimal(dataType.getValue()), POWER_UNIT));
index 3d4b5b55c107ce6952d451eb25d98c29bd5466e1..5952a305fc77e540616208ebd6d14ffbd850fc8b 100644 (file)
@@ -129,10 +129,10 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
                 turnOn(device);
             } else if (command == OnOffType.OFF) {
                 turnOff(device);
-            } else if (command instanceof PercentType) {
-                dim(device, (PercentType) command);
-            } else if (command instanceof IncreaseDecreaseType) {
-                increaseDecrease(device, ((IncreaseDecreaseType) command));
+            } else if (command instanceof PercentType percentCommand) {
+                dim(device, percentCommand);
+            } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                increaseDecrease(device, increaseDecreaseCommand);
             }
         } else if (device instanceof SwitchableDevice) {
             if (command == OnOffType.ON) {
@@ -172,22 +172,21 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
             turnOff(dev);
         } else if (value == 100 && dev instanceof TellstickNetDevice) {
             turnOn(dev);
-        } else if (dev instanceof TellstickNetDevice
-                && (((TellstickNetDevice) dev).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
+        } else if (dev instanceof TellstickNetDevice device && (device.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
             long tdVal = Math.round((value / 100) * 255);
             TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_DIM, dev.getId(), tdVal),
                     TelldusLiveResponse.class);
-            handleResponse((TellstickNetDevice) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send DIM to " + dev);
         }
     }
 
     private void turnOff(Device dev) throws TellstickException {
-        if (dev instanceof TellstickNetDevice) {
+        if (dev instanceof TellstickNetDevice device) {
             TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_TURNOFF, dev.getId()),
                     TelldusLiveResponse.class);
-            handleResponse((TellstickNetDevice) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send OFF to " + dev);
         }
@@ -197,21 +196,21 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
         if (response == null || (response.status == null && response.error == null)) {
             throw new TelldusBindingException("No response " + response);
         } else if (response.error != null) {
-            if (response.error.equals("The client for this device is currently offline")) {
+            if ("The client for this device is currently offline".equals(response.error)) {
                 device.setOnline(false);
                 device.setUpdated(true);
             }
             throw new TelldusBindingException("Error " + response.error);
-        } else if (!response.status.trim().equals("success")) {
+        } else if (!"success".equals(response.status.trim())) {
             throw new TelldusBindingException("Response " + response.status);
         }
     }
 
     private void turnOn(Device dev) throws TellstickException {
-        if (dev instanceof TellstickNetDevice) {
+        if (dev instanceof TellstickNetDevice device) {
             TelldusLiveResponse response = callRestMethod(String.format(HTTP_TELLDUS_DEVICE_TURNON, dev.getId()),
                     TelldusLiveResponse.class);
-            handleResponse((TellstickNetDevice) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send ON to " + dev);
         }
index 12dbe685b643197ba12490912c387d5f428fa23f..2da7a014620e34280688429f308036438b4712a2 100644 (file)
@@ -90,10 +90,10 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
                     turnOn(device);
                 } else if (command == OnOffType.OFF) {
                     turnOff(device);
-                } else if (command instanceof PercentType) {
-                    dim(device, (PercentType) command);
-                } else if (command instanceof IncreaseDecreaseType) {
-                    increaseDecrease(device, ((IncreaseDecreaseType) command));
+                } else if (command instanceof PercentType percentCommand) {
+                    dim(device, percentCommand);
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    increaseDecrease(device, increaseDecreaseCommand);
                 }
             } else if (device instanceof SwitchableDevice) {
                 if (command == OnOffType.ON) {
@@ -137,22 +137,22 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
             turnOff(dev);
         } else if (value == 100 && dev instanceof TellstickLocalDeviceDTO) {
             turnOn(dev);
-        } else if (dev instanceof TellstickLocalDeviceDTO
-                && (((TellstickLocalDeviceDTO) dev).getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
+        } else if (dev instanceof TellstickLocalDeviceDTO device
+                && (device.getMethods() & JNA.CLibrary.TELLSTICK_DIM) > 0) {
             long tdVal = Math.round((value / 100) * 255);
             TelldusLocalResponseDTO response = callRestMethod(
                     String.format(HTTP_LOCAL_API_DEVICE_DIM, dev.getId(), tdVal), TelldusLocalResponseDTO.class);
-            handleResponse((TellstickLocalDeviceDTO) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send DIM to " + dev);
         }
     }
 
     private void turnOff(Device dev) throws TellstickException, InterruptedException {
-        if (dev instanceof TellstickLocalDeviceDTO) {
+        if (dev instanceof TellstickLocalDeviceDTO device) {
             TelldusLocalResponseDTO response = callRestMethod(String.format(HTTP_LOCAL_API_DEVICE_TURNOFF, dev.getId()),
                     TelldusLocalResponseDTO.class);
-            handleResponse((TellstickLocalDeviceDTO) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send OFF to " + dev);
         }
@@ -165,16 +165,16 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
         } else if (response.getError() != null) {
             device.setUpdated(true);
             throw new TelldusBindingException("Error " + response.getError());
-        } else if (!response.getStatus().trim().equals("success")) {
+        } else if (!"success".equals(response.getStatus().trim())) {
             throw new TelldusBindingException("Response " + response.getStatus());
         }
     }
 
     private void turnOn(Device dev) throws TellstickException, InterruptedException {
-        if (dev instanceof TellstickLocalDeviceDTO) {
+        if (dev instanceof TellstickLocalDeviceDTO device) {
             TelldusLocalResponseDTO response = callRestMethod(String.format(HTTP_LOCAL_DEVICE_TURNON, dev.getId()),
                     TelldusLocalResponseDTO.class);
-            handleResponse((TellstickLocalDeviceDTO) dev, response);
+            handleResponse(device, response);
         } else {
             throw new TelldusBindingException("Cannot send ON to " + dev);
         }
index 58836d35c4f4a2f44b85363db2a1e1b54bbf418f..40d5a990ba8ae01b3bc35720d0e185b7ad6110d2 100644 (file)
@@ -964,7 +964,7 @@ public class TeslaChannelSelectorProxy {
         VEHICLE_NAME("vehicle_name", "name", StringType.class, true) {
             @Override
             public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
-                return super.getState(s.replaceAll("\"", ""));
+                return super.getState(s.replace("\"", ""));
             }
         },
         VALET_MODE("valet_mode", "valetmode", OnOffType.class, false) {
index 993ebf7eea971eeab443a31d1886abf850457fa8..62dbc82830a62da4552f2abc9b75f60db4711628 100644 (file)
@@ -18,7 +18,6 @@ import java.time.Instant;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -472,6 +471,6 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(TeslaVehicleDiscoveryService.class);
+        return List.of(TeslaVehicleDiscoveryService.class);
     }
 }
index 04bc9341e31afebbcbdd00e3fb38bbfcf79fe864..826316f5e6ef558dde69403e56630ad1cfb7f878 100644 (file)
@@ -256,8 +256,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
             try {
                 switch (selector) {
                     case CHARGE_LIMIT_SOC: {
-                        if (command instanceof PercentType) {
-                            setChargeLimit(((PercentType) command).intValue());
+                        if (command instanceof PercentType percentCommand) {
+                            setChargeLimit(percentCommand.intValue());
                         } else if (command instanceof OnOffType && command == OnOffType.ON) {
                             setChargeLimit(100);
                         } else if (command instanceof OnOffType && command == OnOffType.OFF) {
@@ -273,11 +273,11 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                     }
                     case CHARGE_AMPS:
                         Integer amps = null;
-                        if (command instanceof DecimalType) {
-                            amps = ((DecimalType) command).intValue();
+                        if (command instanceof DecimalType decimalCommand) {
+                            amps = decimalCommand.intValue();
                         }
-                        if (command instanceof QuantityType<?>) {
-                            QuantityType<?> qamps = ((QuantityType<?>) command).toUnit(Units.AMPERE);
+                        if (command instanceof QuantityType<?> quantityCommand) {
+                            QuantityType<?> qamps = quantityCommand.toUnit(Units.AMPERE);
                             if (qamps != null) {
                                 amps = qamps.intValue();
                             }
@@ -324,8 +324,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case CHARGE_TO_MAX: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 setMaxRangeCharging(true);
                             } else {
                                 setMaxRangeCharging(false);
@@ -334,8 +334,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case CHARGE: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 charge(true);
                             } else {
                                 charge(false);
@@ -344,32 +344,32 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case FLASH: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 flashLights();
                             }
                         }
                         break;
                     }
                     case HONK_HORN: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 honkHorn();
                             }
                         }
                         break;
                     }
                     case CHARGEPORT: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 openChargePort();
                             }
                         }
                         break;
                     }
                     case DOOR_LOCK: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 lockDoors(true);
                             } else {
                                 lockDoors(false);
@@ -378,8 +378,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case AUTO_COND: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 autoConditioning(true);
                             } else {
                                 autoConditioning(false);
@@ -388,24 +388,24 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case WAKEUP: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 wakeUp();
                             }
                         }
                         break;
                     }
                     case FT: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 openFrunk();
                             }
                         }
                         break;
                     }
                     case RT: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 if (vehicleState.rt == 0) {
                                     openTrunk();
                                 }
@@ -416,9 +416,9 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case VALET_MODE: {
-                        if (command instanceof OnOffType) {
+                        if (command instanceof OnOffType onOffCommand) {
                             int valetpin = ((BigDecimal) getConfig().get(VALETPIN)).intValue();
-                            if (((OnOffType) command) == OnOffType.ON) {
+                            if (onOffCommand == OnOffType.ON) {
                                 setValetMode(true, valetpin);
                             } else {
                                 setValetMode(false, valetpin);
@@ -427,16 +427,16 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         break;
                     }
                     case RESET_VALET_PIN: {
-                        if (command instanceof OnOffType) {
-                            if (((OnOffType) command) == OnOffType.ON) {
+                        if (command instanceof OnOffType onOffCommand) {
+                            if (onOffCommand == OnOffType.ON) {
                                 resetValetPin();
                             }
                         }
                         break;
                     }
                     case STEERINGWHEEL_HEATER: {
-                        if (command instanceof OnOffType) {
-                            boolean commandBooleanValue = ((OnOffType) command) == OnOffType.ON ? true : false;
+                        if (command instanceof OnOffType onOffCommand) {
+                            boolean commandBooleanValue = onOffCommand == OnOffType.ON ? true : false;
                             setSteeringWheelHeater(commandBooleanValue);
                         }
                         break;
@@ -1025,7 +1025,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                             case "data:update":
                                 logger.debug("Event : Received an update: '{}'", event.value);
 
-                                String vals[] = event.value.split(",");
+                                String[] vals = event.value.split(",");
                                 long currentTimeStamp = Long.parseLong(vals[0]);
                                 long systemTimeStamp = System.currentTimeMillis();
                                 if (logger.isDebugEnabled()) {
index 68ec816fe8ebb277c42b6e0da0fb5b845e90b343..7cb93eb8e0e81a9996c4a11f8f1f64e20d2c102b 100644 (file)
@@ -26,7 +26,7 @@ public class Vehicle {
     public String option_codes;
     public String vehicle_id;
     public String vin;
-    public String tokens[];
+    public String[] tokens;
     public String state;
     public boolean remote_start_enabled;
     public boolean calendar_enabled;
index 2295434cb00def39d345fe5c5b9f1c86ddcdbd58..57195bdfaed404a65f90e6263cfaca4ae5dae46a 100644 (file)
@@ -26,7 +26,7 @@ public class VehicleData {
     public String option_codes;
     public String vehicle_id;
     public String vin;
-    public String tokens[];
+    public String[] tokens;
     public String state;
     public boolean remote_start_enabled;
     public boolean calendar_enabled;
index 87b9915409e32601f1ba585c41357080f228f3be..8e70d4f0bbfaa26817f06cc04696733648ecafd8 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.tivo.internal;
 
 import static org.openhab.binding.tivo.internal.TiVoBindingConstants.THING_TYPE_TIVO;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -39,7 +38,7 @@ import org.osgi.service.component.annotations.Component;
 @NonNullByDefault
 @Component(configurationPid = "binding.tivo", service = ThingHandlerFactory.class)
 public class TiVoHandlerFactory extends BaseThingHandlerFactory {
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_TIVO);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_TIVO);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 2bee2f756e13bf9fe5f5c40b1bfaf89bad9c8811..9fdf28ce02d1dc47ee8225aba11849d0e522d687 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.tivo.internal.discovery;
 import static org.openhab.binding.tivo.internal.TiVoBindingConstants.*;
 
 import java.net.InetAddress;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -48,7 +47,7 @@ public class TiVoDiscoveryParticipant implements MDNSDiscoveryParticipant {
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(THING_TYPE_TIVO);
+        return Set.of(THING_TYPE_TIVO);
     }
 
     @Override
index 0f29e59a9fb44d895413d7af64600ff2e8a0b42b..5abfb938fc0cdda2221a87b51c7008b423adf161 100644 (file)
@@ -73,7 +73,7 @@ public class TiVoHandler extends BaseThingHandler {
         // Handles the commands from the various TiVo channel objects
         logger.debug("handleCommand '{}', parameter: {}", channelUID, command);
 
-        if (!isInitialized() || !tivoConnection.isPresent()) {
+        if (!isInitialized() || tivoConnection.isEmpty()) {
             logger.debug("handleCommand '{}' device is not initialized yet, command '{}' will be ignored.",
                     getThing().getUID(), channelUID + " " + command);
             return;
@@ -122,7 +122,7 @@ public class TiVoHandler extends BaseThingHandler {
 
     private void sendCommand(String commandKeyword, String commandParameter, TivoStatusData currentStatus)
             throws InterruptedException {
-        if (!tivoConnection.isPresent()) {
+        if (tivoConnection.isEmpty()) {
             return;
         }
 
@@ -299,8 +299,7 @@ public class TiVoHandler extends BaseThingHandler {
             }
 
         } catch (NumberFormatException e) {
-            logger.warn("TiVo'{}' unable to parse channel integer, value sent was: '{}'", getThing().getUID(),
-                    command.toString());
+            logger.warn("TiVo'{}' unable to parse channel integer, value sent was: '{}'", getThing().getUID(), command);
         }
         return tmpStatus;
     }
index 6ec8f5fa0052afdbb653aac1db713ee84bd41eac..ea38df75a1c1078fd9fdc543a331ed5877886e3d 100644 (file)
@@ -78,7 +78,7 @@ public class TivoStatusData {
         UNKNOWN,
         OFFLINE,
         STANDBY,
-        ONLINE;
+        ONLINE
     }
 
     /**
index 6362fc3ff54e638b1637193a1042b666aebe838b..51581a9c8f9894822893342e02ec2cff9473da1f 100644 (file)
@@ -124,7 +124,7 @@ public class TivoStatusProvider {
         }
         for (int i = 1; i <= repeatCount; i++) {
             // Send the command
-            streamWriter.println(tivoCommand.toString() + "\r");
+            streamWriter.println(tivoCommand + "\r");
             if (streamWriter.checkError()) {
                 logger.debug("TiVo '{}' - called cmdTivoSend and encountered an IO error",
                         tivoConfigData.getCfgIdentifier());
index c2cb4554501695b8fa4bb6f21f572648f219a231..1fcef007d56eaa0b62f8ac77d0fb53c3e21b89fd 100644 (file)
@@ -57,8 +57,7 @@ public class TouchWandAlarmSensorHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandUnitDataAlarmSensor) {
-            TouchWandUnitDataAlarmSensor sensor = (TouchWandUnitDataAlarmSensor) unitData;
+        if (unitData instanceof TouchWandUnitDataAlarmSensor sensor) {
             if (isFirstUpdateTouchWandUnitState) {
                 removeUnsupportedChannels(sensor);
                 isFirstUpdateTouchWandUnitState = false;
index 127215178443fe0ca6b8d2332fddc49e23c04963..4094d637b69398575214a0067bda81a404a7d4a7 100644 (file)
@@ -42,21 +42,21 @@ public class TouchWandBSensorHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandBSensorUnitData) {
+        if (unitData instanceof TouchWandBSensorUnitData bSensorUnitData) {
             if (isFirstUpdateTouchWandUnitState) {
-                removeUnsupportedChannels((TouchWandBSensorUnitData) unitData);
+                removeUnsupportedChannels(bSensorUnitData);
                 isFirstUpdateTouchWandUnitState = false;
             }
-            String sensorSubType = ((TouchWandBSensorUnitData) unitData).getIdData().getSubType();
+            String sensorSubType = bSensorUnitData.getIdData().getSubType();
             switch (sensorSubType) {
                 case BSENSOR_SUBTYPE_DOORWINDOW:
-                    updateChannelDoorWindow((TouchWandBSensorUnitData) unitData);
+                    updateChannelDoorWindow(bSensorUnitData);
                     break;
                 case BSENSOR_SUBTYPE_MOTION:
-                    updateChannelMotion((TouchWandBSensorUnitData) unitData);
+                    updateChannelMotion(bSensorUnitData);
                     break;
                 case BSENSOR_SUBTYPE_SMOKE:
-                    updateChannelSmoke((TouchWandBSensorUnitData) unitData);
+                    updateChannelSmoke(bSensorUnitData);
                     break;
                 default:
             }
index ba009faefa89ea80da3ea8c6136d76b2b2502af1..edcef223ecc1d39318b367ef1b9e6e49639f64b3 100644 (file)
@@ -137,7 +137,7 @@ public abstract class TouchWandBaseUnitHandler extends BaseThingHandler implemen
 
     @Override
     public void onItemStatusUpdate(TouchWandUnitData unitData) {
-        if (unitData.getStatus().equals("ALIVE")) {
+        if ("ALIVE".equals(unitData.getStatus())) {
             updateStatus(ThingStatus.ONLINE);
         } else {
             // updateStatus(ThingStatus.OFFLINE); // comment - OFFLINE status is not accurate at the moment
index b84b3c12db206f68e269691401784bdc1ecf64d1..17f068b260232287b805508701bdddd3533ceb09 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.touchwand.internal;
 import static org.openhab.binding.touchwand.internal.TouchWandBindingConstants.THING_TYPE_BRIDGE;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -45,7 +44,7 @@ import org.slf4j.LoggerFactory;
  */
 @NonNullByDefault
 public class TouchWandBridgeHandler extends BaseBridgeHandler implements TouchWandUnitStatusUpdateListener {
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
     private final Logger logger = LoggerFactory.getLogger(TouchWandBridgeHandler.class);
     private boolean addSecondaryUnits;
     private @Nullable TouchWandWebSockets touchWandWebSockets;
@@ -138,6 +137,6 @@ public class TouchWandBridgeHandler extends BaseBridgeHandler implements TouchWa
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TouchWandUnitDiscoveryService.class);
+        return Set.of(TouchWandUnitDiscoveryService.class);
     }
 }
index 3ab7173a4cb63f1f4d0377df960b2dc2a6151a56..377b8d6423b66a6bebe09af61cbb9d7b6fb0aa01 100644 (file)
@@ -39,8 +39,8 @@ public class TouchWandDimmerHandler extends TouchWandBaseUnitHandler {
     void touchWandUnitHandleCommand(Command command) {
         TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
         if (touchWandBridgeHandler != null) {
-            if (command instanceof OnOffType) {
-                touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, (OnOffType) command);
+            if (command instanceof OnOffType onOffCommand) {
+                touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, onOffCommand);
             } else {
                 touchWandBridgeHandler.touchWandClient.cmdDimmerPosition(unitId, command.toString());
             }
@@ -49,8 +49,8 @@ public class TouchWandDimmerHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandShutterSwitchUnitData) {
-            int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
+        if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
+            int status = shutterSwitchUnitData.getCurrStatus();
             PercentType state = PercentType.ZERO;
             int convertStatus = status;
             state = new PercentType(convertStatus);
index adc776a5bd74862301790683cb1eeb4abd9e1d72..cfeaddbe6034c4a35b704b27651c1b580ddcd818 100644 (file)
@@ -203,8 +203,7 @@ public class TouchWandRestClient {
     }
 
     private String buildUrl(String command) {
-        String url = "http://" + touchWandIpAddr + ":" + touchWandPort + COMMAND_MAP.get(command);
-        return url;
+        return "http://" + touchWandIpAddr + ":" + touchWandPort + COMMAND_MAP.get(command);
     }
 
     private synchronized String sendCommand(String command, HttpMethod method, String content) {
index 6bfdb144b626c90682deda05ffcf5ac15bfe1cb1..1bc0ecc8646536b90fe8252895125c9d1cfc6dfc 100644 (file)
@@ -59,8 +59,8 @@ public class TouchWandShutterHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandShutterSwitchUnitData) {
-            int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
+        if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
+            int status = shutterSwitchUnitData.getCurrStatus();
             PercentType state = PercentType.ZERO;
             int convertStatus = 100 - status;
             state = new PercentType(convertStatus);
index 5244e09b2b517e173987bffa6c2170ed515d4cb4..311a10cd88093751f05356a9a77e0861f13bb492 100644 (file)
@@ -37,9 +37,9 @@ public class TouchWandSwitchHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandShutterSwitchUnitData) {
+        if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
             OnOffType state;
-            int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
+            int status = shutterSwitchUnitData.getCurrStatus();
             String sStatus = Integer.toString(status);
 
             if (sStatus.equals(SWITCH_STATUS_OFF)) {
@@ -58,10 +58,10 @@ public class TouchWandSwitchHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void touchWandUnitHandleCommand(Command command) {
-        if (command instanceof OnOffType) {
+        if (command instanceof OnOffType onOffCommand) {
             TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
             if (touchWandBridgeHandler != null) {
-                touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, (OnOffType) command);
+                touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, onOffCommand);
             }
         }
     }
index 45ccd1b34b5a580aa646da42b6b860fa94dc6635..82cc78b7db40ce66394ed40a97d6c0ad51e74cf4 100644 (file)
@@ -40,8 +40,7 @@ public class TouchWandThermostatHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandThermostatUnitData) {
-            TouchWandThermostatUnitData thermostat = (TouchWandThermostatUnitData) unitData;
+        if (unitData instanceof TouchWandThermostatUnitData thermostat) {
             updateThermostatState(thermostat);
             updateTargetTemperature(thermostat);
             updateRoomTemperature(thermostat);
@@ -56,12 +55,12 @@ public class TouchWandThermostatHandler extends TouchWandBaseUnitHandler {
     void touchWandUnitHandleCommand(Command command) {
         TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
         if (touchWandBridgeHandler != null) {
-            if (command instanceof OnOffType) {
-                touchWandBridgeHandler.touchWandClient.cmdThermostatOnOff(unitId, (OnOffType) command);
+            if (command instanceof OnOffType onOffCommand) {
+                touchWandBridgeHandler.touchWandClient.cmdThermostatOnOff(unitId, onOffCommand);
                 return;
             }
-            if (command instanceof QuantityType) {
-                final QuantityType<?> value = ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS);
+            if (command instanceof QuantityType quantityCommand) {
+                final QuantityType<?> value = quantityCommand.toUnit(SIUnits.CELSIUS);
                 String targetTemperature = String.valueOf(value.intValue());
                 touchWandBridgeHandler.touchWandClient.cmdThermostatTargetTemperature(unitId, targetTemperature);
                 return;
index 83c9066be5e5dbd6eb9cca4e4b52f8212a2b7132..54c0e66349d41eefa8c2e5d30c3fff79954734c8 100644 (file)
@@ -48,8 +48,8 @@ public class TouchWandWallControllerHandler extends TouchWandBaseUnitHandler {
 
     @Override
     void updateTouchWandUnitState(TouchWandUnitData unitData) {
-        if (unitData instanceof TouchWandUnitDataWallController) {
-            Csc status = ((TouchWandUnitDataWallController) unitData).getCurrStatus();
+        if (unitData instanceof TouchWandUnitDataWallController unitDataWallController) {
+            Csc status = unitDataWallController.getCurrStatus();
             long ts = status.getTs();
             long timeDiff = ts - timeLastEventMs;
             if ((timeDiff) > ADJACENT_EVENT_FILTER_TIME_MILLISEC) {
index 57e8ff3befd69eb70a86198c857c7e6f6fb09b41..9d2c99ba36c4ef3a201672d259d6ab152faae8d5 100644 (file)
@@ -79,7 +79,7 @@ public class TouchWandWebSockets {
 
     public void connect() {
         try {
-            uri = new URI("ws://" + controllerAddress + ":" + String.valueOf(port) + WS_ENDPOINT_TOUCHWAND);
+            uri = new URI("ws://" + controllerAddress + ":" + port + WS_ENDPOINT_TOUCHWAND);
         } catch (URISyntaxException e) {
             logger.warn("URI not valid {} message {}", uri, e.getMessage());
             return;
@@ -152,12 +152,12 @@ public class TouchWandWebSockets {
             TouchWandUnitData touchWandUnit;
             try {
                 JsonObject unitObj = JsonParser.parseString(msg).getAsJsonObject();
-                boolean eventUnitChanged = unitObj.get("type").getAsString().equals("UNIT_CHANGED");
+                boolean eventUnitChanged = "UNIT_CHANGED".equals(unitObj.get("type").getAsString());
                 if (!eventUnitChanged) {
                     return;
                 }
                 touchWandUnit = TouchWandUnitFromJson.parseResponse(unitObj.get("unit").getAsJsonObject());
-                if (!touchWandUnit.getStatus().equals("ALIVE")) {
+                if (!"ALIVE".equals(touchWandUnit.getStatus())) {
                     logger.debug("UNIT_CHANGED unit status not ALIVE : {}", touchWandUnit.getStatus());
                 }
                 boolean supportedUnitType = Arrays.asList(SUPPORTED_TOUCHWAND_TYPES).contains(touchWandUnit.getType());
index d603724d43e4cb214cfb2af4d5b399bae8c46876..048ba30ef3b6e5aeb628d0348c000d3887e5c2d6 100644 (file)
@@ -91,7 +91,7 @@ public class TouchWandControllerDiscoveryService extends AbstractDiscoveryServic
     }
 
     private void addDeviceDiscoveryResult(String label, String ip) {
-        String id = ip.replaceAll("\\.", "");
+        String id = ip.replace(".", "");
         ThingUID thingUID = new ThingUID(THING_TYPE_BRIDGE, id);
         Map<String, Object> properties = new HashMap<>();
         properties.put("label", label);
@@ -138,7 +138,7 @@ public class TouchWandControllerDiscoveryService extends AbstractDiscoveryServic
                     String sentence = new String(dgram.getData(), 0, dgram.getLength(), StandardCharsets.US_ASCII);
                     JsonObject bridge = JsonParser.parseString(sentence).getAsJsonObject();//
                     String name = bridge.get("name").getAsString();
-                    addDeviceDiscoveryResult(name, address.getHostAddress().toString());
+                    addDeviceDiscoveryResult(name, address.getHostAddress());
                     logger.debug("Received Datagram from {}:{} on Port {} message {}", address.getHostAddress(),
                             dgram.getPort(), mySocket.getLocalPort(), sentence);
                 }
index ea1588d22a89abbb87386e0130a409a80e98be60..e9d826a8f41108b69c5218fa9dc955d1bc56f32a 100644 (file)
@@ -191,8 +191,8 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
 
     @Override
     public void setThingHandler(@NonNullByDefault({}) ThingHandler handler) {
-        if (handler instanceof TouchWandBridgeHandler) {
-            touchWandBridgeHandler = (TouchWandBridgeHandler) handler;
+        if (handler instanceof TouchWandBridgeHandler touchWandBridgeHandler) {
+            this.touchWandBridgeHandler = touchWandBridgeHandler;
         }
     }
 
index 995030b1871151a53f763514c3b49e323586ad51..f9d7c757ef14154b5192849084d6f7ad0cbfc972 100644 (file)
@@ -69,7 +69,7 @@ public class AlarmSensorUnitDataDeserializer implements JsonDeserializer<TouchWa
 
             for (Entry<String, JsonElement> entry : currentStatusObj.entrySet()) {
                 String key = entry.getKey();
-                String splits[] = key.split("_"); // the key is xxxx_n where xxx is sensor type and n is
+                String[] splits = key.split("_"); // the key is xxxx_n where xxx is sensor type and n is
                 String keyName = splits[0];
                 int index = 0;
 
index 392d25700bafbc6eac9b994ce74b6d0da2b67f9f..8baeada1d12d584811f4a5b439d25bae74250aa7 100644 (file)
@@ -70,12 +70,12 @@ public class BulbDevice extends SmartHomeDevice {
         final int transitionPeriod = configuration.transitionPeriod;
         final HasErrorResponse response;
 
-        if (command instanceof OnOffType && CHANNELS_BULB_SWITCH.contains(channelId)) {
-            response = handleOnOffType(channelId, (OnOffType) command, transitionPeriod);
-        } else if (command instanceof HSBType && CHANNEL_COLOR.equals(channelId)) {
-            response = handleHSBType(channelId, (HSBType) command, transitionPeriod);
-        } else if (command instanceof DecimalType) {
-            response = handleDecimalType(channelId, (DecimalType) command, transitionPeriod);
+        if (command instanceof OnOffType onOffCommand && CHANNELS_BULB_SWITCH.contains(channelId)) {
+            response = handleOnOffType(channelId, onOffCommand, transitionPeriod);
+        } else if (command instanceof HSBType hsbCommand && CHANNEL_COLOR.equals(channelId)) {
+            response = handleHSBType(channelId, hsbCommand, transitionPeriod);
+        } else if (command instanceof DecimalType decimalCommand) {
+            response = handleDecimalType(channelId, decimalCommand, transitionPeriod);
         } else {
             return false;
         }
index e91395db5e40eda1c90f1f8ae7c3b4982947e59d..9c17ff20229e8fd39ef316c143e0cee650702fbd 100644 (file)
@@ -56,11 +56,9 @@ public class DimmerDevice extends SwitchDevice {
     private boolean handleBrightnessChannel(ChannelUID channelUid, Command command) throws IOException {
         HasErrorResponse response = null;
 
-        if (command instanceof OnOffType) {
-            response = setOnOffState(channelUid, (OnOffType) command);
-        } else if (command instanceof PercentType) {
-            PercentType percentCommand = (PercentType) command;
-
+        if (command instanceof OnOffType onOffCommand) {
+            response = setOnOffState(channelUid, onOffCommand);
+        } else if (command instanceof PercentType percentCommand) {
             // Don't send value 0 as brightness value as it will give an error from the device.
             if (percentCommand.intValue() > 0) {
                 response = commands.setDimmerBrightnessResponse(
index 69e4fa64cc8491e0fb984edbc133834f5f950a38..d096a1298e54391f84eaa12ddc6ea50f63067e42 100644 (file)
@@ -41,7 +41,7 @@ public class SwitchDevice extends SmartHomeDevice {
 
     @Override
     public boolean handleCommand(ChannelUID channelUid, Command command) throws IOException {
-        return command instanceof OnOffType && handleOnOffType(channelUid, (OnOffType) command);
+        return command instanceof OnOffType onOffCommand && handleOnOffType(channelUid, onOffCommand);
     }
 
     /**
index ad77be3dc56ac6a8e551ee9be8d916ac7e3fd44e..105fd1bdca9bb99ff0296a109aa040c16608552a 100644 (file)
@@ -58,8 +58,8 @@ public class TPLinkSmartHomeActions implements ThingActions, ThingHandlerService
 
     @Override
     public void setThingHandler(final ThingHandler handler) {
-        if (handler instanceof SmartHomeHandler) {
-            this.handler = (SmartHomeHandler) handler;
+        if (handler instanceof SmartHomeHandler smartHomeHandler) {
+            this.handler = smartHomeHandler;
         }
     }
 
index c905ae6ae1a4439ca0395ec3ca0f1ff8b444cda3..1f61c94bec27d02886d8dc6f7bade0898ca50732 100644 (file)
@@ -122,7 +122,7 @@ public class FritzboxActions implements ThingActions {
 
         Optional<SCPDServiceType> scpdService = scpdUtil.getDevice("")
                 .flatMap(deviceType -> deviceType.getServiceList().stream().filter(
-                        service -> service.getServiceId().equals("urn:DeviceConfig-com:serviceId:DeviceConfig1"))
+                        service -> "urn:DeviceConfig-com:serviceId:DeviceConfig1".equals(service.getServiceId()))
                         .findFirst());
         if (scpdService.isEmpty()) {
             logger.warn("Could not get service.");
index f209416d04481d383ffcc7b9c301acfa1272d23a..93ae8383e1a6d676035416c72ca3d0859ee9b51f 100644 (file)
@@ -53,8 +53,8 @@ public class Tr064DiscoveryService extends AbstractDiscoveryService implements T
 
     @Override
     public void setThingHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof Tr064RootHandler) {
-            this.bridgeHandler = (Tr064RootHandler) thingHandler;
+        if (thingHandler instanceof Tr064RootHandler tr064RootHandler) {
+            this.bridgeHandler = tr064RootHandler;
         }
     }
 
index a23ae326485e16b7070685cce1b092943f2e789c..dcd41460e10f007925f785237c97da528c3a783d 100644 (file)
@@ -111,8 +111,8 @@ public class Tr064HandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof Tr064RootHandler) {
-            phonebookProfileFactory.unregisterPhonebookProvider((Tr064RootHandler) thingHandler);
+        if (thingHandler instanceof Tr064RootHandler tr064RootHandler) {
+            phonebookProfileFactory.unregisterPhonebookProvider(tr064RootHandler);
         }
     }
 }
index 17c42a2f2206c771632abcf342f0c18642523a4e..4bed5ba039419e2a32ae8cc2cf2f890da3231248 100644 (file)
@@ -242,7 +242,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
                 SCPDDeviceType device = scpdUtil.getDevice("")
                         .orElseThrow(() -> new SCPDException("Root device not found"));
                 SCPDServiceType deviceService = device.getServiceList().stream()
-                        .filter(service -> service.getServiceId().equals("urn:DeviceInfo-com:serviceId:DeviceInfo1"))
+                        .filter(service -> "urn:DeviceInfo-com:serviceId:DeviceInfo1".equals(service.getServiceId()))
                         .findFirst().orElseThrow(() -> new SCPDException(
                                 "service 'urn:DeviceInfo-com:serviceId:DeviceInfo1' not found"));
 
@@ -282,7 +282,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
                 SCPDActionType getInfoAction = scpdUtil.getService(deviceService.getServiceId())
                         .orElseThrow(() -> new SCPDException(
                                 "Could not get service definition for 'urn:DeviceInfo-com:serviceId:DeviceInfo1'"))
-                        .getActionList().stream().filter(action -> action.getName().equals("GetInfo")).findFirst()
+                        .getActionList().stream().filter(action -> "GetInfo".equals(action.getName())).findFirst()
                         .orElseThrow(() -> new SCPDException("Action 'GetInfo' not found"));
                 SOAPMessage soapResponse1 = soapConnector
                         .doSOAPRequest(new SOAPRequest(deviceService, getInfoAction.getName()));
index d0292a2a9e5a599fc96251e3a24f68d6570e5460..aab94ff02bed1c0aa05ab8689a2d287904ce5adc 100644 (file)
@@ -98,17 +98,17 @@ public class PhonebookProfile implements StateProfile {
                 phonebookName = UIDUtils.decode(phonebookParams[1]);
             }
             if (matchCountParam != null) {
-                if (matchCountParam instanceof BigDecimal) {
-                    matchCount = ((BigDecimal) matchCountParam).intValue();
-                } else if (matchCountParam instanceof String) {
-                    matchCount = Integer.parseInt((String) matchCountParam);
+                if (matchCountParam instanceof BigDecimal bigDecimal) {
+                    matchCount = bigDecimal.intValue();
+                } else if (matchCountParam instanceof String string) {
+                    matchCount = Integer.parseInt(string);
                 }
             }
             if (phoneNumberIndexParam != null) {
-                if (phoneNumberIndexParam instanceof BigDecimal) {
-                    phoneNumberIndex = ((BigDecimal) phoneNumberIndexParam).intValue();
-                } else if (phoneNumberIndexParam instanceof String) {
-                    phoneNumberIndex = Integer.parseInt((String) phoneNumberIndexParam);
+                if (phoneNumberIndexParam instanceof BigDecimal bigDecimal) {
+                    phoneNumberIndex = bigDecimal.intValue();
+                } else if (phoneNumberIndexParam instanceof String string) {
+                    phoneNumberIndex = Integer.parseInt(string);
                 }
             }
         } catch (IllegalArgumentException e) {
index 7c6c72b2818f3ecc8f79946109ec608d50831e26..3e1d3c4a6b49c8943dbf7fa77fdbcd6c3978cbe4 100644 (file)
@@ -153,8 +153,8 @@ public class SOAPConnector {
             return soapMessage;
         } catch (IllegalArgumentException e) {
             Throwable cause = e.getCause();
-            if (cause instanceof Tr064CommunicationException) {
-                throw (Tr064CommunicationException) cause;
+            if (cause instanceof Tr064CommunicationException tr064CommunicationException) {
+                throw tr064CommunicationException;
             } else {
                 throw e;
             }
index 5f90f4d7f72037307f55821d59be43847fe14a40..48b36bb78d488ed8b0f29ddccc9ee36848f3e2d4 100644 (file)
@@ -78,9 +78,8 @@ public class SOAPValueConverter {
             // we don't have data to send
             return Optional.of("");
         }
-        if (command instanceof QuantityType) {
-            QuantityType<?> value = (unit.isEmpty()) ? ((QuantityType<?>) command)
-                    : ((QuantityType<?>) command).toUnit(unit);
+        if (command instanceof QuantityType quantityCommand) {
+            QuantityType<?> value = (unit.isEmpty()) ? quantityCommand : quantityCommand.toUnit(unit);
             if (value == null) {
                 logger.warn("Could not convert {} to unit {}", command, unit);
                 return Optional.empty();
@@ -95,8 +94,8 @@ public class SOAPValueConverter {
                 default -> {
                 }
             }
-        } else if (command instanceof DecimalType) {
-            BigDecimal value = ((DecimalType) command).toBigDecimal();
+        } else if (command instanceof DecimalType decimalCommand) {
+            BigDecimal value = decimalCommand.toBigDecimal();
             switch (dataType) {
                 case "ui1", "ui2" -> {
                     return Optional.of(String.valueOf(value.shortValue()));
@@ -139,7 +138,7 @@ public class SOAPValueConverter {
             // map rawValue to State
             switch (dataType) {
                 case "boolean" -> {
-                    return rawValue.equals("0") ? OnOffType.OFF : OnOffType.ON;
+                    return "0".equals(rawValue) ? OnOffType.OFF : OnOffType.ON;
                 }
                 case "string" -> {
                     return new StringType(rawValue);
@@ -170,8 +169,8 @@ public class SOAPValueConverter {
                 Method method = SOAPValueConverter.class.getDeclaredMethod(postProcessor, State.class,
                         Tr064ChannelConfig.class);
                 Object o = method.invoke(this, state, channelConfig);
-                if (o instanceof State) {
-                    return (State) o;
+                if (o instanceof State stateInstance) {
+                    return stateInstance;
                 }
             } catch (NoSuchMethodException | IllegalAccessException e) {
                 logger.warn("Postprocessor {} not found, this most likely is a programming error", postProcessor, e);
index dc4c7c37b33d849e70b03eaa6411c064cc9a9052..8990432da1bf455de222781d463930ec29b5f4e3 100644 (file)
@@ -281,10 +281,10 @@ public class Util {
             // get parameters by reflection from thing config
             Field paramField = thingConfig.getClass().getField(parameter.getThingParameter());
             Object rawFieldValue = paramField.get(thingConfig);
-            if ((rawFieldValue instanceof List<?>)) {
-                ((List<?>) rawFieldValue).forEach(obj -> {
-                    if (obj instanceof String) {
-                        parameters.add((String) obj);
+            if ((rawFieldValue instanceof List<?> list)) {
+                list.forEach(obj -> {
+                    if (obj instanceof String string) {
+                        parameters.add(string);
                     }
                 });
             }
index da11d714fa2594e34380c6eb525916d89fb9af75..ac3c9cea4595b17e0cd568edc0f034dc4cfa480e 100644 (file)
@@ -52,9 +52,9 @@ public class TradfriBindingConstants {
             .unmodifiableSet(Stream.of(THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_TEMP_LIGHT, THING_TYPE_COLOR_LIGHT)
                     .collect(Collectors.toSet()));
 
-    public static final Set<ThingTypeUID> SUPPORTED_PLUG_TYPES_UIDS = Collections.singleton(THING_TYPE_ONOFF_PLUG);
+    public static final Set<ThingTypeUID> SUPPORTED_PLUG_TYPES_UIDS = Set.of(THING_TYPE_ONOFF_PLUG);
 
-    public static final Set<ThingTypeUID> SUPPORTED_BLINDS_TYPES_UIDS = Collections.singleton(THING_TYPE_BLINDS);
+    public static final Set<ThingTypeUID> SUPPORTED_BLINDS_TYPES_UIDS = Set.of(THING_TYPE_BLINDS);
 
     public static final Set<ThingTypeUID> SUPPORTED_AIR_PURIFIER_TYPES_UIDS = Set.of(THING_TYPE_AIR_PURIFIER);
 
@@ -70,7 +70,7 @@ public class TradfriBindingConstants {
             .unmodifiableSet(Stream.of(THING_TYPE_DIMMER, THING_TYPE_REMOTE_CONTROL,
                     THING_TYPE_OPEN_CLOSE_REMOTE_CONTROL, THING_TYPE_MOTION_SENSOR).collect(Collectors.toSet()));
 
-    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Collections.singleton(GATEWAY_TYPE_UID);
+    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Set.of(GATEWAY_TYPE_UID);
 
     public static final Set<ThingTypeUID> SUPPORTED_DEVICE_TYPES_UIDS = Collections.unmodifiableSet(Stream
             .of(SUPPORTED_LIGHT_TYPES_UIDS.stream(), SUPPORTED_CONTROLLER_TYPES_UIDS.stream(),
index 5fd3fbcb6717c912a0a90414757b981a5fbe68a4..6fe7f8dc051d8247dec5a9502670eb6add99dcdf 100644 (file)
@@ -86,8 +86,8 @@ public class TradfriDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof TradfriGatewayHandler) {
-            this.handler = (TradfriGatewayHandler) handler;
+        if (handler instanceof TradfriGatewayHandler gatewayHandler) {
+            this.handler = gatewayHandler;
         }
     }
 
index 149d09bf3611213b4febdd94a0ea2aa778c4ae0e..23057ab5115bf93524495518bc333222a32285fe 100644 (file)
@@ -75,8 +75,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
     }
 
     private void handleFanModeCommand(Command command) {
-        if (command instanceof Number) {
-            set(new TradfriAirPurifierData().setFanMode((Number) command).getJsonString());
+        if (command instanceof Number numberCommand) {
+            set(new TradfriAirPurifierData().setFanMode(numberCommand).getJsonString());
         } else {
             logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
                     CHANNEL_FAN_MODE);
@@ -84,8 +84,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
     }
 
     private void handleDisableLed(Command command) {
-        if (command instanceof OnOffType) {
-            set(new TradfriAirPurifierData().setDisableLed((OnOffType) command).getJsonString());
+        if (command instanceof OnOffType onOffCommand) {
+            set(new TradfriAirPurifierData().setDisableLed(onOffCommand).getJsonString());
         } else {
             logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
                     CHANNEL_DISABLE_LED);
@@ -93,8 +93,8 @@ public class TradfriAirPurifierHandler extends TradfriThingHandler {
     }
 
     private void handleLockButton(Command command) {
-        if (command instanceof OnOffType) {
-            set(new TradfriAirPurifierData().setLockPhysicalButton((OnOffType) command).getJsonString());
+        if (command instanceof OnOffType onOffCommand) {
+            set(new TradfriAirPurifierData().setLockPhysicalButton(onOffCommand).getJsonString());
         } else {
             logger.debug("Cannot handle command '{}' of type {} for channel '{}'", command, command.getClass(),
                     CHANNEL_DISABLE_LED);
index 0acc6d59eec5a1806270ebd77af50b02bc215d24..d7a696727039949d6275263260558b3a09b86ee4 100644 (file)
@@ -108,8 +108,8 @@ public class TradfriBlindHandler extends TradfriThingHandler {
     }
 
     private void handlePositionCommand(Command command) {
-        if (command instanceof PercentType) {
-            setPosition((PercentType) command);
+        if (command instanceof PercentType percentCommand) {
+            setPosition(percentCommand);
         } else if (command instanceof StopMoveType) {
             if (StopMoveType.STOP.equals(command)) {
                 triggerStop();
index 6ea12fad69a906026b4b95140382dbd305a0c848..18aeb6a7947f06ffdb4c00de4841365cefba983d 100644 (file)
@@ -18,7 +18,6 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Objects;
 import java.util.Set;
 import java.util.UUID;
@@ -137,7 +136,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(TradfriDiscoveryService.class);
+        return Set.of(TradfriDiscoveryService.class);
     }
 
     private void establishConnection() {
index b935450192b511feee3052480726a46d694bd3bf..03fc20a9a0aeeeb7a46d6f326b1cc2aaf3a5ce80 100644 (file)
@@ -154,10 +154,10 @@ public class TradfriLightHandler extends TradfriThingHandler {
     }
 
     private void handleBrightnessCommand(Command command) {
-        if (command instanceof PercentType) {
-            setBrightness((PercentType) command);
-        } else if (command instanceof OnOffType) {
-            setState(((OnOffType) command));
+        if (command instanceof PercentType percentCommand) {
+            setBrightness(percentCommand);
+        } else if (command instanceof OnOffType onOffCommand) {
+            setState(onOffCommand);
         } else if (command instanceof IncreaseDecreaseType) {
             final TradfriLightData state = this.state;
             if (state != null && state.getBrightness() != null) {
@@ -177,8 +177,8 @@ public class TradfriLightHandler extends TradfriThingHandler {
     }
 
     private void handleColorTemperatureCommand(Command command) {
-        if (command instanceof PercentType) {
-            setColorTemperature((PercentType) command);
+        if (command instanceof PercentType percentCommand) {
+            setColorTemperature(percentCommand);
         } else if (command instanceof IncreaseDecreaseType) {
             final TradfriLightData state = this.state;
             if (state != null && state.getColorTemperature() != null) {
@@ -198,13 +198,13 @@ public class TradfriLightHandler extends TradfriThingHandler {
     }
 
     private void handleColorCommand(Command command) {
-        if (command instanceof HSBType) {
-            setColor((HSBType) command);
-            setBrightness(((HSBType) command).getBrightness());
-        } else if (command instanceof OnOffType) {
-            setState(((OnOffType) command));
-        } else if (command instanceof PercentType) {
-            setBrightness((PercentType) command);
+        if (command instanceof HSBType hsbCommand) {
+            setColor(hsbCommand);
+            setBrightness(hsbCommand.getBrightness());
+        } else if (command instanceof OnOffType onOffCommand) {
+            setState(onOffCommand);
+        } else if (command instanceof PercentType percentCommand) {
+            setBrightness(percentCommand);
         } else if (command instanceof IncreaseDecreaseType) {
             final TradfriLightData state = this.state;
             // increase or decrease only the brightness, but keep color
index db0b3598e42c898b062338c37e53bac6345639a2..5cf4ec779f00839c317ba07b8bd90f3544a0d9fe 100644 (file)
@@ -75,8 +75,8 @@ public class TradfriPlugHandler extends TradfriThingHandler {
 
             switch (channelUID.getId()) {
                 case CHANNEL_POWER:
-                    if (command instanceof OnOffType) {
-                        setState(((OnOffType) command));
+                    if (command instanceof OnOffType onOffCommand) {
+                        setState(onOffCommand);
                     } else {
                         logger.debug("Cannot handle command '{}' for channel '{}'", command, CHANNEL_POWER);
                     }
index 8d67f4a96237d6a4c8ee7fbfab2c7093b2417c7f..d5d83d2cc3e74ec2280b8638e3e56e51a896f35e 100644 (file)
@@ -135,8 +135,8 @@ public class TradfriAirPurifierData extends TradfriDeviceData {
     public @Nullable State getAirQualityRating() {
         State pm25State = getAirQualityPM25();
         if (pm25State != null) {
-            if (pm25State instanceof Number) {
-                int pm25Value = ((Number) pm25State).intValue();
+            if (pm25State instanceof Number number) {
+                int pm25Value = number.intValue();
                 int qualityRating = 1;
 
                 if (pm25Value >= AIR_PURIFIER_AIR_QUALITY_BAD) {
index f2db46d783f32d134cec30829f8b5111f86fe608..8b962d7902e9ff7771c4cce9d1cec022b48fdde7 100644 (file)
@@ -21,7 +21,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -82,7 +82,7 @@ public class TwitterHandler extends BaseThingHandler {
     // creates list of available Actions
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(TwitterActions.class);
+        return List.of(TwitterActions.class);
     }
 
     @Override
@@ -118,7 +118,7 @@ public class TwitterHandler extends BaseThingHandler {
             Twitter localClient = client;
             if (localClient != null) {
                 ResponseList<Status> statuses = localClient.getUserTimeline();
-                if (statuses.size() > 0) {
+                if (!statuses.isEmpty()) {
                     updateState(CHANNEL_LASTTWEET, StringType.valueOf(statuses.get(0).getText()));
                 } else {
                     logger.debug("No Statuses Found");
index 81a9ba5f19ea82ecfdd1b1faaaabe2771cfa15c3..a1390f27f4a16e531968880520dd6bdc73e9cd62 100644 (file)
@@ -112,8 +112,8 @@ public class TwitterActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof TwitterHandler) {
-            this.handler = (TwitterHandler) handler;
+        if (handler instanceof TwitterHandler twitterHandler) {
+            this.handler = twitterHandler;
         }
     }
 
index 59b7cfb376f4e214a2703176735d98d068c8cc92..b0cd37163f2ba9e568a8ccf53a9ccc4732a154bc 100644 (file)
@@ -259,8 +259,8 @@ public class UniFiSiteActions implements ThingActions {
 
     @Override
     public void setThingHandler(ThingHandler handler) {
-        if (handler instanceof UniFiSiteThingHandler) {
-            this.handler = (UniFiSiteThingHandler) handler;
+        if (handler instanceof UniFiSiteThingHandler siteThingHandler) {
+            this.handler = siteThingHandler;
         }
     }
 
index 0e450dd0940d6196a42f87bb1ec3d3e9622f2730..fc0439e3b5978af7caae41d033763ca97300ecf0 100644 (file)
@@ -206,13 +206,13 @@ class UniFiControllerRequest<T> {
             } else if (cause instanceof SSLException) {
                 // cannot establish ssl connection
                 throw new UniFiSSLException(cause);
-            } else if (cause instanceof HttpResponseException
-                    && ((HttpResponseException) cause).getResponse() instanceof ContentResponse) {
+            } else if (cause instanceof HttpResponseException httpResponseException
+                    && httpResponseException.getResponse() instanceof ContentResponse) {
                 // the UniFi controller violates the HTTP protocol
                 // - it returns 401 UNAUTHORIZED without the WWW-Authenticate response header
                 // - this causes an ExecutionException to be thrown
                 // - we unwrap the response from the exception for proper handling of the 401 status code
-                response = ((HttpResponseException) cause).getResponse();
+                response = httpResponseException.getResponse();
             } else {
                 // catch all
                 throw new UniFiException(cause);
index 55d581fd3134bf8997c9e60b30d18a442b0fa23f..6023e255271042d5ba2a4ea512206dd4718aee33 100644 (file)
@@ -107,8 +107,10 @@ public class UniFiVoucher implements HasId {
     @Override
     public String toString() {
         return String.format(
-                "UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', "
-                        + "qosRateMaxUp: '%s', qosRateMaxDown: '%s', qosOverwrite: '%s', note: '%s', status: '%s', site: %s}",
+                """
+                        UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', \
+                        qosRateMaxUp: '%s', qosRateMaxDown: '%s', qosOverwrite: '%s', note: '%s', status: '%s', site: %s}\
+                        """,
                 id, code, createTime, duration, quota, used, qosUsageQuota, qosRateMaxUp, qosRateMaxDown, qosOverwrite,
                 note, status, getSite());
     }
index 7b725657c8971483c9e83a878bd84a543ccb4573..b5ef263970eeedfc702316624fa2210718ed6c96 100644 (file)
@@ -245,13 +245,13 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
 
             default:
                 // mgb: additional wired client channels
-                if (client.isWired() && (client instanceof UniFiWiredClient)) {
-                    state = getWiredChannelState((UniFiWiredClient) client, channelId, state);
+                if (client.isWired() && (client instanceof UniFiWiredClient wiredClient)) {
+                    state = getWiredChannelState(wiredClient, channelId, state);
                 }
 
                 // mgb: additional wireless client channels
-                else if (client.isWireless() && (client instanceof UniFiWirelessClient)) {
-                    state = getWirelessChannelState((UniFiWirelessClient) client, channelId, state);
+                else if (client.isWireless() && (client instanceof UniFiWirelessClient wirelessClient)) {
+                    state = getWirelessChannelState(wirelessClient, channelId, state);
                 }
                 break;
         }
index da8dce148e1490e1d120894f4b38c0d63e3733c2..9964aa48ed39adec5ba4e863c28873ff59a72104 100644 (file)
@@ -199,8 +199,8 @@ public class UniFiControllerThingHandler extends BaseBridgeHandler {
             getThing().getThings().forEach((thing) -> {
                 final ThingHandler handler = thing.getHandler();
 
-                if (handler instanceof UniFiBaseThingHandler) {
-                    ((UniFiBaseThingHandler<?, ?>) handler).refresh();
+                if (handler instanceof UniFiBaseThingHandler baseThingHandler) {
+                    baseThingHandler.refresh();
                 }
             });
         }
index 7ec1c0d1fa2b10545e6b183865a3c415dc91b867..5011c34d1730375eabf866af8b026e462ae3fe94 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.unifi.internal.handler;
 import static org.openhab.binding.unifi.internal.UniFiBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 import java.util.function.Predicate;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -134,6 +134,6 @@ public class UniFiSiteThingHandler extends UniFiBaseThingHandler<UniFiSite, UniF
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(UniFiSiteActions.class);
+        return Set.of(UniFiSiteActions.class);
     }
 }
index 46aeace7017a9662b0ddc96444e01b8ce89c2955..560530c24c3b489cfd8fc216ea539b4e7fe4aa8d 100644 (file)
@@ -76,8 +76,8 @@ public class UniFiThingDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(final ThingHandler handler) {
-        if (handler instanceof UniFiControllerThingHandler) {
-            bridgeHandler = (UniFiControllerThingHandler) handler;
+        if (handler instanceof UniFiControllerThingHandler controllerThingHandler) {
+            bridgeHandler = controllerThingHandler;
         }
     }
 
index 72f2fc4aea1a25af6f1904b2bf1399a5cf357829..da3d31f046786cb35d0fc4fadb7b1c99b57fde67 100644 (file)
@@ -135,8 +135,8 @@ public class UniFiWlanThingHandler extends UniFiBaseThingHandler<UniFiWlan, UniF
             return UnDefType.UNDEF;
         } else {
             return new DecimalType(site.getCache().countClients(site,
-                    c -> c instanceof UniFiWirelessClient
-                            && (wlan.getName() != null && wlan.getName().equals(((UniFiWirelessClient) c).getEssid()))
+                    c -> c instanceof UniFiWirelessClient wirelessClient
+                            && (wlan.getName() != null && wlan.getName().equals(wirelessClient.getEssid()))
                             && filter.test(c)));
         }
     }
index 53b51e1dd0f22db8e0f4969febfbee07518ecd20..d02602754c95134573786a3258503794afb7cadc 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.unifiedremote.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -31,8 +30,7 @@ public class UnifiedRemoteBindingConstants {
 
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_UNIFIED_REMOTE_SERVER = new ThingTypeUID(BINDING_ID, "server");
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections
-            .singleton(THING_TYPE_UNIFIED_REMOTE_SERVER);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_UNIFIED_REMOTE_SERVER);
 
     // List of all Channel ids
     public static final String MOUSE_CHANNEL = "mouse-move";
index 5dea21026ba3832b0fbb87301c67ed8caa1c4a79..f261b15eab17c45d34aa8ddbd734b4330ebcff98 100644 (file)
@@ -87,16 +87,14 @@ public class UPBController {
     }
 
     public void deviceAdded(final ThingHandler childHandler, final Thing childThing) {
-        if (childHandler instanceof UPBThingHandler) {
-            final UPBThingHandler hnd = (UPBThingHandler) childHandler;
-            things.put(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
+        if (childHandler instanceof UPBThingHandler upbThingHandler) {
+            things.put(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
         }
     }
 
     public void deviceRemoved(final ThingHandler childHandler, final Thing childThing) {
-        if (childHandler instanceof UPBThingHandler) {
-            final UPBThingHandler hnd = (UPBThingHandler) childHandler;
-            things.remove(mkAddr(hnd.getNetworkId(), hnd.getUnitId()), hnd);
+        if (childHandler instanceof UPBThingHandler upbThingHandler) {
+            things.remove(mkAddr(upbThingHandler.getNetworkId(), upbThingHandler.getUnitId()), upbThingHandler);
         }
     }
 
index 67b21e2de0d5bc5cdbf144caadcca356285b67ba..ce97b2768cada0103b19c6fd63c984870961f7ac 100644 (file)
@@ -144,8 +144,8 @@ public class UPBThingHandler extends BaseThingHandler {
             message = MessageBuilder.forCommand(ACTIVATE);
         } else if (cmd == OnOffType.OFF) {
             message = MessageBuilder.forCommand(DEACTIVATE);
-        } else if (cmd instanceof PercentType) {
-            message = MessageBuilder.forCommand(GOTO).args(((PercentType) cmd).byteValue());
+        } else if (cmd instanceof PercentType percentCommand) {
+            message = MessageBuilder.forCommand(GOTO).args(percentCommand.byteValue());
         } else if (cmd == RefreshType.REFRESH) {
             refreshDeviceState();
             return;
index 882f43bdd220dfcda870ec2c99841320c2203ab2..38c7820aa1c241c8242ba100994afa1685f320c5 100644 (file)
@@ -52,8 +52,7 @@ public class UpnpDynamicCommandDescriptionProvider implements DynamicCommandDesc
     @Override
     public @Nullable CommandDescription getCommandDescription(Channel channel,
             @Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) {
-        CommandDescription description = descriptions.get(channel.getUID());
-        return description;
+        return descriptions.get(channel.getUID());
     }
 
     @Deactivate
index 6af9891fdff8a660a843917b3b6628f946e15d34..e916a49215ee89f5019f99f14f4186734581db9c 100644 (file)
@@ -52,8 +52,7 @@ public class UpnpDynamicStateDescriptionProvider implements DynamicStateDescript
     @Override
     public @Nullable StateDescription getStateDescription(Channel channel,
             @Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
-        StateDescription description = descriptions.get(channel.getUID());
-        return description;
+        return descriptions.get(channel.getUID());
     }
 
     @Deactivate
index b22baa73d66175fdb1e1c2c5c220cd190dfccf9a..9c694718c4c8a65e8475a91422956906fc36f3ea 100644 (file)
@@ -333,7 +333,7 @@ public abstract class UpnpHandler extends BaseThingHandler implements UpnpIOPart
      * Invoke ConnectionComplete on UPnP Connection Manager.
      */
     protected void connectionComplete() {
-        Map<String, String> inputs = Collections.singletonMap(CONNECTION_ID, Integer.toString(connectionId));
+        Map<String, String> inputs = Map.of(CONNECTION_ID, Integer.toString(connectionId));
 
         invokeAction(CONNECTION_MANAGER, "ConnectionComplete", inputs);
     }
@@ -367,7 +367,7 @@ public abstract class UpnpHandler extends BaseThingHandler implements UpnpIOPart
         isRcsIdSet = new CompletableFuture<Boolean>();
 
         // ConnectionID will default to 0 if not set through prepareForConnection method
-        Map<String, String> inputs = Collections.singletonMap(CONNECTION_ID, Integer.toString(connectionId));
+        Map<String, String> inputs = Map.of(CONNECTION_ID, Integer.toString(connectionId));
 
         invokeAction(CONNECTION_MANAGER, "GetCurrentConnectionInfo", inputs);
     }
index 2ece784b1fe6b5995313d7a06468722fdda2fc1d..1acf87403921e8ee6b37db2e8cc073da6dbc03dc 100644 (file)
@@ -19,7 +19,6 @@ import java.nio.charset.StandardCharsets;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -317,7 +316,7 @@ public class UpnpRendererHandler extends UpnpHandler {
                                                            // received
         }
 
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "Stop", inputs);
     }
@@ -353,7 +352,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Invoke Pause on UPnP AV Transport.
      */
     protected void pause() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "Pause", inputs);
     }
@@ -362,7 +361,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Invoke Next on UPnP AV Transport.
      */
     protected void next() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "Next", inputs);
     }
@@ -371,7 +370,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Invoke Previous on UPnP AV Transport.
      */
     protected void previous() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "Previous", inputs);
     }
@@ -456,7 +455,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Result is received in {@link #onValueReceived}.
      */
     protected void getTransportState() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "GetTransportInfo", inputs);
     }
@@ -466,7 +465,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Result is received in {@link #onValueReceived}.
      */
     protected void getPositionInfo() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "GetPositionInfo", inputs);
     }
@@ -476,7 +475,7 @@ public class UpnpRendererHandler extends UpnpHandler {
      * Result is received in {@link #onValueReceived}.
      */
     protected void getMediaInfo() {
-        Map<String, String> inputs = Collections.singletonMap(INSTANCE_ID, Integer.toString(avTransportId));
+        Map<String, String> inputs = Map.of(INSTANCE_ID, Integer.toString(avTransportId));
 
         invokeAction(AV_TRANSPORT, "smarthome:audio stream http://icecast.vrtcdn.be/stubru_tijdloze-high.mp3", inputs);
     }
@@ -696,24 +695,24 @@ public class UpnpRendererHandler extends UpnpHandler {
     private void handleCommandVolume(Command command, String id) {
         if (command instanceof RefreshType) {
             getVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""));
-        } else if (command instanceof PercentType) {
-            setVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""), (PercentType) command);
+        } else if (command instanceof PercentType percentCommand) {
+            setVolume("volume".equals(id) ? UPNP_MASTER : id.replace("volume", ""), percentCommand);
         }
     }
 
     private void handleCommandMute(Command command, String id) {
         if (command instanceof RefreshType) {
             getMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""));
-        } else if (command instanceof OnOffType) {
-            setMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""), (OnOffType) command);
+        } else if (command instanceof OnOffType onOffCommand) {
+            setMute("mute".equals(id) ? UPNP_MASTER : id.replace("mute", ""), onOffCommand);
         }
     }
 
     private void handleCommandLoudness(Command command, String id) {
         if (command instanceof RefreshType) {
             getLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""));
-        } else if (command instanceof OnOffType) {
-            setLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""), (OnOffType) command);
+        } else if (command instanceof OnOffType onOffCommand) {
+            setLoudness("loudness".equals(id) ? UPNP_MASTER : id.replace("loudness", ""), onOffCommand);
         }
     }
 
@@ -884,8 +883,8 @@ public class UpnpRendererHandler extends UpnpHandler {
     private void handleCommandTrackPosition(ChannelUID channelUID, Command command) {
         if (command instanceof RefreshType) {
             updateState(channelUID, new QuantityType<>(trackPosition, Units.SECOND));
-        } else if (command instanceof QuantityType<?>) {
-            QuantityType<?> position = ((QuantityType<?>) command).toUnit(Units.SECOND);
+        } else if (command instanceof QuantityType<?> quantityCommand) {
+            QuantityType<?> position = quantityCommand.toUnit(Units.SECOND);
             if (position != null) {
                 int pos = Integer.min(trackDuration, position.intValue());
                 seek(String.format("%02d:%02d:%02d", pos / 3600, (pos % 3600) / 60, pos % 60));
@@ -897,8 +896,8 @@ public class UpnpRendererHandler extends UpnpHandler {
         if (command instanceof RefreshType) {
             int relPosition = (trackDuration != 0) ? (trackPosition * 100) / trackDuration : 0;
             updateState(channelUID, new PercentType(relPosition));
-        } else if (command instanceof PercentType) {
-            int pos = ((PercentType) command).intValue() * trackDuration / 100;
+        } else if (command instanceof PercentType percentCommand) {
+            int pos = percentCommand.intValue() * trackDuration / 100;
             seek(String.format("%02d:%02d:%02d", pos / 3600, (pos % 3600) / 60, pos % 60));
         }
     }
index 8355367f0eb260bbca95acf01d8fba6773e38cd1..5846895f73441d055269549e7ba1188b5b9bc587 100644 (file)
@@ -321,8 +321,8 @@ public class UpnpServerHandler extends UpnpHandler {
     private void handleCommandUpnpRenderer(ChannelUID channelUID, Command command) {
         UpnpRendererHandler renderer = null;
         UpnpRendererHandler previousRenderer = currentRendererHandler;
-        if (command instanceof StringType) {
-            renderer = (upnpRenderers.get(((StringType) command).toString()));
+        if (command instanceof StringType stringCommand) {
+            renderer = (upnpRenderers.get(stringCommand.toString()));
             currentRendererHandler = renderer;
             if (config.filter) {
                 // only refresh title list if filtering by renderer capabilities
index 080d4b66239af226c51e28dcdb18431a418d7f43..59839cce842af4be08af7e2534f05a882e353d55 100644 (file)
@@ -32,11 +32,11 @@ public class StringUtils {
      * ' - &apos;
      */
     public static String escapeXml(String xml) {
-        xml = xml.replaceAll("&", "&amp;");
-        xml = xml.replaceAll("<", "&lt;");
-        xml = xml.replaceAll(">", "&gt;");
-        xml = xml.replaceAll("\"", "&quot;");
-        xml = xml.replaceAll("'", "&apos;");
+        xml = xml.replace("&", "&amp;");
+        xml = xml.replace("<", "&lt;");
+        xml = xml.replace(">", "&gt;");
+        xml = xml.replace("\"", "&quot;");
+        xml = xml.replace("'", "&apos;");
         return xml;
     }
 
@@ -50,11 +50,11 @@ public class StringUtils {
      * ' - &apos;
      */
     public static String unEscapeXml(String xml) {
-        xml = xml.replaceAll("&amp;", "&");
-        xml = xml.replaceAll("&lt;", "<");
-        xml = xml.replaceAll("&gt;", ">");
-        xml = xml.replaceAll("&quot;", "\"");
-        xml = xml.replaceAll("&apos;", "'");
+        xml = xml.replace("&amp;", "&");
+        xml = xml.replace("&lt;", "<");
+        xml = xml.replace("&gt;", ">");
+        xml = xml.replace("&quot;", "\"");
+        xml = xml.replace("&apos;", "'");
         return xml;
     }
 }
index c4207b75f778300e8f0f269811fa4c9671478014..de15d104b26544c6ccb987166bb52b5715250de5 100644 (file)
@@ -113,9 +113,8 @@ public final class UpnpControlUtil {
             return Collections.emptyList();
         }
 
-        List<String> result = (Arrays.asList(files)).stream().map(p -> p.getName().replace(extension, ""))
+        return (Arrays.asList(files)).stream().map(p -> p.getName().replace(extension, ""))
                 .collect(Collectors.toList());
-        return result;
     }
 
     private static void delete(String name, @Nullable String path, String extension) {
index c227f1fc8dc20978d4898eec8ef07fa050c658d7..2afebf708f91a47c31127cd4375aa2ce28cc11b9 100644 (file)
@@ -145,9 +145,8 @@ public class UpnpHandlerTest {
             ((Runnable) invocation.getArguments()[0]).run();
             return null;
         }).when(executor).scheduleWithFixedDelay(any(Runnable.class), eq(0L), anyLong(), any(TimeUnit.class));
-        doAnswer(invocation -> {
-            return SCHEDULER.schedule((Runnable) invocation.getArguments()[0], 500, TimeUnit.MILLISECONDS);
-        }).when(executor).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
+        doAnswer(invocation -> SCHEDULER.schedule((Runnable) invocation.getArguments()[0], 500, TimeUnit.MILLISECONDS))
+                .when(executor).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
     }
 
     public void tearDown() {
index 985760c2060e333e8dcbf952a70e825a3441c330..8d8de3526e0629732ff665056a7c8f10582708f9 100644 (file)
@@ -74,8 +74,10 @@ public class UpnpRendererHandlerTest extends UpnpHandlerTest {
     private static final String THING_TYPE_UID = "upnpcontrol:upnprenderer";
     private static final String THING_UID = THING_TYPE_UID + ":mockrenderer";
 
-    private static final String LAST_CHANGE_HEADER = "<Event xmlns=\"urn:schemas-upnp-org:metadata-1-0/AVT/\">"
-            + "<InstanceID val=\"0\">";
+    private static final String LAST_CHANGE_HEADER = """
+            <Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">\
+            <InstanceID val="0">\
+            """;
     private static final String LAST_CHANGE_FOOTER = "</InstanceID></Event>";
     private static final String AV_TRANSPORT_URI = "<AVTransportURI val=\"";
     private static final String AV_TRANSPORT_URI_METADATA = "<AVTransportURIMetaData val=\"";
index 72b0c2692e02f4dea1b7b5fc0e200eb50fd0c856..ce91ec51cd84194faf3b5a6df66c17227f1c6217 100644 (file)
@@ -60,9 +60,11 @@ public class UpnpServerHandlerTest extends UpnpHandlerTest {
     private static final String THING_TYPE_UID = "upnpcontrol:upnpserver";
     private static final String THING_UID = THING_TYPE_UID + ":mockserver";
 
-    private static final String RESPONSE_HEADER = "<DIDL-Lite xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\" "
-            + "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
-            + "xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\">";
+    private static final String RESPONSE_HEADER = """
+            <DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" \
+            xmlns:dc="http://purl.org/dc/elements/1.1/" \
+            xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">\
+            """;
     private static final String RESPONSE_FOOTER = "</DIDL-Lite>";
 
     private static final String BASE_CONTAINER = RESPONSE_HEADER
index 44a40418f96a091cc2a6faaf6c05848f02aa9a21..d93ae25a1989c809e62a41edbbe75820cec65d74 100644 (file)
@@ -61,8 +61,8 @@ public class UrtsiHandlerFactory extends BaseThingHandlerFactory {
     protected @Nullable ThingHandler createHandler(Thing thing) {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
-        if (thingTypeUID.equals(URTSI_DEVICE_THING_TYPE) && thing instanceof Bridge) {
-            return new UrtsiDeviceHandler((Bridge) thing, serialPortManager);
+        if (thingTypeUID.equals(URTSI_DEVICE_THING_TYPE) && thing instanceof Bridge bridge) {
+            return new UrtsiDeviceHandler(bridge, serialPortManager);
         } else if (thingTypeUID.equals(RTS_DEVICE_THING_TYPE)) {
             return new RtsDeviceHandler(thing);
         }
index 9b164232bf726e46bfb1c80d45b70a7a7d071032..95d66ac63a51d9676df7967270c98f83f062d86e 100644 (file)
@@ -42,8 +42,8 @@ public class RtsDeviceHandler extends BaseThingHandler {
     public void handleCommand(ChannelUID channelUID, Command command) {
         if (channelUID.getId().equals(UrtsiBindingConstants.POSITION)) {
             RtsCommand rtsCommand = null;
-            if (command instanceof UpDownType) {
-                switch ((UpDownType) command) {
+            if (command instanceof UpDownType upDownCommand) {
+                switch (upDownCommand) {
                     case UP:
                         rtsCommand = RtsCommand.UP;
                         break;
@@ -53,8 +53,8 @@ public class RtsDeviceHandler extends BaseThingHandler {
                     default:
                         break;
                 }
-            } else if (command instanceof StopMoveType) {
-                switch ((StopMoveType) command) {
+            } else if (command instanceof StopMoveType stopMoveCommand) {
+                switch (stopMoveCommand) {
                     case STOP:
                         rtsCommand = RtsCommand.STOP;
                         break;
@@ -65,11 +65,10 @@ public class RtsDeviceHandler extends BaseThingHandler {
             if (rtsCommand != null) {
                 // We delegate the execution to the bridge handler
                 ThingHandler bridgeHandler = getBridge().getHandler();
-                if (bridgeHandler instanceof UrtsiDeviceHandler) {
-                    boolean executedSuccessfully = ((UrtsiDeviceHandler) bridgeHandler).executeRtsCommand(getThing(),
-                            rtsCommand);
-                    if (executedSuccessfully && command instanceof State) {
-                        updateState(channelUID, (State) command);
+                if (bridgeHandler instanceof UrtsiDeviceHandler deviceHandler) {
+                    boolean executedSuccessfully = deviceHandler.executeRtsCommand(getThing(), rtsCommand);
+                    if (executedSuccessfully && command instanceof State state) {
+                        updateState(channelUID, state);
                     }
                 }
             }
index f0ba662b180232edb2b1c4125c18aa0bc92d40e0..796a470e57c7826d6e6ca3859dd79763fda1ab32 100644 (file)
@@ -91,8 +91,7 @@ public class UrtsiDeviceHandler extends BaseBridgeHandler {
         }
         String urtsiCommand = new StringBuilder(address).append(mappedChannel).append(rtsCommand.getActionKey())
                 .toString();
-        boolean executedSuccessfully = writeString(urtsiCommand);
-        return executedSuccessfully;
+        return writeString(urtsiCommand);
     }
 
     /**
index 387b768d4a323341bbe87d6c16f3454f7c0558b1..453b8f0a582733c184967b2cc8f0bef636ce8f69 100644 (file)
@@ -12,9 +12,6 @@
  */
 package org.openhab.binding.valloxmv.internal;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -241,28 +238,24 @@ public class ValloxMVBindingConstants {
     /**
      * Set of writable channels that are Switches
      */
-    public static final Set<String> WRITABLE_CHANNELS_SWITCHES = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(CHANNEL_ONOFF, CHANNEL_BOOST_TIMER_ENABLED,
-                    CHANNEL_FIREPLACE_TIMER_ENABLED, CHANNEL_EXTRA_TIMER_ENABLED, CHANNEL_WEEKLY_TIMER_ENABLED)));
+    public static final Set<String> WRITABLE_CHANNELS_SWITCHES = Set.of(CHANNEL_ONOFF, CHANNEL_BOOST_TIMER_ENABLED,
+            CHANNEL_FIREPLACE_TIMER_ENABLED, CHANNEL_EXTRA_TIMER_ENABLED, CHANNEL_WEEKLY_TIMER_ENABLED);
 
     /**
      *
      * Set of writable channels that are dimensionless
      */
-    public static final Set<String> WRITABLE_CHANNELS_DIMENSIONLESS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(CHANNEL_EXTR_FAN_BALANCE_BASE, CHANNEL_SUPP_FAN_BALANCE_BASE,
-                    CHANNEL_HOME_SPEED_SETTING, CHANNEL_AWAY_SPEED_SETTING, CHANNEL_BOOST_SPEED_SETTING,
-                    CHANNEL_BOOST_TIME, CHANNEL_BOOST_TIMER_ENABLED, CHANNEL_FIREPLACE_EXTR_FAN,
-                    CHANNEL_FIREPLACE_SUPP_FAN, CHANNEL_FIREPLACE_TIME, CHANNEL_FIREPLACE_TIMER_ENABLED,
-                    CHANNEL_EXTRA_EXTR_FAN, CHANNEL_EXTRA_SUPP_FAN, CHANNEL_EXTRA_TIME, CHANNEL_EXTRA_TIMER_ENABLED,
-                    CHANNEL_WEEKLY_TIMER_ENABLED)));
+    public static final Set<String> WRITABLE_CHANNELS_DIMENSIONLESS = Set.of(CHANNEL_EXTR_FAN_BALANCE_BASE,
+            CHANNEL_SUPP_FAN_BALANCE_BASE, CHANNEL_HOME_SPEED_SETTING, CHANNEL_AWAY_SPEED_SETTING,
+            CHANNEL_BOOST_SPEED_SETTING, CHANNEL_BOOST_TIME, CHANNEL_BOOST_TIMER_ENABLED, CHANNEL_FIREPLACE_EXTR_FAN,
+            CHANNEL_FIREPLACE_SUPP_FAN, CHANNEL_FIREPLACE_TIME, CHANNEL_FIREPLACE_TIMER_ENABLED, CHANNEL_EXTRA_EXTR_FAN,
+            CHANNEL_EXTRA_SUPP_FAN, CHANNEL_EXTRA_TIME, CHANNEL_EXTRA_TIMER_ENABLED, CHANNEL_WEEKLY_TIMER_ENABLED);
 
     /**
      * Set of writable channels that are temperatures
      */
-    public static final Set<String> WRITABLE_CHANNELS_TEMPERATURE = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(CHANNEL_HOME_AIR_TEMP_TARGET, CHANNEL_AWAY_AIR_TEMP_TARGET,
-                    CHANNEL_BOOST_AIR_TEMP_TARGET, CHANNEL_EXTRA_AIR_TEMP_TARGET)));
+    public static final Set<String> WRITABLE_CHANNELS_TEMPERATURE = Set.of(CHANNEL_HOME_AIR_TEMP_TARGET,
+            CHANNEL_AWAY_AIR_TEMP_TARGET, CHANNEL_BOOST_AIR_TEMP_TARGET, CHANNEL_EXTRA_AIR_TEMP_TARGET);
 
     // Thing configuration
     /**
index fb8ab7eb038bc0614e8cfe8a173abe49c1cce639..b113fbd3c6189e96be405e8dc8edd0565dd0ca2c 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.valloxmv.internal;
 
 import static org.openhab.binding.valloxmv.internal.ValloxMVBindingConstants.THING_TYPE_VALLOXMV;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -40,7 +39,7 @@ import org.osgi.service.component.annotations.Reference;
 @NonNullByDefault()
 public class ValloxMVHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_VALLOXMV);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_VALLOXMV);
 
     private final WebSocketClient webSocketClient;
 
index 42cf79b847c9a4dd7d70b9b2abbecd054fff86c4..4d04b6f202aec8ac077b170e9c7f98c2da321400 100644 (file)
@@ -101,7 +101,7 @@ public class VDRHandler extends BaseThingHandler {
         Map<String, String> properties = editProperties();
         // set vdr version to properties of thing
         String version = client.getSVDRPVersion();
-        properties.put(VDRBindingConstants.PROPERTY_VERSION, version.toString());
+        properties.put(VDRBindingConstants.PROPERTY_VERSION, version);
 
         // persist changes only if there are any changes.
         if (!editProperties().equals(properties)) {
index e69ab663efabaf236dc36832580ecdc4ec0aca43..dd37ca7085015647f183deb6215aecfa0a72a925 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.vdr.internal;
 
 import static org.openhab.binding.vdr.internal.VDRBindingConstants.THING_TYPE_VDR;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -39,7 +38,7 @@ import org.osgi.service.component.annotations.Reference;
 @Component(configurationPid = "binding.vdr", service = ThingHandlerFactory.class)
 public class VDRHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_VDR);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_VDR);
 
     private final TimeZoneProvider timeZoneProvider;
 
index f5dc9dc365548a2c6365ec76630606e127cb4996..88affe4316bb1d9b89fe4fde00e8f85959eeaf21 100644 (file)
@@ -90,7 +90,7 @@ public class SVDRPChannel {
     public String toString() {
         StringBuilder sb = new StringBuilder();
         if (number >= 0) {
-            sb.append("Number: " + String.valueOf(number) + System.lineSeparator());
+            sb.append("Number: " + number + System.lineSeparator());
         }
         sb.append("Name: " + name + System.lineSeparator());
         return sb.toString();
index 669a6112b80b41d1ace9c3cf47997f91c23d21d2..5941a666c4dc90e6927eda333b1f83abe02af6cf 100644 (file)
@@ -219,8 +219,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         res = execute("STAT disk");
 
         if (res.getCode() == 250) {
-            SVDRPDiskStatus status = SVDRPDiskStatus.parse(res.getMessage());
-            return status;
+            return SVDRPDiskStatus.parse(res.getMessage());
         } else {
             throw new SVDRPParseResponseException(res);
         }
@@ -249,8 +248,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         }
 
         if (res != null && res.getCode() == 215) {
-            SVDRPEpgEvent entry = SVDRPEpgEvent.parse(res.getMessage());
-            return entry;
+            return SVDRPEpgEvent.parse(res.getMessage());
         } else if (res != null) {
             throw new SVDRPParseResponseException(res);
         } else {
@@ -272,8 +270,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         res = execute("VOLU");
 
         if (res.getCode() == 250) {
-            SVDRPVolume volume = SVDRPVolume.parse(res.getMessage());
-            return volume;
+            return SVDRPVolume.parse(res.getMessage());
         } else {
             throw new SVDRPParseResponseException(res);
         }
@@ -295,8 +292,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         res = execute(String.format("VOLU %s", String.valueOf(Math.round(newVolumeDouble))));
 
         if (res.getCode() == 250) {
-            SVDRPVolume volume = SVDRPVolume.parse(res.getMessage());
-            return volume;
+            return SVDRPVolume.parse(res.getMessage());
         } else {
             throw new SVDRPParseResponseException(res);
         }
@@ -352,8 +348,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         res = execute("CHAN");
 
         if (res.getCode() == 250) {
-            SVDRPChannel channel = SVDRPChannel.parse(res.getMessage());
-            return channel;
+            return SVDRPChannel.parse(res.getMessage());
         } else {
             throw new SVDRPParseResponseException(res);
         }
@@ -374,8 +369,7 @@ public class SVDRPClientImpl implements SVDRPClient {
         res = execute(String.format("CHAN %s", number));
 
         if (res.getCode() == 250) {
-            SVDRPChannel channel = SVDRPChannel.parse(res.getMessage());
-            return channel;
+            return SVDRPChannel.parse(res.getMessage());
         } else {
             throw new SVDRPParseResponseException(res);
         }
index 9d8f66d6eb376e13bd82e5affac58e3278048395..d0943f381df748b7a192ccdc012ad9f042328bd7 100644 (file)
@@ -33,32 +33,72 @@ import org.openhab.binding.vdr.internal.svdrp.SVDRPParseResponseException;
  */
 @NonNullByDefault
 public class SVDRPEpgEventTest {
-    private final String epgResponseComplete = "C S19.2E-1-1201-28326 WDR HD Bielefeld\n"
-            + "E 9886 1610391600 900 4E F\n" + "T Tagesschau\n" + "S Aktuelle Nachrichten aus der Welt\n"
-            + "D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien\n"
-            + "G 20 80\n" + "X 2 03 deu stereo\n" + "X 2 03 deu ohne Audiodeskription\n"
-            + "X 3 01 deu Teletext-Untertitel\n" + "X 3 20 deu mit DVB-Untertitel\n" + "X 5 0B deu HD-Video\n"
-            + "V 1610391600\n" + "e\n" + "c\n" + "End of EPG data";
-    private final String epgMissingSubtitle = "C S19.2E-1-1201-28326 WDR HD Bielefeld\n"
-            + "E 9886 1610391600 900 4E F\n" + "T Tagesschau\n"
-            + "D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien\n"
-            + "G 20 80\n" + "X 2 03 deu stereo\n" + "X 2 03 deu ohne Audiodeskription\n"
-            + "X 3 01 deu Teletext-Untertitel\n" + "X 3 20 deu mit DVB-Untertitel\n" + "X 5 0B deu HD-Video\n"
-            + "V 1610391600\n" + "e\n" + "c\n" + "End of EPG data";
+    private final String epgResponseComplete = """
+            C S19.2E-1-1201-28326 WDR HD Bielefeld
+            E 9886 1610391600 900 4E F
+            T Tagesschau
+            S Aktuelle Nachrichten aus der Welt
+            D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien
+            G 20 80
+            X 2 03 deu stereo
+            X 2 03 deu ohne Audiodeskription
+            X 3 01 deu Teletext-Untertitel
+            X 3 20 deu mit DVB-Untertitel
+            X 5 0B deu HD-Video
+            V 1610391600
+            e
+            c
+            End of EPG data\
+            """;
+    private final String epgMissingSubtitle = """
+            C S19.2E-1-1201-28326 WDR HD Bielefeld
+            E 9886 1610391600 900 4E F
+            T Tagesschau
+            D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien
+            G 20 80
+            X 2 03 deu stereo
+            X 2 03 deu ohne Audiodeskription
+            X 3 01 deu Teletext-Untertitel
+            X 3 20 deu mit DVB-Untertitel
+            X 5 0B deu HD-Video
+            V 1610391600
+            e
+            c
+            End of EPG data\
+            """;
     private final String epgParseError = "E 9999999999999999999999999";
-    private final String epgCorruptDate = "C S19.2E-1-1201-28326 WDR HD Bielefeld\n" + "E 9886 2a10391600 900 4E F\n"
-            + "T Tagesschau\n"
-            + "D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien\n"
-            + "G 20 80\n" + "X 2 03 deu stereo\n" + "X 2 03 deu ohne Audiodeskription\n"
-            + "X 3 01 deu Teletext-Untertitel\n" + "X 3 20 deu mit DVB-Untertitel\n" + "X 5 0B deu HD-Video\n"
-            + "V 1610391600\n" + "e\n" + "c\n" + "End of EPG data";
+    private final String epgCorruptDate = """
+            C S19.2E-1-1201-28326 WDR HD Bielefeld
+            E 9886 2a10391600 900 4E F
+            T Tagesschau
+            D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien
+            G 20 80
+            X 2 03 deu stereo
+            X 2 03 deu ohne Audiodeskription
+            X 3 01 deu Teletext-Untertitel
+            X 3 20 deu mit DVB-Untertitel
+            X 5 0B deu HD-Video
+            V 1610391600
+            e
+            c
+            End of EPG data\
+            """;
 
-    private final String epgMissingEnd = "C S19.2E-1-1201-28326 WDR HD Bielefeld\n" + "E 9886 1610391600 900 4E F\n"
-            + "T Tagesschau\n"
-            + "D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien\n"
-            + "G 20 80\n" + "X 2 03 deu stereo\n" + "X 2 03 deu ohne Audiodeskription\n"
-            + "X 3 01 deu Teletext-Untertitel\n" + "X 3 20 deu mit DVB-Untertitel\n" + "X 5 0B deu HD-Video\n"
-            + "V 1610391600\n" + "e\n" + "c\n";
+    private final String epgMissingEnd = """
+            C S19.2E-1-1201-28326 WDR HD Bielefeld
+            E 9886 1610391600 900 4E F
+            T Tagesschau
+            D Themen u.a.:|* Corona-Pandemie in Deutschland: Verschärfter Lockdown bundesweit in Kraft|* Entmachtung des US-Präsidenten: Demokraten planen Schritte gegen Trump|* Wintereinbruch in Bosnien-Herzegowina: Dramatische Lage der Flüchtlinge an der Grenze zu Kroatien
+            G 20 80
+            X 2 03 deu stereo
+            X 2 03 deu ohne Audiodeskription
+            X 3 01 deu Teletext-Untertitel
+            X 3 20 deu mit DVB-Untertitel
+            X 5 0B deu HD-Video
+            V 1610391600
+            e
+            c
+            """;
 
     @Test
     public void testParseEpgEventComplete() throws SVDRPException, ParseException {
index 0ced7f52f5c198f4ccd3a81c8c18128388874a5a..6804db4f1cea92107ecbb19f5fc47f896d23f186 100644 (file)
@@ -27,10 +27,14 @@ import org.openhab.binding.vdr.internal.svdrp.SVDRPTimerList;
  */
 @NonNullByDefault
 public class SVDRPTimerListTest {
-    private final String timerListResponseTimerActive = "1 1:1:2021-01-12:2013:2110:50:99:Charité (1/6)~Eiserne Lunge:Test\n"
-            + "2 9:1:2021-01-12:2058:2200:50:99:Charité (2/6)~Blutsauger:Test";
-    private final String timerListResponseTimerNotActive = "1 1:1:2021-01-12:2013:2110:50:99:Charité (1/6)~Eiserne Lunge:Test\n"
-            + "2 1:1:2021-01-12:2058:2200:50:99:Charité (2/6)~Blutsauger:Test";
+    private final String timerListResponseTimerActive = """
+            1 1:1:2021-01-12:2013:2110:50:99:Charité (1/6)~Eiserne Lunge:Test
+            2 9:1:2021-01-12:2058:2200:50:99:Charité (2/6)~Blutsauger:Test\
+            """;
+    private final String timerListResponseTimerNotActive = """
+            1 1:1:2021-01-12:2013:2110:50:99:Charité (1/6)~Eiserne Lunge:Test
+            2 1:1:2021-01-12:2058:2200:50:99:Charité (2/6)~Blutsauger:Test\
+            """;
 
     @Test
     public void testParseTimerList() throws SVDRPException {
index 131a386083dd9f44a69a93deee11d305b702b7a6..a96367b3c2d28f49db69692d98896fdf99c4f7c5 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.vektiva.internal;
 
 import static org.openhab.binding.vektiva.internal.VektivaBindingConstants.THING_TYPE_SMARWI;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -43,7 +42,7 @@ import org.osgi.service.component.annotations.Reference;
 @Component(configurationPid = "binding.vektiva", service = ThingHandlerFactory.class)
 public class VektivaHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SMARWI);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SMARWI);
 
     /**
      * the shared http client
index 404be96695b51796165f9c144c54944c8f21e3fe..ceee0ff2d4f17d378f2ea5d3e9e3cdf7e3aebfd6 100644 (file)
@@ -241,7 +241,7 @@ public class VektivaSmarwiHandler extends BaseThingHandler {
             statusMessage = "Blocked";
         }
 
-        int position = values.getOrDefault("pos", NA).equals("o") ? 0 : 100;
+        int position = "o".equals(values.getOrDefault("pos", NA)) ? 0 : 100;
         if (position == 0 && lastPosition != -1) {
             position = lastPosition;
         }
index de5b7c77b46975778e318698988acfacebfd0393..7c975d992f4ec8994e884e083b413f2c3c00ec66 100644 (file)
@@ -12,9 +12,6 @@
  */
 package org.openhab.binding.velbus.internal;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -89,20 +86,19 @@ public class VelbusBindingConstants {
     public static final ThingTypeUID THING_TYPE_VMB4PB = new ThingTypeUID(BINDING_ID, "vmb4pb");
 
     // thing type sets
-    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(BRIDGE_THING_TYPE, NETWORK_BRIDGE_THING_TYPE)));
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
-            new HashSet<>(Arrays.asList(THING_TYPE_VMB1BL, THING_TYPE_VMB1BLS, THING_TYPE_VMB1DM, THING_TYPE_VMB1LED,
-                    THING_TYPE_VMB1RY, THING_TYPE_VMB1RYNO, THING_TYPE_VMB1RYNOS, THING_TYPE_VMB1RYS, THING_TYPE_VMB1TS,
-                    THING_TYPE_VMB2BL, THING_TYPE_VMB2BLE, THING_TYPE_VMB2PBN, THING_TYPE_VMB4AN, THING_TYPE_VMB4DC,
-                    THING_TYPE_VMB4RY, THING_TYPE_VMB4RYLD, THING_TYPE_VMB4RYNO, THING_TYPE_VMB6IN, THING_TYPE_VMB6PBN,
-                    THING_TYPE_VMB7IN, THING_TYPE_VMB8IR, THING_TYPE_VMB8PB, THING_TYPE_VMB8PBU, THING_TYPE_VMBDME,
-                    THING_TYPE_VMBDMI, THING_TYPE_VMBDMIR, THING_TYPE_VMBEL1, THING_TYPE_VMBEL2, THING_TYPE_VMBEL4,
-                    THING_TYPE_VMBELO, THING_TYPE_VMBELPIR, THING_TYPE_VMBGP1, THING_TYPE_VMBGP1_2, THING_TYPE_VMBGP2,
-                    THING_TYPE_VMBGP2_2, THING_TYPE_VMBGP4, THING_TYPE_VMBGP4_2, THING_TYPE_VMBGP4PIR,
-                    THING_TYPE_VMBGP4PIR_2, THING_TYPE_VMBGPO, THING_TYPE_VMBGPOD, THING_TYPE_VMBGPOD_2,
-                    THING_TYPE_VMBMETEO, THING_TYPE_VMBPIRC, THING_TYPE_VMBPIRM, THING_TYPE_VMBPIRO,
-                    THING_TYPE_VMBRFR8S, THING_TYPE_VMBVP1, THING_TYPE_VMBKP, THING_TYPE_VMBIN, THING_TYPE_VMB4PB)));
+    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE,
+            NETWORK_BRIDGE_THING_TYPE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_VMB1BL, THING_TYPE_VMB1BLS,
+            THING_TYPE_VMB1DM, THING_TYPE_VMB1LED, THING_TYPE_VMB1RY, THING_TYPE_VMB1RYNO, THING_TYPE_VMB1RYNOS,
+            THING_TYPE_VMB1RYS, THING_TYPE_VMB1TS, THING_TYPE_VMB2BL, THING_TYPE_VMB2BLE, THING_TYPE_VMB2PBN,
+            THING_TYPE_VMB4AN, THING_TYPE_VMB4DC, THING_TYPE_VMB4RY, THING_TYPE_VMB4RYLD, THING_TYPE_VMB4RYNO,
+            THING_TYPE_VMB6IN, THING_TYPE_VMB6PBN, THING_TYPE_VMB7IN, THING_TYPE_VMB8IR, THING_TYPE_VMB8PB,
+            THING_TYPE_VMB8PBU, THING_TYPE_VMBDME, THING_TYPE_VMBDMI, THING_TYPE_VMBDMIR, THING_TYPE_VMBEL1,
+            THING_TYPE_VMBEL2, THING_TYPE_VMBEL4, THING_TYPE_VMBELO, THING_TYPE_VMBELPIR, THING_TYPE_VMBGP1,
+            THING_TYPE_VMBGP1_2, THING_TYPE_VMBGP2, THING_TYPE_VMBGP2_2, THING_TYPE_VMBGP4, THING_TYPE_VMBGP4_2,
+            THING_TYPE_VMBGP4PIR, THING_TYPE_VMBGP4PIR_2, THING_TYPE_VMBGPO, THING_TYPE_VMBGPOD, THING_TYPE_VMBGPOD_2,
+            THING_TYPE_VMBMETEO, THING_TYPE_VMBPIRC, THING_TYPE_VMBPIRM, THING_TYPE_VMBPIRO, THING_TYPE_VMBRFR8S,
+            THING_TYPE_VMBVP1, THING_TYPE_VMBKP, THING_TYPE_VMBIN, THING_TYPE_VMB4PB);
 
     // Velbus module types
     public static final byte MODULE_TYPE_VMB8PB = 0x01;
index 18bfb8399518aa582a74f19bb118bd82df4a22fd..0ea2bac0ebfb3ef7fcb085110a2b568d2efcdcef 100644 (file)
@@ -384,8 +384,7 @@ public class VelbusThingDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VelbusBridgeHandler) {
-            final VelbusBridgeHandler velbusBridgeHandler = (VelbusBridgeHandler) handler;
+        if (handler instanceof VelbusBridgeHandler velbusBridgeHandler) {
             this.velbusBridgeHandler = velbusBridgeHandler;
             velbusBridgeHandler.setDefaultPacketListener(this);
         }
index c191cdf9e2885196cdbf3fb8d83ceaeec9824c1d..d6cf637141a931550f60343c1c01ded1e67ff8b3 100644 (file)
@@ -69,9 +69,8 @@ public class VelbusBlindsHandler extends VelbusThingHandler {
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (command instanceof UpDownType) {
-            UpDownType s = (UpDownType) command;
-            if (s == UpDownType.UP) {
+        } else if (command instanceof UpDownType upDownCommand) {
+            if (upDownCommand == UpDownType.UP) {
                 byte commandByte = COMMAND_BLIND_UP;
 
                 VelbusBlindUpDownPacket packet = new VelbusBlindUpDownPacket(
@@ -88,18 +87,17 @@ public class VelbusBlindsHandler extends VelbusThingHandler {
                 byte[] packetBytes = packet.getBytes();
                 velbusBridgeHandler.sendPacket(packetBytes);
             }
-        } else if (command instanceof StopMoveType) {
-            StopMoveType s = (StopMoveType) command;
-            if (s == StopMoveType.STOP) {
+        } else if (command instanceof StopMoveType stopMoveCommand) {
+            if (stopMoveCommand == StopMoveType.STOP) {
                 VelbusBlindOffPacket packet = new VelbusBlindOffPacket(
                         getModuleAddress().getChannelIdentifier(channelUID));
 
                 byte[] packetBytes = packet.getBytes();
                 velbusBridgeHandler.sendPacket(packetBytes);
             }
-        } else if (command instanceof PercentType) {
+        } else if (command instanceof PercentType percentCommand) {
             VelbusBlindPositionPacket packet = new VelbusBlindPositionPacket(
-                    getModuleAddress().getChannelIdentifier(channelUID), ((PercentType) command).byteValue());
+                    getModuleAddress().getChannelIdentifier(channelUID), percentCommand.byteValue());
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
index 8d11b8462924d7cc046607f88ede2c6d89d7c302..7d7fa266eff1dfc94f0794e6481ee751eec5757e 100644 (file)
@@ -20,9 +20,9 @@ import java.io.OutputStream;
 import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.TimeZone;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -172,32 +172,32 @@ public abstract class VelbusBridgeHandler extends BaseBridgeHandler {
                 }
                 case CHANNEL_BRIDGE_CLOCK_ALARM1_WAKEUP_HOUR:
                 case CHANNEL_BRIDGE_CLOCK_ALARM2_WAKEUP_HOUR: {
-                    if (command instanceof DecimalType) {
-                        byte wakeupHour = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte wakeupHour = decimalCommand.byteValue();
                         alarmClock.setWakeupHour(wakeupHour);
                     }
                     break;
                 }
                 case CHANNEL_BRIDGE_CLOCK_ALARM1_WAKEUP_MINUTE:
                 case CHANNEL_BRIDGE_CLOCK_ALARM2_WAKEUP_MINUTE: {
-                    if (command instanceof DecimalType) {
-                        byte wakeupMinute = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte wakeupMinute = decimalCommand.byteValue();
                         alarmClock.setWakeupMinute(wakeupMinute);
                     }
                     break;
                 }
                 case CHANNEL_BRIDGE_CLOCK_ALARM1_BEDTIME_HOUR:
                 case CHANNEL_BRIDGE_CLOCK_ALARM2_BEDTIME_HOUR: {
-                    if (command instanceof DecimalType) {
-                        byte bedTimeHour = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte bedTimeHour = decimalCommand.byteValue();
                         alarmClock.setBedtimeHour(bedTimeHour);
                     }
                     break;
                 }
                 case CHANNEL_BRIDGE_CLOCK_ALARM1_BEDTIME_MINUTE:
                 case CHANNEL_BRIDGE_CLOCK_ALARM2_BEDTIME_MINUTE: {
-                    if (command instanceof DecimalType) {
-                        byte bedTimeMinute = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte bedTimeMinute = decimalCommand.byteValue();
                         alarmClock.setBedtimeMinute(bedTimeMinute);
                     }
                     break;
@@ -361,7 +361,7 @@ public abstract class VelbusBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(VelbusThingDiscoveryService.class);
+        return Set.of(VelbusThingDiscoveryService.class);
     }
 
     public void setDefaultPacketListener(VelbusPacketListener velbusPacketListener) {
index 77f21b8d7ce8e10227f0d31d1c55a1212d7ff3a0..5042378cc0c33616996e908a4e5d9430f371f75c 100644 (file)
@@ -72,17 +72,16 @@ public class VelbusDimmerHandler extends VelbusThingHandler {
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (command instanceof PercentType) {
+        } else if (command instanceof PercentType percentCommand) {
             byte commandByte = COMMAND_SET_VALUE;
 
             VelbusDimmerPacket packet = new VelbusDimmerPacket(getModuleAddress().getChannelIdentifier(channelUID),
-                    commandByte, ((PercentType) command).byteValue(), this.dimmerConfig.dimspeed,
-                    isFirstGenerationDevice());
+                    commandByte, percentCommand.byteValue(), this.dimmerConfig.dimspeed, isFirstGenerationDevice());
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (command instanceof OnOffType) {
-            byte commandByte = determineCommandByte((OnOffType) command);
+        } else if (command instanceof OnOffType onOffCommand) {
+            byte commandByte = determineCommandByte(onOffCommand);
 
             VelbusDimmerPacket packet = new VelbusDimmerPacket(getModuleAddress().getChannelIdentifier(channelUID),
                     commandByte, (byte) 0x00, this.dimmerConfig.dimspeed, isFirstGenerationDevice());
index 291d94296aa5229563247a3a09c800efd3649e01..86fcb9288864bf4c14d2730098ef22110d4345de 100644 (file)
@@ -47,8 +47,8 @@ public abstract class VelbusMemoHandler extends VelbusThermostatHandler {
             return;
         }
 
-        if (channelUID.equals(memoChannel) && command instanceof StringType) {
-            String memoText = ((StringType) command).toFullString();
+        if (channelUID.equals(memoChannel) && command instanceof StringType stringCommand) {
+            String memoText = stringCommand.toFullString();
             String trucatedMemoText = memoText.substring(0, Math.min(memoText.length(), MEMO_TEXT_MAX_LENGTH));
             String[] splittedMemoText = trucatedMemoText.split("(?<=\\G.....)");
 
index 7209ce76f7a7682f065aaeb2bc833da2adf21d54..13931d71c7483a6d1673883ec89bfb0f930d0102 100644 (file)
@@ -61,8 +61,8 @@ public class VelbusRelayHandler extends VelbusThingHandler {
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (command instanceof OnOffType) {
-            byte commandByte = determineCommandByte((OnOffType) command);
+        } else if (command instanceof OnOffType onOffCommand) {
+            byte commandByte = determineCommandByte(onOffCommand);
 
             VelbusRelayPacket packet = new VelbusRelayPacket(getModuleAddress().getChannelIdentifier(channelUID),
                     commandByte);
index daf91de7d32274ed72bb3c7ae9ed1867da0501c4..a543bae88b1928c9c0e81ef3d49ae0739a2ce6bf 100644 (file)
@@ -58,17 +58,15 @@ public class VelbusRelayWithInputHandler extends VelbusRelayHandler {
             return;
         }
 
-        if (isButtonChannel(channelUID) && command instanceof StringType) {
-            StringType stringTypeCommand = (StringType) command;
-
-            if (stringTypeCommand.equals(PRESSED) || stringTypeCommand.equals(LONG_PRESSED)) {
+        if (isButtonChannel(channelUID) && command instanceof StringType stringCommand) {
+            if (stringCommand.equals(PRESSED) || stringCommand.equals(LONG_PRESSED)) {
                 VelbusButtonPacket packet = new VelbusButtonPacket(getModuleAddress().getChannelIdentifier(channelUID));
 
                 packet.Pressed();
                 velbusBridgeHandler.sendPacket(packet.getBytes());
                 triggerChannel("CH6t", CommonTriggerEvents.PRESSED);
 
-                if (stringTypeCommand.equals(LONG_PRESSED)) {
+                if (stringCommand.equals(LONG_PRESSED)) {
                     packet.LongPressed();
                     velbusBridgeHandler.sendPacket(packet.getBytes());
                     triggerChannel("CH6t", CommonTriggerEvents.LONG_PRESSED);
index b86cf3e3d9e19740e2bbe8f9fcb3395044ebeb08..72a3a54c82ee415701ab3c0d18f0067f352ba1e8 100644 (file)
@@ -69,19 +69,17 @@ public class VelbusSensorHandler extends VelbusThingHandler {
             return;
         }
 
-        if (isFeedbackChannel(channelUID) && command instanceof StringType) {
+        if (isFeedbackChannel(channelUID) && command instanceof StringType stringCommand) {
             byte commandByte;
-
-            StringType stringTypeCommand = (StringType) command;
-            if (stringTypeCommand.equals(SET_LED)) {
+            if (stringCommand.equals(SET_LED)) {
                 commandByte = COMMAND_SET_LED;
-            } else if (stringTypeCommand.equals(SLOW_BLINK_LED)) {
+            } else if (stringCommand.equals(SLOW_BLINK_LED)) {
                 commandByte = COMMAND_SLOW_BLINK_LED;
-            } else if (stringTypeCommand.equals(FAST_BLINK_LED)) {
+            } else if (stringCommand.equals(FAST_BLINK_LED)) {
                 commandByte = COMMAND_FAST_BLINK_LED;
-            } else if (stringTypeCommand.equals(VERY_FAST_BLINK_LED)) {
+            } else if (stringCommand.equals(VERY_FAST_BLINK_LED)) {
                 commandByte = COMMAND_VERY_FAST_BLINK_LED;
-            } else if (stringTypeCommand.equals(CLEAR_LED)) {
+            } else if (stringCommand.equals(CLEAR_LED)) {
                 commandByte = COMMAND_CLEAR_LED;
             } else {
                 throw new UnsupportedOperationException(
@@ -95,10 +93,8 @@ public class VelbusSensorHandler extends VelbusThingHandler {
             velbusBridgeHandler.sendPacket(packetBytes);
         }
 
-        if (isButtonChannel(channelUID) && command instanceof StringType) {
-            StringType stringTypeCommand = (StringType) command;
-
-            if (stringTypeCommand.equals(PRESSED) || stringTypeCommand.equals(LONG_PRESSED)) {
+        if (isButtonChannel(channelUID) && command instanceof StringType stringCommand) {
+            if (stringCommand.equals(PRESSED) || stringCommand.equals(LONG_PRESSED)) {
                 VelbusButtonPacket packet = new VelbusButtonPacket(getModuleAddress().getChannelIdentifier(channelUID));
 
                 packet.Pressed();
@@ -106,7 +102,7 @@ public class VelbusSensorHandler extends VelbusThingHandler {
                 triggerChannel("input#CH" + getModuleAddress().getChannelNumber(channelUID),
                         CommonTriggerEvents.PRESSED);
 
-                if (stringTypeCommand.equals(LONG_PRESSED)) {
+                if (stringCommand.equals(LONG_PRESSED)) {
                     packet.LongPressed();
                     velbusBridgeHandler.sendPacket(packet.getBytes());
                     triggerChannel("input#CH" + getModuleAddress().getChannelNumber(channelUID),
@@ -141,7 +137,6 @@ public class VelbusSensorHandler extends VelbusThingHandler {
             byte command = packet[4];
 
             if (command == COMMAND_PUSH_BUTTON_STATUS && packet.length >= 6) {
-
                 for (int channel = 0; channel < 8; channel++) {
                     byte channelMask = (byte) Math.pow(2, channel);
 
index e6258b6e9d1d0589cf6303eacdc1867580b00946..364411c1d725b7c1b789283c08bf676791ab07ac 100644 (file)
@@ -180,32 +180,32 @@ public class VelbusSensorWithAlarmClockHandler extends VelbusSensorHandler {
                 }
                 case CHANNEL_MODULE_CLOCK_ALARM1_WAKEUP_HOUR:
                 case CHANNEL_MODULE_CLOCK_ALARM2_WAKEUP_HOUR: {
-                    if (command instanceof DecimalType) {
-                        byte wakeupHour = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte wakeupHour = decimalCommand.byteValue();
                         alarmClock.setWakeupHour(wakeupHour);
                     }
                     break;
                 }
                 case CHANNEL_MODULE_CLOCK_ALARM1_WAKEUP_MINUTE:
                 case CHANNEL_MODULE_CLOCK_ALARM2_WAKEUP_MINUTE: {
-                    if (command instanceof DecimalType) {
-                        byte wakeupMinute = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte wakeupMinute = decimalCommand.byteValue();
                         alarmClock.setWakeupMinute(wakeupMinute);
                     }
                     break;
                 }
                 case CHANNEL_MODULE_CLOCK_ALARM1_BEDTIME_HOUR:
                 case CHANNEL_MODULE_CLOCK_ALARM2_BEDTIME_HOUR: {
-                    if (command instanceof DecimalType) {
-                        byte bedTimeHour = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte bedTimeHour = decimalCommand.byteValue();
                         alarmClock.setBedtimeHour(bedTimeHour);
                     }
                     break;
                 }
                 case CHANNEL_MODULE_CLOCK_ALARM1_BEDTIME_MINUTE:
                 case CHANNEL_MODULE_CLOCK_ALARM2_BEDTIME_MINUTE: {
-                    if (command instanceof DecimalType) {
-                        byte bedTimeMinute = ((DecimalType) command).byteValue();
+                    if (command instanceof DecimalType decimalCommand) {
+                        byte bedTimeMinute = decimalCommand.byteValue();
                         alarmClock.setBedtimeMinute(bedTimeMinute);
                     }
                     break;
index a4169030e76acb1a2f79360d65a426b72343b44d..281d22c0a38529c3d1888369addcad84ae8e2876 100644 (file)
@@ -110,8 +110,8 @@ public abstract class VelbusThermostatHandler extends VelbusTemperatureSensorHan
         } else if (isThermostatChannel(channelUID)
                 && (command instanceof QuantityType<?> || command instanceof DecimalType)) {
             byte temperatureVariable = determineTemperatureVariable(channelUID);
-            QuantityType<?> temperatureInDegreesCelcius = (command instanceof QuantityType<?>)
-                    ? ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS)
+            QuantityType<?> temperatureInDegreesCelcius = (command instanceof QuantityType<?> qt)
+                    ? qt.toUnit(SIUnits.CELSIUS)
                     : new QuantityType<>(((DecimalType) command), SIUnits.CELSIUS);
 
             if (temperatureInDegreesCelcius != null) {
@@ -124,8 +124,8 @@ public abstract class VelbusThermostatHandler extends VelbusTemperatureSensorHan
                 byte[] packetBytes = packet.getBytes();
                 velbusBridgeHandler.sendPacket(packetBytes);
             }
-        } else if (channelUID.equals(operatingModeChannel) && command instanceof StringType) {
-            byte commandByte = ((StringType) command).equals(OPERATING_MODE_HEATING) ? COMMAND_SET_HEATING_MODE
+        } else if (channelUID.equals(operatingModeChannel) && command instanceof StringType stringCommand) {
+            byte commandByte = stringCommand.equals(OPERATING_MODE_HEATING) ? COMMAND_SET_HEATING_MODE
                     : COMMAND_SET_COOLING_MODE;
 
             VelbusThermostatOperatingModePacket packet = new VelbusThermostatOperatingModePacket(
@@ -133,15 +133,13 @@ public abstract class VelbusThermostatHandler extends VelbusTemperatureSensorHan
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (channelUID.equals(modeChannel) && command instanceof StringType) {
+        } else if (channelUID.equals(modeChannel) && command instanceof StringType stringCommand) {
             byte commandByte = COMMAND_SWITCH_TO_SAFE_MODE;
-
-            StringType stringTypeCommand = (StringType) command;
-            if (stringTypeCommand.equals(MODE_COMFORT)) {
+            if (stringCommand.equals(MODE_COMFORT)) {
                 commandByte = COMMAND_SWITCH_TO_COMFORT_MODE;
-            } else if (stringTypeCommand.equals(MODE_DAY)) {
+            } else if (stringCommand.equals(MODE_DAY)) {
                 commandByte = COMMAND_SWITCH_TO_DAY_MODE;
-            } else if (stringTypeCommand.equals(MODE_NIGHT)) {
+            } else if (stringCommand.equals(MODE_NIGHT)) {
                 commandByte = COMMAND_SWITCH_TO_NIGHT_MODE;
             }
 
index cd0e9af631b63dd846ab6f664b32a5ba3049db52..2f2acabd322470f69e636c020073bb65219435b9 100644 (file)
@@ -222,8 +222,7 @@ public abstract class VelbusThingHandler extends BaseThingHandler implements Vel
                 return null;
             }
             ThingHandler bridgeHandler = bridge.getHandler();
-            if (bridgeHandler instanceof VelbusBridgeHandler) {
-                VelbusBridgeHandler velbusBridgeHandler = (VelbusBridgeHandler) bridgeHandler;
+            if (bridgeHandler instanceof VelbusBridgeHandler velbusBridgeHandler) {
                 this.velbusBridgeHandler = velbusBridgeHandler;
 
                 if (velbusModuleAddress != null) {
index 22f0bdc6ab908142e3101f7a2f029122e29e6660..482c96d3ba78bdba7530db905c04e18866368bd4 100644 (file)
@@ -124,10 +124,10 @@ public class VelbusVMB4ANHandler extends VelbusSensorWithAlarmClockHandler {
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
-        } else if (command instanceof PercentType && isAnalogOutputChannel(channelUID)) {
+        } else if (command instanceof PercentType percentCommand && isAnalogOutputChannel(channelUID)) {
             VelbusDimmerPacket packet = new VelbusDimmerPacket(
                     new VelbusChannelIdentifier(this.getModuleAddress().getAddress(), channelByte), COMMAND_SET_VALUE,
-                    ((PercentType) command).byteValue(), 0x00, false);
+                    percentCommand.byteValue(), 0x00, false);
 
             byte[] packetBytes = packet.getBytes();
             velbusBridgeHandler.sendPacket(packetBytes);
index de803dc56670fed45bb945bc964f4988a6a257ee..7fcd0842c745d475c1fdc6d021e950cca83ff510 100644 (file)
@@ -41,8 +41,8 @@ public class VeluxActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VeluxBridgeHandler) {
-            this.bridgeHandler = (VeluxBridgeHandler) handler;
+        if (handler instanceof VeluxBridgeHandler veluxBridgeHandler) {
+            this.bridgeHandler = veluxBridgeHandler;
         }
     }
 
index 5d35febd6fcf38b946367db8601937f2dc07d212..cbdf1f37b55b4778aff259f735ca03b7b19e77c7 100644 (file)
@@ -156,7 +156,6 @@ class JCgetFirmware extends GetFirmware implements JsonBridgeCommunicationProtoc
      */
     @Override
     public VeluxGwFirmware getFirmware() {
-        VeluxGwFirmware gwFirmware = new VeluxGwFirmware(response.data.version);
-        return gwFirmware;
+        return new VeluxGwFirmware(response.data.version);
     }
 }
index e584773588b14de1bb4e167a59e4c3c465590188..80d8fc7e4cc358b4caa63a03f90108caf60f7435 100644 (file)
@@ -179,8 +179,7 @@ class JCgetLANConfig extends GetLANConfig implements BridgeCommunicationProtocol
      */
     @Override
     public VeluxGwLAN getLANConfig() {
-        VeluxGwLAN gwLAN = new VeluxGwLAN(response.data.ipAddress, response.data.subnetMask,
-                response.data.defaultGateway, response.data.dhcp);
-        return gwLAN;
+        return new VeluxGwLAN(response.data.ipAddress, response.data.subnetMask, response.data.defaultGateway,
+                response.data.dhcp);
     }
 }
index 07302c32bb6a081b01802e6c5c859d9f9b90a116..1c1900d13c1b890cc8554dc8df791f19b5afaf64 100644 (file)
@@ -175,7 +175,6 @@ class JCgetWLANConfig extends GetWLANConfig implements JsonBridgeCommunicationPr
      */
     @Override
     public VeluxGwWLAN getWLANConfig() {
-        VeluxGwWLAN gwWLAN = new VeluxGwWLAN(response.data.name, response.data.password);
-        return gwWLAN;
+        return new VeluxGwWLAN(response.data.name, response.data.password);
     }
 }
index 628d9f023f3bfa18c1acddf6b6d54bc2e70817ca..952f3c8ee21e9b20c37ba2ff097a85aa854840c4 100644 (file)
@@ -199,10 +199,10 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory {
             veluxBindingHandlers.remove(thingHandler);
         } else
         // Handle Bridge removal
-        if (thingHandler instanceof VeluxBridgeHandler) {
+        if (thingHandler instanceof VeluxBridgeHandler veluxBridgeHandler) {
             logger.trace("removeHandler() removing bridge '{}'.", thingHandler.toString());
             veluxBridgeHandlers.remove(thingHandler);
-            unregisterDeviceDiscoveryService((VeluxBridgeHandler) thingHandler);
+            unregisterDeviceDiscoveryService(veluxBridgeHandler);
         } else
         // Handle removal of Things behind the Bridge
         if (thingHandler instanceof VeluxHandler) {
index bf9a9ee5619fc624585b505aba3b56d6e67da80d..3e78acb2b78bd2738160b3a4ba677aa2eed9c5c7 100644 (file)
@@ -228,10 +228,10 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate {
 
             switch (channelId) {
                 case CHANNEL_VANE_POSITION:
-                    if (command instanceof PercentType) {
+                    if (command instanceof PercentType percentCommand) {
                         VeluxProduct existingProductClone = existingProducts.get(productBridgeIndex).clone();
-                        existingProductClone.setVanePosition(
-                                new VeluxProductPosition((PercentType) command).getPositionAsVeluxType());
+                        existingProductClone
+                                .setVanePosition(new VeluxProductPosition(percentCommand).getPositionAsVeluxType());
                         functionalParameters = existingProductClone.getFunctionalParameters();
                     }
                     break;
@@ -243,12 +243,12 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate {
                                 : new VeluxProductPosition(PercentType.HUNDRED);
                     } else if (command instanceof StopMoveType) {
                         mainParameter = StopMoveType.STOP.equals(command) ? new VeluxProductPosition() : mainParameter;
-                    } else if (command instanceof PercentType) {
-                        PercentType ptCommand = (PercentType) command;
+                    } else if (command instanceof PercentType percentCommand) {
                         if (veluxActuator.isInverted()) {
-                            ptCommand = new PercentType(PercentType.HUNDRED.intValue() - ptCommand.intValue());
+                            percentCommand = new PercentType(
+                                    PercentType.HUNDRED.intValue() - percentCommand.intValue());
                         }
-                        mainParameter = new VeluxProductPosition(ptCommand);
+                        mainParameter = new VeluxProductPosition(percentCommand);
                     }
                     break;
 
@@ -268,7 +268,7 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate {
                 LOGGER.debug("handleCommand(): sending command '{}' for channel id '{}'.", command, channelId);
                 RunProductCommand bcp = thisBridgeHandler.thisBridge.bridgeAPI().runProductCommand();
                 boolean success = false;
-                if (bcp instanceof SCrunProductCommand) {
+                if (bcp instanceof SCrunProductCommand productCommand) {
                     synchronized (bcp) {
                         if (bcp.setNodeIdAndParameters(productBridgeIndex.toInt(), mainParameter, functionalParameters)
                                 && thisBridgeHandler.thisBridge.bridgeCommunicate(bcp)
@@ -278,7 +278,7 @@ final class ChannelActuatorPosition extends ChannelHandlerTemplate {
                                     .autoRefresh(thisBridgeHandler.thisBridge)) {
                                 LOGGER.trace("handleCommand(): actuator position will be updated via polling.");
                             }
-                            if (existingProducts.update(((SCrunProductCommand) bcp).getProduct())) {
+                            if (existingProducts.update(productCommand.getProduct())) {
                                 LOGGER.trace("handleCommand(): actuator position immediate update requested.");
                             }
                         }
index 5d096d02f84e2fc44db459ecbee566d9652b3c8b..4e009a9d551223a9e79755eaa8a79cb1b1dd8767 100644 (file)
@@ -1029,8 +1029,8 @@ public class VeluxBridgeHandler extends ExtendedBaseBridgeHandler implements Vel
     private void updateDynamicChannels() {
         getThing().getThings().stream().forEach(thing -> {
             ThingHandler thingHandler = thing.getHandler();
-            if (thingHandler instanceof VeluxHandler) {
-                ((VeluxHandler) thingHandler).updateDynamicChannels(this);
+            if (thingHandler instanceof VeluxHandler veluxHandler) {
+                veluxHandler.updateDynamicChannels(this);
             }
         });
     }
index 6d8e30cb6ef27a12392f963dcd41a88b41dbd678..e885112aced50dfcfea9976c49dc2965953b87c7 100644 (file)
@@ -68,7 +68,7 @@ public class VeluxProduct {
      *
      * @author AndrewFG - Initial contribution.
      */
-    public static enum ProductState {
+    public enum ProductState {
         NON_EXECUTING(0),
         ERROR(1),
         NOT_USED(2),
@@ -137,9 +137,9 @@ public class VeluxProduct {
      *
      * @author AndrewFG - Initial contribution.
      */
-    public static enum DataSource {
+    public enum DataSource {
         GATEWAY,
-        BINDING;
+        BINDING
     }
 
     // Class internal
index 851e277b1f7a26000626cb19de56ff3ecf15e65f..77dbaa9cbee65135483afe931f2e41bade9ccb17 100644 (file)
@@ -73,7 +73,7 @@ public class VeluxProductPosition {
      *
      * @author AndrewFG - Initial contribution.
      */
-    public static enum PositionType {
+    public enum PositionType {
         ABSOLUTE_VALUE(0f),
         OFFSET_POSITIVE(1f),
         OFFSET_NEGATIVE(-1f);
index a8ba69e4cafaa89f36c269c3be5576bd88e1c057..1a4dfb32432e6e2ec6b6dcc9c649f89d32786723 100644 (file)
@@ -44,7 +44,7 @@ public enum VeluxProductType {
     SWITCH,
     UNDEFTYPE;
 
-    public static enum ActuatorType {
+    public enum ActuatorType {
         UNDEFTYPE((short) 0xffff, VeluxBindingConstants.UNKNOWN, VeluxProductType.SWITCH),
         BLIND_1_0((short) 0x0040, "Interior Venetian Blind", VeluxProductType.SLIDER_SHUTTER),
         ROLLERSHUTTER_2_0((short) 0x0080, "Roller Shutter", VeluxProductType.SLIDER_SHUTTER),
index 9b7174634c1c5fcb020c92b1589e3d021013b0f7..da69b6ead8846d4daac5f38bd5366bfde8931d72 100644 (file)
@@ -49,8 +49,6 @@ public class ManifestInformation {
      * @return <B>bundleVersion</B> the resulted bundle version as {@link String}.
      */
     public static String getBundleVersion() {
-        String osgiBundleVersion = FrameworkUtil.getBundle(ManifestInformation.class).getBundleContext().getBundle()
-                .toString();
-        return osgiBundleVersion;
+        return FrameworkUtil.getBundle(ManifestInformation.class).getBundleContext().getBundle().toString();
     }
 }
index 6efce926347c3028dc35fe3aa95aac25e5449310..9260e56a9f3db4582e1618d02bb4a7cf7701e24a 100644 (file)
@@ -107,10 +107,12 @@ public class TestNotificationsAndDatabase {
     @Order(3)
     public void testSCgetProduct() {
         // initialise the test parameters
-        final String packet = "06 00 06 00 48 6F 62 62 79 6B 61 6D 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 01 04 40 00 00 00 00 00 00 00 00 00 00 00 00 00 2D C8 00 C8 00 F7 FF F7 FF 00 00 F7 FF 00"
-                + " 00 4F 00 4A EA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
+        final String packet = """
+                06 00 06 00 48 6F 62 62 79 6B 61 6D 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 01 04 40 00 00 00 00 00 00 00 00 00 00 00 00 00 2D C8 00 C8 00 F7 FF F7 FF 00 00 F7 FF 00\
+                 00 4F 00 4A EA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                """;
         final Command command = VeluxKLFAPI.Command.GW_GET_NODE_INFORMATION_NTF;
 
         // initialise the BCP
@@ -198,8 +200,10 @@ public class TestNotificationsAndDatabase {
     @Order(5)
     public void testSCgetProductStatus() {
         // initialise the test parameters
-        final String packet = "00 D8 01 06 00 01 01 02 00 C8 00 03 63 4F 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
+        final String packet = """
+                00 D8 01 06 00 01 01 02 00 C8 00 03 63 4F 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                """;
         final Command command = VeluxKLFAPI.Command.GW_STATUS_REQUEST_NTF;
 
         // initialise the BCP
@@ -334,10 +338,12 @@ public class TestNotificationsAndDatabase {
     @Order(9)
     public void testSCgetProductOnVelux() {
         // initialise the test parameters
-        final String packet = "00 00 00 00 53 68 65 64 20 57 69 6E 64 6F 77 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 01 01 01 03 07 00 01 16 56 24 5C 26 14 19 00 FC 05 46 00 46 00 F7 FF F7"
-                + " FF F7 FF F7 FF 00 00 4F 05 B3 5F 01 D8 03 B2 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
+        final String packet = """
+                00 00 00 00 53 68 65 64 20 57 69 6E 64 6F 77 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 01 01 01 03 07 00 01 16 56 24 5C 26 14 19 00 FC 05 46 00 46 00 F7 FF F7\
+                 FF F7 FF F7 FF 00 00 4F 05 B3 5F 01 D8 03 B2 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                """;
         final short command = VeluxKLFAPI.Command.GW_GET_NODE_INFORMATION_NTF.getShort();
 
         // initialise the BCP
@@ -454,9 +460,11 @@ public class TestNotificationsAndDatabase {
     @Test
     @Order(12)
     public void testSCrunProductA() {
-        final String expectedString = "02 1C 08 05 00 20 00 90 00 00 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00";
+        final String expectedString = """
+                02 1C 08 05 00 20 00 90 00 00 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00\
+                """;
         final byte[] expectedPacket = toByteArray(expectedString);
         final int targetMainPosition = 0x9000;
         final int targetVanePosition = 0xA000;
@@ -885,9 +893,11 @@ public class TestNotificationsAndDatabase {
     @Order(21)
     public void testErrorStateMapping() {
         // initialise the test parameters
-        final String packet = "0F A3 01 06 01 00 01 02 00 9A 36 03 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
-                + " 00 00 00 00 00";
+        final String packet = """
+                0F A3 01 06 01 00 01 02 00 9A 36 03 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
+                 00 00 00 00 00\
+                """;
         final Command command = VeluxKLFAPI.Command.GW_STATUS_REQUEST_NTF;
 
         // initialise the BCP
index e4c330e0f8dfb57631636192040734e3ea95407f..ca0773cb77b2981b2ddfcbaff7326d67c7c2135f 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.venstarthermostat.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -34,7 +33,7 @@ public class VenstarThermostatBindingConstants {
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_COLOR_TOUCH = new ThingTypeUID(BINDING_ID, "colorTouchThermostat");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_COLOR_TOUCH);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_COLOR_TOUCH);
     // List of all Channel ids
     public static final String CHANNEL_TEMPERATURE = "temperature";
     public static final String CHANNEL_HUMIDITY = "humidity";
index 0184e7d8d74a70034063e3b212014d21a1c89374..9fe49e1dc08a2fb4e2481b3323d4b8f1f6e686fa 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.venstarthermostat.internal;
 
 import static org.openhab.binding.venstarthermostat.internal.VenstarThermostatBindingConstants.THING_TYPE_COLOR_TOUCH;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -37,7 +36,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.venstarthermostat")
 public class VenstarThermostatHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_COLOR_TOUCH);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COLOR_TOUCH);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 7a9c3631b7f3c234ef45a6851af9b3e37659dbd4..7aea198193d7bbb678e338f429ce2829d171cea9 100644 (file)
@@ -53,8 +53,13 @@ import org.slf4j.LoggerFactory;
 @Component(service = DiscoveryService.class, configurationPid = "discovery.venstarthermostat")
 public class VenstarThermostatDiscoveryService extends AbstractDiscoveryService {
     private final Logger logger = LoggerFactory.getLogger(VenstarThermostatDiscoveryService.class);
-    private static final String COLOR_TOUCH_DISCOVERY_MESSAGE = "M-SEARCH * HTTP/1.1\r\n"
-            + "Host: 239.255.255.250:1900\r\n" + "Man: ssdp:discover\r\n" + "ST: colortouch:ecp\r\n" + "\r\n";
+    private static final String COLOR_TOUCH_DISCOVERY_MESSAGE = """
+            M-SEARCH * HTTP/1.1
+            Host: 239.255.255.250:1900
+            Man: ssdp:discover
+            ST: colortouch:ecp
+
+            """;
     private static final Pattern USN_PATTERN = Pattern
             .compile("^(colortouch:)?ecp((?::[0-9a-fA-F]{2}){6}):name:(.+)(?::type:(\\w+))");
     private static final String SSDP_MATCH = "colortouch:ecp";
index e8e71919f50408caa73af6b62d79cabc7c726fcf..e2fa62fd568787abf07c51e2a9364312bcac9d43 100644 (file)
@@ -29,7 +29,6 @@ public class VenstarFanStateSerializer implements JsonDeserializer<VenstarFanSta
     @Override
     public VenstarFanState deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
             throws JsonParseException {
-
         int key = element.getAsInt();
         try {
             return VenstarFanState.fromInt(key);
index 7dc53c48a2f3e499f04ddc09b737b57fb6617e96..57a8333da2159eeb1563a0801b19a79dcb95222a 100644 (file)
@@ -188,8 +188,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             } else if (channelUID.getId().equals(CHANNEL_SYSTEM_MODE)) {
                 VenstarSystemMode value;
                 try {
-                    if (command instanceof StringType) {
-                        value = VenstarSystemMode.valueOf(((StringType) command).toString().toUpperCase());
+                    if (command instanceof StringType stringCommand) {
+                        value = VenstarSystemMode.valueOf(stringCommand.toString().toUpperCase());
                     } else {
                         value = VenstarSystemMode.fromInt(((DecimalType) command).intValue());
                     }
@@ -202,8 +202,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             } else if (channelUID.getId().equals(CHANNEL_AWAY_MODE)) {
                 VenstarAwayMode value;
                 try {
-                    if (command instanceof StringType) {
-                        value = VenstarAwayMode.valueOf(((StringType) command).toString().toUpperCase());
+                    if (command instanceof StringType stringCommand) {
+                        value = VenstarAwayMode.valueOf(stringCommand.toString().toUpperCase());
                     } else {
                         value = VenstarAwayMode.fromInt(((DecimalType) command).intValue());
                     }
@@ -217,8 +217,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             } else if (channelUID.getId().equals(CHANNEL_FAN_MODE)) {
                 VenstarFanMode value;
                 try {
-                    if (command instanceof StringType) {
-                        value = VenstarFanMode.valueOf(((StringType) command).toString().toUpperCase());
+                    if (command instanceof StringType stringCommand) {
+                        value = VenstarFanMode.valueOf(stringCommand.toString().toUpperCase());
                     } else {
                         value = VenstarFanMode.fromInt(((DecimalType) command).intValue());
                     }
@@ -231,8 +231,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             } else if (channelUID.getId().equals(CHANNEL_SCHEDULE_MODE)) {
                 VenstarScheduleMode value;
                 try {
-                    if (command instanceof StringType) {
-                        value = VenstarScheduleMode.valueOf(((StringType) command).toString().toUpperCase());
+                    if (command instanceof StringType stringCommand) {
+                        value = VenstarScheduleMode.valueOf(stringCommand.toString().toUpperCase());
                     } else {
                         value = VenstarScheduleMode.fromInt(((DecimalType) command).intValue());
                     }
@@ -325,7 +325,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
 
     private State getTemperature() {
         Optional<VenstarSensor> optSensor = sensorData.stream()
-                .filter(sensor -> sensor.getName().equalsIgnoreCase("Thermostat")).findAny();
+                .filter(sensor -> "Thermostat".equalsIgnoreCase(sensor.getName())).findAny();
         if (optSensor.isPresent()) {
             return new QuantityType<Temperature>(optSensor.get().getTemp(), unitSystem);
         }
@@ -335,7 +335,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
 
     private State getHumidity() {
         Optional<VenstarSensor> optSensor = sensorData.stream()
-                .filter(sensor -> sensor.getName().equalsIgnoreCase("Thermostat")).findAny();
+                .filter(sensor -> "Thermostat".equalsIgnoreCase(sensor.getName())).findAny();
         if (optSensor.isPresent()) {
             return new QuantityType<Dimensionless>(optSensor.get().getHum(), Units.PERCENT);
         }
@@ -345,7 +345,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
 
     private State getOutdoorTemperature() {
         Optional<VenstarSensor> optSensor = sensorData.stream()
-                .filter(sensor -> sensor.getName().equalsIgnoreCase("Outdoor")).findAny();
+                .filter(sensor -> "Outdoor".equalsIgnoreCase(sensor.getName())).findAny();
         if (optSensor.isPresent()) {
             return new QuantityType<Temperature>(optSensor.get().getTemp(), unitSystem);
         }
@@ -432,8 +432,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
         ZoneId zoneId = ZoneId.systemDefault();
         ZonedDateTime now = LocalDateTime.now().atZone(zoneId);
         int diff = now.getOffset().getTotalSeconds();
-        ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp() - diff), zoneId);
-        return z;
+        return ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp() - diff), zoneId);
     }
 
     private void updateScheduleMode(VenstarScheduleMode schedule) {
@@ -634,8 +633,8 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
     }
 
     protected DecimalType commandToDecimalType(Command command) {
-        if (command instanceof DecimalType) {
-            return (DecimalType) command;
+        if (command instanceof DecimalType decimalCommand) {
+            return decimalCommand;
         }
         return new DecimalType(new BigDecimal(command.toString()));
     }
index 638fb8b183b79099b6451490122ece817479a785..479da6f850c42cdfa5ee5e5806b0c20455b98c15 100644 (file)
@@ -110,7 +110,6 @@ public class Communicator {
                 }
             }
             br.close();
-            socket.close();
         } catch (IOException e) {
             callback.communicationProblem();
         }
@@ -150,7 +149,6 @@ public class Communicator {
             logger.debug("sendingArray: {}", Arrays.toString(dataToSend));
 
             output.write(dataToSend);
-            socket.close();
         }
     }
 
index 4c08b334cab738f7f1024ada29cf735911dce828..21b27c74003d15633672423ba721a1a2d6f660d1 100644 (file)
@@ -92,20 +92,20 @@ public class VentaThingHandler extends BaseThingHandler {
                 }
                 break;
             case VentaAirBindingConstants.CHANNEL_FAN_SPEED:
-                if (command instanceof DecimalType) {
-                    int fanStage = ((DecimalType) command).intValue();
+                if (command instanceof DecimalType decimalCommand) {
+                    int fanStage = decimalCommand.intValue();
                     dispatchActionToDevice(new FanAction(fanStage));
                 }
                 break;
             case VentaAirBindingConstants.CHANNEL_TARGET_HUMIDITY:
-                if (command instanceof DecimalType) {
-                    int targetHumidity = ((DecimalType) command).intValue();
+                if (command instanceof DecimalType decimalCommand) {
+                    int targetHumidity = decimalCommand.intValue();
                     dispatchActionToDevice(new HumidityAction(targetHumidity));
                 }
                 break;
             case VentaAirBindingConstants.CHANNEL_TIMER:
-                if (command instanceof DecimalType) {
-                    int timer = ((DecimalType) command).intValue();
+                if (command instanceof DecimalType decimalCommand) {
+                    int timer = decimalCommand.intValue();
                     dispatchActionToDevice(new TimerAction(timer));
                 }
                 break;
index 771e862d31b411f75b8a8db98c8a8804d3f6cc4b..7433d1a14ecc9f849385a6c51741709a291a327d 100644 (file)
@@ -18,7 +18,6 @@ import java.net.DatagramSocket;
 import java.net.SocketException;
 import java.nio.charset.StandardCharsets;
 import java.time.Duration;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
@@ -53,8 +52,8 @@ import com.google.gson.JsonSyntaxException;
 @Component(service = DiscoveryService.class, configurationPid = "discovery.ventaair")
 public class VentaDeviceDiscovery extends AbstractDiscoveryService {
     private static final String REPRESENTATION_PROPERTY = "macAddress";
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(VentaAirBindingConstants.THING_TYPE_LW60T);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(VentaAirBindingConstants.THING_TYPE_LW60T);
     // defined as int, because AbstractDiscoveryService wants and int and not long as provided by Duration.getSeconds()
     private static final int MANUAL_DISCOVERY_TIME = 30;
     private static final Duration TIME_BETWEEN_SCANS = Duration.ofSeconds(30);
index 3381938b680a36cfaa2ec27c8ac24a145a9179db..3b892cc3a1a811cb5d9b7bd2fe4246b0afaf4969 100644 (file)
@@ -761,7 +761,7 @@ public class VerisureSession {
                         if (deviceId != null) {
                             deviceId = VerisureThingConfiguration.normalizeDeviceId(deviceId);
                             VerisureThingDTO mouseThing = verisureThings.get(deviceId);
-                            if (mouseThing != null && mouseThing instanceof VerisureMiceDetectionDTO) {
+                            if (mouseThing instanceof VerisureMiceDetectionDTO) {
                                 VerisureMiceDetectionDTO miceDetectorThing = (VerisureMiceDetectionDTO) mouseThing;
                                 miceDetectorThing.setTemperatureValue(climate.getTemperatureValue());
                                 miceDetectorThing.setTemperatureTime(climate.getTemperatureTimestamp());
index 878543256bde2baf882e91375b0b821cee356959..6d20e2243683584d3d9a09208dbb436c47b7aebd 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.verisure.internal.discovery;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -107,7 +107,7 @@ public class VerisureThingDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void activate() {
-        super.activate(Collections.singletonMap(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY, true));
+        super.activate(Map.of(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY, true));
     }
 
     @Override
@@ -117,8 +117,8 @@ public class VerisureThingDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VerisureBridgeHandler) {
-            verisureBridgeHandler = (VerisureBridgeHandler) handler;
+        if (handler instanceof VerisureBridgeHandler verisureBridgeHandler) {
+            this.verisureBridgeHandler = verisureBridgeHandler;
             bridgeUID = verisureBridgeHandler.getUID();
         }
     }
index 06f5ec5ded78326826984ea6c5bec5394a0b0ab4..61b97ae6bf34a5bb735b6a3ad7fc941d31abdd45 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -45,7 +44,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureAlarmThingHandler extends VerisureThingHandler<VerisureAlarmsDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_ALARM);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_ALARM);
 
     private static final int REFRESH_DELAY_SECONDS = 10;
 
@@ -143,7 +142,7 @@ public class VerisureAlarmThingHandler extends VerisureThingHandler<VerisureAlar
         String alarmStatus = armState.getStatusType();
         if (alarmStatus != null) {
             getThing().getChannels().stream().map(Channel::getUID)
-                    .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                    .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                     .forEach(channelUID -> {
                         State state = getValue(channelUID.getId(), armState);
                         updateState(channelUID, state);
index 28d2e6591b1070251ecee3ceed5b10a9ee5d7d87..2479cc7200382f45856cf799d6c2cba0aae234eb 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.verisure.internal.handler;
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.ScheduledFuture;
@@ -53,7 +52,7 @@ import org.slf4j.LoggerFactory;
 @NonNullByDefault
 public class VerisureBridgeHandler extends BaseBridgeHandler {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
 
     private static final int REFRESH_DELAY_SECONDS = 30;
     private final Logger logger = LoggerFactory.getLogger(VerisureBridgeHandler.class);
@@ -159,7 +158,7 @@ public class VerisureBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(VerisureThingDiscoveryService.class);
+        return Set.of(VerisureThingDiscoveryService.class);
     }
 
     private void refreshAndUpdateStatus() {
index 556189ad8dfdd7346aae77e5e21c1ebe7f7fdc38..487b2154af77388219e53fa082679cc81a9be89d 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.verisure.internal.handler;
 
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -34,8 +33,7 @@ import org.openhab.core.thing.ThingTypeUID;
 @NonNullByDefault
 public class VerisureBroadbandConnectionThingHandler extends VerisureThingHandler<VerisureBroadbandConnectionsDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections
-            .singleton(THING_TYPE_BROADBAND_CONNECTION);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BROADBAND_CONNECTION);
 
     public VerisureBroadbandConnectionThingHandler(Thing thing) {
         super(thing);
index a387be9a678cbb31fe035637a91b49876814d435..f6d4f18ec8e190f9cf5cba4dd26eee29a216cd2a 100644 (file)
@@ -71,7 +71,7 @@ public class VerisureClimateDeviceThingHandler extends VerisureThingHandler<Veri
 
     private void updateClimateDeviceState(VerisureClimatesDTO climateJSON) {
         getThing().getChannels().stream().map(Channel::getUID)
-                .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                 .forEach(channelUID -> {
                     State state = getValue(channelUID.getId(), climateJSON);
                     updateState(channelUID, state);
index 9a7571f3ad40aa129e50e682984496ee500614a7..075ec780ed1a456a263781da5d61234b826a6253 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.verisure.internal.handler;
 
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -41,7 +40,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureDoorWindowThingHandler extends VerisureThingHandler<VerisureDoorWindowsDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_DOORWINDOW);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_DOORWINDOW);
 
     public VerisureDoorWindowThingHandler(Thing thing) {
         super(thing);
@@ -64,7 +63,7 @@ public class VerisureDoorWindowThingHandler extends VerisureThingHandler<Verisur
             DoorWindow doorWindow = doorWindowList.get(0);
 
             getThing().getChannels().stream().map(Channel::getUID)
-                    .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                    .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                     .forEach(channelUID -> {
                         State state = getValue(channelUID.getId(), doorWindow, doorWindowJSON);
                         updateState(channelUID, state);
index 8b37c11c49a2a5aa75f814e23788f275a04af254..c29955ab9299fa1b7632538d8a69bcac640af76d 100644 (file)
@@ -51,7 +51,7 @@ public class VerisureEventLogThingHandler extends VerisureThingHandler<VerisureE
     private BigDecimal lastEventId = BigDecimal.ZERO;
     private long lastEventTime = 0;
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_EVENT_LOG);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_EVENT_LOG);
 
     public VerisureEventLogThingHandler(Thing thing) {
         super(thing);
@@ -83,7 +83,7 @@ public class VerisureEventLogThingHandler extends VerisureThingHandler<VerisureE
 
     private void updateEventLogState(VerisureEventLogDTO eventLogJSON) {
         EventLog eventLog = eventLogJSON.getData().getInstallation().getEventLog();
-        if (eventLog.getPagedList().size() > 0) {
+        if (!eventLog.getPagedList().isEmpty()) {
             getThing().getChannels().stream().map(Channel::getUID).filter(channelUID -> isLinked(channelUID))
                     .forEach(channelUID -> {
                         State state = getValue(channelUID.getId(), eventLogJSON, eventLog);
index 1f23c28eb6721f0d1178269c4b9cce83558c6938..a4e44caa6cca2975db6e0d27f5b75efbb43f825c 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.verisure.internal.handler;
 
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -38,7 +37,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureGatewayThingHandler extends VerisureThingHandler<VerisureGatewayDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_GATEWAY);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_GATEWAY);
 
     public VerisureGatewayThingHandler(Thing thing) {
         super(thing);
index 5ade277f913bf8692c0a80871679f1f37d800563..7ee00619733915aa60befe8faca5b59f105d30da 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.verisure.internal.handler;
 
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -46,7 +45,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureMiceDetectionThingHandler extends VerisureThingHandler<VerisureMiceDetectionDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_MICE_DETECTION);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MICE_DETECTION);
 
     public VerisureMiceDetectionThingHandler(Thing thing) {
         super(thing);
@@ -68,12 +67,12 @@ public class VerisureMiceDetectionThingHandler extends VerisureThingHandler<Veri
         if (!miceList.isEmpty()) {
             Mouse mouse = miceList.get(0);
             getThing().getChannels().stream().map(Channel::getUID).filter(channelUID -> isLinked(channelUID)
-                    && !channelUID.getId().equals("timestamp") && !channelUID.getId().equals("temperatureTimestamp"))
+                    && !"timestamp".equals(channelUID.getId()) && !"temperatureTimestamp".equals(channelUID.getId()))
                     .forEach(channelUID -> {
                         State state = getValue(channelUID.getId(), miceDetectionJSON, mouse);
                         updateState(channelUID, state);
                     });
-            if (mouse.getDetections().size() != 0) {
+            if (!mouse.getDetections().isEmpty()) {
                 updateTimeStamp(mouse.getDetections().get(0).getNodeTime());
             }
             updateTimeStamp(miceDetectionJSON.getTemperatureTime(), CHANNEL_TEMPERATURE_TIMESTAMP);
@@ -86,25 +85,25 @@ public class VerisureMiceDetectionThingHandler extends VerisureThingHandler<Veri
     public State getValue(String channelId, VerisureMiceDetectionDTO miceDetectionJSON, Mouse mouse) {
         switch (channelId) {
             case CHANNEL_COUNT_LATEST_DETECTION:
-                if (mouse.getDetections().size() == 0) {
+                if (mouse.getDetections().isEmpty()) {
                     return new DecimalType(0);
                 } else {
                     return new DecimalType(mouse.getDetections().get(0).getCount());
                 }
             case CHANNEL_COUNT_LAST_24_HOURS:
-                if (mouse.getDetections().size() == 0) {
+                if (mouse.getDetections().isEmpty()) {
                     return new DecimalType(0);
                 } else {
                     return new DecimalType(mouse.getDetections().stream().mapToInt(Detection::getCount).sum());
                 }
             case CHANNEL_DURATION_LATEST_DETECTION:
-                if (mouse.getDetections().size() == 0) {
+                if (mouse.getDetections().isEmpty()) {
                     return new QuantityType<Time>(0, Units.SECOND);
                 } else {
                     return new QuantityType<Time>(mouse.getDetections().get(0).getDuration(), Units.SECOND);
                 }
             case CHANNEL_DURATION_LAST_24_HOURS:
-                if (mouse.getDetections().size() == 0) {
+                if (mouse.getDetections().isEmpty()) {
                     return new QuantityType<Time>(0, Units.SECOND);
                 } else {
                     return new QuantityType<Time>(mouse.getDetections().stream().mapToInt(Detection::getDuration).sum(),
index 1d841fa6cdb858702b3e98e1532fe02a6b46b09b..7a2bd8e379cf3c2a6f8ef53d6bd9d0899194430b 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
@@ -51,7 +50,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureSmartLockThingHandler extends VerisureThingHandler<VerisureSmartLocksDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_SMARTLOCK);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_SMARTLOCK);
 
     private static final int REFRESH_DELAY_SECONDS = 10;
 
@@ -255,7 +254,7 @@ public class VerisureSmartLockThingHandler extends VerisureThingHandler<Verisure
             VerisureSmartLockDTO smartLockJSON = smartLocksJSON.getSmartLockJSON();
             if (smartLockStatus != null) {
                 getThing().getChannels().stream().map(Channel::getUID)
-                        .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                        .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                         .forEach(channelUID -> {
                             State state = getValue(channelUID.getId(), doorlock, smartLockStatus, smartLockJSON);
                             updateState(channelUID, state);
index 6d69be3b402ca2b96660e0cbc716eac990fe18d2..24aa871e6b1247879d5342bc0111585947d9c715 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -47,7 +46,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureSmartPlugThingHandler extends VerisureThingHandler<VerisureSmartPlugsDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_SMARTPLUG);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_SMARTPLUG);
 
     private static final int REFRESH_DELAY_SECONDS = 10;
 
@@ -132,7 +131,7 @@ public class VerisureSmartPlugThingHandler extends VerisureThingHandler<Verisure
             String smartPlugStatus = smartplug.getCurrentState();
             if (smartPlugStatus != null) {
                 getThing().getChannels().stream().map(Channel::getUID)
-                        .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                        .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                         .forEach(channelUID -> {
                             State state = getValue(channelUID.getId(), smartplug, smartPlugStatus);
                             updateState(channelUID, state);
index c7b48ae4812b6a494e84b99c8f32e8cbd29d20ea..d7fae4458ed56b41e36785a38485c36e92a09b71 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.verisure.internal.handler;
 
 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -38,7 +37,7 @@ import org.openhab.core.types.UnDefType;
 @NonNullByDefault
 public class VerisureUserPresenceThingHandler extends VerisureThingHandler<VerisureUserPresencesDTO> {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_USERPRESENCE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_USERPRESENCE);
 
     public VerisureUserPresenceThingHandler(Thing thing) {
         super(thing);
@@ -60,7 +59,7 @@ public class VerisureUserPresenceThingHandler extends VerisureThingHandler<Veris
         if (!userTrackingList.isEmpty()) {
             UserTracking userTracking = userTrackingList.get(0);
             getThing().getChannels().stream().map(Channel::getUID)
-                    .filter(channelUID -> isLinked(channelUID) && !channelUID.getId().equals("timestamp"))
+                    .filter(channelUID -> isLinked(channelUID) && !"timestamp".equals(channelUID.getId()))
                     .forEach(channelUID -> {
                         State state = getValue(channelUID.getId(), userTracking);
                         updateState(channelUID, state);
index bef2421582d1ee617f52f9a91d37e8e275b2eea3..4c6db2af2aad156340f9d6fe72793a351fe6d47a 100644 (file)
@@ -147,25 +147,21 @@ public class VeSyncV2ApiHelper {
         requestData.applyAuthentication(loggedInSession);
 
         // Apply specific addressing parameters
-        if (requestData instanceof VeSyncRequestManagedDeviceBypassV2) {
+        if (requestData instanceof VeSyncRequestManagedDeviceBypassV2 veSyncRequestManagedDeviceBypassV2) {
             final VeSyncManagedDeviceBase deviceData = macLookup.get(macId);
             if (deviceData == null) {
                 throw new DeviceUnknownException(String.format("Device not discovered with mac id: %s", macId));
             }
-            ((VeSyncRequestManagedDeviceBypassV2) requestData).cid = deviceData.cid;
-            ((VeSyncRequestManagedDeviceBypassV2) requestData).configModule = deviceData.configModule;
-            ((VeSyncRequestManagedDeviceBypassV2) requestData).deviceRegion = deviceData.deviceRegion;
+            veSyncRequestManagedDeviceBypassV2.cid = deviceData.cid;
+            veSyncRequestManagedDeviceBypassV2.configModule = deviceData.configModule;
+            veSyncRequestManagedDeviceBypassV2.deviceRegion = deviceData.deviceRegion;
         }
         return reqV1Authorized(url, requestData);
     }
 
     public String reqV1Authorized(final String url, final VeSyncAuthenticatedRequest requestData)
             throws AuthenticationException {
-        try {
-            return directReqV1Authorized(url, requestData);
-        } catch (final AuthenticationException ae) {
-            throw ae;
-        }
+        return directReqV1Authorized(url, requestData);
     }
 
     private String directReqV1Authorized(final String url, final VeSyncAuthenticatedRequest requestData)
index ec0e0c92ef85817a2e88f1f16c9abedf9231bd63..c6a413d3897c1a3d58ee3ecba9d309a6794cb8ab 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.vesync.internal.discovery;
 
 import static org.openhab.binding.vesync.internal.VeSyncConstants.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,7 @@ import org.osgi.service.component.annotations.Component;
 public class VeSyncDiscoveryService extends AbstractDiscoveryService
         implements DiscoveryService, ThingHandlerService, DeviceMetaDataUpdatedHandler {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
 
     private static final int DISCOVER_TIMEOUT_SECONDS = 5;
 
@@ -79,8 +78,8 @@ public class VeSyncDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VeSyncBridgeHandler) {
-            bridgeHandler = (VeSyncBridgeHandler) handler;
+        if (handler instanceof VeSyncBridgeHandler veSyncBridgeHandler) {
+            bridgeHandler = veSyncBridgeHandler;
             bridgeUID = bridgeHandler.getUID();
         }
     }
index 260a7df8588968ec485d4d1535ad488c65238650..53073b579c1c12e974d357fd1ad906c224ca8f92 100644 (file)
@@ -148,10 +148,9 @@ public abstract class VeSyncBaseDeviceHandler extends BaseThingHandler {
 
     protected boolean isDeviceOnline() {
         BridgeHandler bridgeHandler = getBridgeHandler();
-        if (bridgeHandler != null && bridgeHandler instanceof VeSyncBridgeHandler) {
-            VeSyncBridgeHandler vesyncBridgeHandler = (VeSyncBridgeHandler) bridgeHandler;
+        if (bridgeHandler instanceof VeSyncBridgeHandler veSyncBridgeHandler) {
             @Nullable
-            VeSyncManagedDeviceBase metadata = vesyncBridgeHandler.api.getMacLookupMap().get(deviceLookupKey);
+            VeSyncManagedDeviceBase metadata = veSyncBridgeHandler.api.getMacLookupMap().get(deviceLookupKey);
 
             if (metadata == null) {
                 return false;
@@ -166,10 +165,9 @@ public abstract class VeSyncBaseDeviceHandler extends BaseThingHandler {
         Map<String, String> newProps = null;
 
         BridgeHandler bridgeHandler = getBridgeHandler();
-        if (bridgeHandler != null && bridgeHandler instanceof VeSyncBridgeHandler) {
-            VeSyncBridgeHandler vesyncBridgeHandler = (VeSyncBridgeHandler) bridgeHandler;
+        if (bridgeHandler instanceof VeSyncBridgeHandler veSyncBridgeHandler) {
             @Nullable
-            VeSyncManagedDeviceBase metadata = vesyncBridgeHandler.api.getMacLookupMap().get(deviceLookupKey);
+            VeSyncManagedDeviceBase metadata = veSyncBridgeHandler.api.getMacLookupMap().get(deviceLookupKey);
 
             if (metadata == null) {
                 return;
@@ -248,8 +246,8 @@ public abstract class VeSyncBaseDeviceHandler extends BaseThingHandler {
                 return null;
             }
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof VeSyncClient) {
-                veSyncClient = (VeSyncClient) handler;
+            if (handler instanceof VeSyncClient client) {
+                veSyncClient = client;
             } else {
                 return null;
             }
@@ -260,8 +258,7 @@ public abstract class VeSyncBaseDeviceHandler extends BaseThingHandler {
     protected void requestBridgeFreqScanMetadataIfReq() {
         if (requiresMetaDataFrequentUpdates()) {
             BridgeHandler bridgeHandler = getBridgeHandler();
-            if (bridgeHandler != null && bridgeHandler instanceof VeSyncBridgeHandler) {
-                VeSyncBridgeHandler vesyncBridgeHandler = (VeSyncBridgeHandler) bridgeHandler;
+            if (bridgeHandler instanceof VeSyncBridgeHandler vesyncBridgeHandler) {
                 vesyncBridgeHandler.checkIfIncreaseScanRateRequired();
             }
         }
@@ -272,8 +269,7 @@ public abstract class VeSyncBaseDeviceHandler extends BaseThingHandler {
         final VeSyncDeviceConfiguration config = getConfigAs(VeSyncDeviceConfiguration.class);
 
         BridgeHandler bridgeHandler = getBridgeHandler();
-        if (bridgeHandler != null && bridgeHandler instanceof VeSyncBridgeHandler) {
-            VeSyncBridgeHandler vesyncBridgeHandler = (VeSyncBridgeHandler) bridgeHandler;
+        if (bridgeHandler instanceof VeSyncBridgeHandler vesyncBridgeHandler) {
 
             final String configMac = config.macId;
 
index bc12f8c2f058308f551c0302bfbfb7a28ba06983..1d830101f5c9097b5260291c2b9a3335cc5a9a46 100644 (file)
@@ -15,9 +15,9 @@ package org.openhab.binding.vesync.internal.handlers;
 import static org.openhab.binding.vesync.internal.VeSyncConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -86,8 +86,8 @@ public class VeSyncBridgeHandler extends BaseBridgeHandler implements VeSyncClie
         boolean frequentScanReq = false;
         for (Thing th : getThing().getThings()) {
             ThingHandler handler = th.getHandler();
-            if (handler instanceof VeSyncBaseDeviceHandler) {
-                if (((VeSyncBaseDeviceHandler) handler).requiresMetaDataFrequentUpdates()) {
+            if (handler instanceof VeSyncBaseDeviceHandler veSyncBaseDeviceHandler) {
+                if (veSyncBaseDeviceHandler.requiresMetaDataFrequentUpdates()) {
                     frequentScanReq = true;
                     break;
                 }
@@ -185,15 +185,15 @@ public class VeSyncBridgeHandler extends BaseBridgeHandler implements VeSyncClie
     }
 
     private void updateThing(VeSyncBridgeConfiguration config, @Nullable ThingHandler handler) {
-        if (handler instanceof VeSyncBaseDeviceHandler) {
-            ((VeSyncBaseDeviceHandler) handler).updateDeviceMetaData();
-            ((VeSyncBaseDeviceHandler) handler).updateBridgeBasedPolls(config);
+        if (handler instanceof VeSyncBaseDeviceHandler veSyncBaseDeviceHandler) {
+            veSyncBaseDeviceHandler.updateDeviceMetaData();
+            veSyncBaseDeviceHandler.updateBridgeBasedPolls(config);
         }
     }
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(VeSyncDiscoveryService.class);
+        return Set.of(VeSyncDiscoveryService.class);
     }
 
     @Override
@@ -240,6 +240,7 @@ public class VeSyncBridgeHandler extends BaseBridgeHandler implements VeSyncClie
         this.updateProperties(newProps);
     }
 
+    @Override
     public String reqV2Authorized(final String url, final String macId, final VeSyncAuthenticatedRequest requestData)
             throws AuthenticationException, DeviceUnknownException {
         return api.reqV2Authorized(url, macId, requestData);
index d3b2464c07923227d6f34e4d9fb39d029a6090ff..ec98c23dcabd1b45488eac4d16c8739b15c3ac4e 100644 (file)
@@ -174,10 +174,10 @@ public class VeSyncDeviceAirHumidifierHandler extends VeSyncBaseDeviceHandler {
                         logger.warn("Warm mode API is unknown in order to send the command");
                         break;
                 }
-            } else if (command instanceof QuantityType) {
+            } else if (command instanceof QuantityType quantityCommand) {
                 switch (channelUID.getId()) {
                     case DEVICE_CHANNEL_CONFIG_TARGET_HUMIDITY:
-                        int targetHumidity = ((QuantityType<?>) command).intValue();
+                        int targetHumidity = quantityCommand.intValue();
                         if (targetHumidity < 30) {
                             logger.warn("Target Humidity less than 30 - adjusting to 30 as the valid API value");
                             targetHumidity = 30;
@@ -193,7 +193,7 @@ public class VeSyncDeviceAirHumidifierHandler extends VeSyncBaseDeviceHandler {
                                 new VeSyncRequestManagedDeviceBypassV2.SetTargetHumidity(targetHumidity));
                         break;
                     case DEVICE_CHANNEL_MIST_LEVEL:
-                        int targetMistLevel = ((QuantityType<?>) command).intValue();
+                        int targetMistLevel = quantityCommand.intValue();
                         // If more devices have this the hope is it's those with the prefix LUH so the check can
                         // be simplified, originally devices mapped 1/5/9 to 1/2/3.
                         if (DEV_FAMILY_DUAL_200S.equals(deviceFamily)) {
index ab6d8ac8c0486c0e89102b58867db1b36a582c1b..bd80e4a67a8f44cb98425b31378a98b8d8f120a7 100644 (file)
@@ -234,14 +234,14 @@ public class VeSyncDeviceAirPurifierHandler extends VeSyncBaseDeviceHandler {
                         }
                         break;
                 }
-            } else if (command instanceof QuantityType) {
+            } else if (command instanceof QuantityType quantityCommand) {
                 switch (channelUID.getId()) {
                     case DEVICE_CHANNEL_FAN_SPEED_ENABLED:
                         // If the fan speed is being set enforce manual mode
                         sendV2BypassControlCommand(DEVICE_SET_PURIFIER_MODE,
                                 new VeSyncRequestManagedDeviceBypassV2.SetMode(MODE_MANUAL), false);
 
-                        int requestedLevel = ((QuantityType<?>) command).intValue();
+                        int requestedLevel = quantityCommand.intValue();
                         if (requestedLevel < 1) {
                             logger.warn("Fan speed command less than 1 - adjusting to 1 as the valid API value");
                             requestedLevel = 1;
index 499794cf74fb8a8a7fc560bf331cfa15c3e91269..3a326ac36b1aceb471ffdf012bcf0b8bfbbb3b96 100644 (file)
@@ -33,7 +33,7 @@ import org.openhab.binding.vesync.internal.dto.responses.VesyncLoginResponse;
 @NonNullByDefault
 public class VesyncAuthenticatedRequestTest {
 
-    public final static VesyncLoginResponse.VesyncUserSession testUser = VeSyncConstants.GSON.fromJson(
+    public static final VesyncLoginResponse.VesyncUserSession testUser = VeSyncConstants.GSON.fromJson(
             org.openhab.binding.vesync.internal.handler.responses.VesyncLoginResponseTest.testGoodLoginResponseBody,
             VesyncLoginResponse.class).result;
 
index daf401f8f2203634e49b4cc3ee9cacad437d2d63..f114c7c003dd5e33de78608cade760c93b96134b 100644 (file)
@@ -46,7 +46,7 @@ public class VesyncRequestManagedDeviceBypassV2Test {
     public void checkEmptyPayload() {
         final VesyncRequestManagedDeviceBypassV2.EmptyPayload testPaylaod = new VesyncRequestManagedDeviceBypassV2.EmptyPayload();
         final String contentTest1 = VeSyncConstants.GSON.toJson(testPaylaod);
-        assertEquals(true, contentTest1.equals("{}"));
+        assertEquals(true, "{}".equals(contentTest1));
     }
 
     @Test
index 31b53b1db4e50b4d191a4a5fb06009844d2f9c03..9f375209345002724e5f6532dbfdd3e54cf98db2 100644 (file)
@@ -27,26 +27,48 @@ import org.openhab.binding.vesync.internal.dto.responses.VesyncLoginResponse;
 @NonNullByDefault
 public class VesyncLoginResponseTest {
 
-    public final static String testGoodLoginResponseBody = "{\r\n" + "    \"traceId\": \"1634253816\",\r\n"
-            + "    \"code\": 0,\r\n" + "    \"msg\": \"request success\",\r\n" + "    \"result\": {\r\n"
-            + "        \"isRequiredVerify\": true,\r\n" + "        \"accountID\": \"5328043\",\r\n"
-            + "        \"avatarIcon\": \"https://image.vesync.com/defaultImages/user/avatar_nor.png\",\r\n"
-            + "        \"birthday\": \"\",\r\n" + "        \"gender\": \"\",\r\n"
-            + "        \"acceptLanguage\": \"en\",\r\n" + "        \"userType\": \"1\",\r\n"
-            + "        \"nickName\": \"david.goodyear\",\r\n" + "        \"mailConfirmation\": true,\r\n"
-            + "        \"termsStatus\": true,\r\n" + "        \"gdprStatus\": true,\r\n"
-            + "        \"countryCode\": \"GB\",\r\n" + "        \"registerAppVersion\": \"VeSync 3.1.37 build3\",\r\n"
-            + "        \"registerTime\": \"2021-10-14 17:35:50\",\r\n"
-            + "        \"verifyEmail\": \"david.goodyear@gmail.com\",\r\n" + "        \"heightCm\": 0.0,\r\n"
-            + "        \"weightTargetSt\": 0.0,\r\n" + "        \"heightUnit\": \"FT\",\r\n"
-            + "        \"heightFt\": 0.0,\r\n" + "        \"weightTargetKg\": 0.0,\r\n"
-            + "        \"weightTargetLb\": 0.0,\r\n" + "        \"weightUnit\": \"LB\",\r\n"
-            + "        \"targetBfr\": 0.0,\r\n" + "        \"displayFlag\": [],\r\n"
-            + "        \"real_weight_kg\": 0.0,\r\n" + "        \"real_weight_lb\": 0.0,\r\n"
-            + "        \"real_weight_unit\": \"lb\",\r\n" + "        \"heart_rate_zones\": 0.0,\r\n"
-            + "        \"run_step_long_cm\": 0.0,\r\n" + "        \"walk_step_long_cm\": 0.0,\r\n"
-            + "        \"step_target\": 0.0,\r\n" + "        \"sleep_target_mins\": 0.0,\r\n"
-            + "        \"token\": \"AccessTokenString=\"\r\n" + "    }\r\n" + "}";
+    public static final String testGoodLoginResponseBody = """
+            {
+                "traceId": "1634253816",
+                "code": 0,
+                "msg": "request success",
+                "result": {
+                    "isRequiredVerify": true,
+                    "accountID": "5328043",
+                    "avatarIcon": "https://image.vesync.com/defaultImages/user/avatar_nor.png",
+                    "birthday": "",
+                    "gender": "",
+                    "acceptLanguage": "en",
+                    "userType": "1",
+                    "nickName": "david.goodyear",
+                    "mailConfirmation": true,
+                    "termsStatus": true,
+                    "gdprStatus": true,
+                    "countryCode": "GB",
+                    "registerAppVersion": "VeSync 3.1.37 build3",
+                    "registerTime": "2021-10-14 17:35:50",
+                    "verifyEmail": "david.goodyear@gmail.com",
+                    "heightCm": 0.0,
+                    "weightTargetSt": 0.0,
+                    "heightUnit": "FT",
+                    "heightFt": 0.0,
+                    "weightTargetKg": 0.0,
+                    "weightTargetLb": 0.0,
+                    "weightUnit": "LB",
+                    "targetBfr": 0.0,
+                    "displayFlag": [],
+                    "real_weight_kg": 0.0,
+                    "real_weight_lb": 0.0,
+                    "real_weight_unit": "lb",
+                    "heart_rate_zones": 0.0,
+                    "run_step_long_cm": 0.0,
+                    "walk_step_long_cm": 0.0,
+                    "step_target": 0.0,
+                    "sleep_target_mins": 0.0,
+                    "token": "AccessTokenString="
+                }
+            }\
+            """;
 
     @Test
     public void testParseLoginGoodResponse() {
@@ -67,8 +89,14 @@ public class VesyncLoginResponseTest {
 
     @Test
     public void testParseLoginFailResponse() {
-        String testReponse = "{\r\n" + "    \"traceId\": \"1634253816\",\r\n" + "    \"code\": -11201022,\r\n"
-                + "    \"msg\": \"password incorrect\",\r\n" + "    \"result\": null\r\n" + "}";
+        String testReponse = """
+                {
+                    "traceId": "1634253816",
+                    "code": -11201022,
+                    "msg": "password incorrect",
+                    "result": null
+                }\
+                """;
         VesyncLoginResponse response = VeSyncConstants.GSON.fromJson(testReponse,
                 VesyncLoginResponse.class);
         if (response != null) {
index 9a3fac40a2b0c7d07d10c2c3d4d8bc69195bf817..94392d449bc3a06cac8044f4720e08c81ad39974 100644 (file)
@@ -28,46 +28,48 @@ import static org.junit.jupiter.api.Assertions.*;
 @NonNullByDefault
 public class VesyncManagedDevicesPageTest {
 
-    public final static String testGoodSearchResponsePageBody = "{\n" +
-            "    \"traceId\": \"1634387642\",\n" +
-            "    \"code\": 0,\n" +
-            "    \"msg\": \"request success\",\n" +
-            "    \"result\": {\n" +
-            "        \"total\": 2,\n" +
-            "        \"pageSize\": 100,\n" +
-            "        \"pageNo\": 1,\n" +
-            "        \"list\": [\n" +
-            "            {\n" +
-            "                \"deviceRegion\": \"EU\",\n" +
-            "                \"isOwner\": true,\n" +
-            "                \"authKey\": null,\n" +
-            "                \"deviceName\": \"Air Filter\",\n" +
-            "                \"deviceImg\": \"https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png\",\n" +
-            "                \"cid\": \"cidValue1\",\n" +
-            "                \"deviceStatus\": \"on\",\n" +
-            "                \"connectionStatus\": \"online\",\n" +
-            "                \"connectionType\": \"WiFi+BTOnboarding+BTNotify\",\n" +
-            "                \"deviceType\": \"Core400S\",\n" +
-            "                \"type\": \"wifi-air\",\n" +
-            "                \"uuid\": \"abcdefab-1234-1234-abcd-123498761234\",\n" +
-            "                \"configModule\": \"WiFiBTOnboardingNotify_AirPurifier_Core400S_EU\",\n" +
-            "                \"macID\": \"ab:cd:ef:12:34:56\",\n" +
-            "                \"mode\": \"simModeData\",\n" +
-            "                \"speed\": 4,\n" +
-            "                \"extension\": {\n" +
-            "                    \"airQuality\": -1,\n" +
-            "                    \"airQualityLevel\": 1,\n" +
-            "                    \"mode\": \"auto\",\n" +
-            "                    \"fanSpeedLevel\": \"1\"\n" +
-            "                },\n" +
-            "                \"currentFirmVersion\": null,\n" +
-            "                \"subDeviceNo\": \"simSubDevice\",\n" +
-            "                \"subDeviceType\": \"simSubDeviceType\",\n" +
-            "                \"deviceFirstSetupTime\": \"Oct 15, 2021 3:43:02 PM\"\n" +
-            "            }\n" +
-            "        ]\n" +
-            "    }\n" +
-            "}";
+    public static final String testGoodSearchResponsePageBody = """
+            {
+                "traceId": "1634387642",
+                "code": 0,
+                "msg": "request success",
+                "result": {
+                    "total": 2,
+                    "pageSize": 100,
+                    "pageNo": 1,
+                    "list": [
+                        {
+                            "deviceRegion": "EU",
+                            "isOwner": true,
+                            "authKey": null,
+                            "deviceName": "Air Filter",
+                            "deviceImg": "https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png",
+                            "cid": "cidValue1",
+                            "deviceStatus": "on",
+                            "connectionStatus": "online",
+                            "connectionType": "WiFi+BTOnboarding+BTNotify",
+                            "deviceType": "Core400S",
+                            "type": "wifi-air",
+                            "uuid": "abcdefab-1234-1234-abcd-123498761234",
+                            "configModule": "WiFiBTOnboardingNotify_AirPurifier_Core400S_EU",
+                            "macID": "ab:cd:ef:12:34:56",
+                            "mode": "simModeData",
+                            "speed": 4,
+                            "extension": {
+                                "airQuality": -1,
+                                "airQualityLevel": 1,
+                                "mode": "auto",
+                                "fanSpeedLevel": "1"
+                            },
+                            "currentFirmVersion": null,
+                            "subDeviceNo": "simSubDevice",
+                            "subDeviceType": "simSubDeviceType",
+                            "deviceFirstSetupTime": "Oct 15, 2021 3:43:02 PM"
+                        }
+                    ]
+                }
+            }\
+            """;
 
     @Test
     public void testParseManagedDevicesSearchGoodResponse() {
index 6ed1d2699cdeb92569a580cc64ff2c85019a44d6..ff94d7d5ba5ff2166d86805a8878e70e17445bf9 100644 (file)
@@ -29,21 +29,23 @@ import static org.junit.jupiter.api.Assertions.fail;
 @NonNullByDefault
 public class VesyncV1AirPurifierDeviceDetailsTest {
 
-    public final static String testAirPurifierResponseBasedOnCore400S = "{\n" +
-            "    \"code\": 0,\n" +
-            "    \"msg\": \"request success\",\n" +
-            "    \"traceId\": \"1634255391\",\n" +
-            "    \"screenStatus\": \"on1\",\n" +
-            "    \"airQuality\": 1,\n" +
-            "    \"level\": 2,\n" +
-            "    \"mode\": \"manual\",\n" +
-            "    \"deviceName\": \"Lounge Air Purifier\",\n" +
-            "    \"currentFirmVersion\": \"1.0.17\",\n" +
-            "    \"childLock\": \"off1\",\n" +
-            "    \"deviceStatus\": \"on2\",\n" +
-            "    \"deviceImg\": \"https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png\",\n" +
-            "    \"connectionStatus\": \"online\"\n" +
-            "}";
+    public static final String testAirPurifierResponseBasedOnCore400S = """
+            {
+                "code": 0,
+                "msg": "request success",
+                "traceId": "1634255391",
+                "screenStatus": "on1",
+                "airQuality": 1,
+                "level": 2,
+                "mode": "manual",
+                "deviceName": "Lounge Air Purifier",
+                "currentFirmVersion": "1.0.17",
+                "childLock": "off1",
+                "deviceStatus": "on2",
+                "deviceImg": "https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png",
+                "connectionStatus": "online"
+            }\
+            """;
 
     @Test
     public void testParseV1AirPurifierDeviceDetailsResponse() {
index 6f51407f8d2cfc3a0f5bbb8dba3bb206b26f46ab..6569776d3eaf2c117852ebcfe080d21127ceea0f 100644 (file)
@@ -74,6 +74,5 @@ public class VitotronicBindingConstants {
                     THING_TYPE_UID_TEMPERATURESENSOR, THING_TYPE_UID_PUMP, THING_TYPE_UID_VALVE)
             .collect(Collectors.toSet()));
 
-    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS = Collections
-            .singleton(THING_TYPE_UID_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS = Set.of(THING_TYPE_UID_BRIDGE);
 }
index 9e75cb8bec0e066c136a507a66432bed32f96cbb..ded88051d3724078c990033daef8df77b2620ca5 100644 (file)
@@ -82,8 +82,8 @@ public class VitotronicThingHandler extends BaseThingHandler {
         VitotronicBridgeHandler bridgeHandler = null;
 
         ThingHandler handler = bridge.getHandler();
-        if (handler instanceof VitotronicBridgeHandler) {
-            bridgeHandler = (VitotronicBridgeHandler) handler;
+        if (handler instanceof VitotronicBridgeHandler vitotronicBridgeHandler) {
+            bridgeHandler = vitotronicBridgeHandler;
         } else {
             logger.debug("No available bridge handler found yet. Bridge: {} .", bridge.getUID());
             bridgeHandler = null;
index b07d62e2fadb466308f2954e6da9589daf6abd61..8a80c82022cb962d4fd59e73c14edb9bddc333ac 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.vizio.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@ public class VizioBindingConstants {
 
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_VIZIO_TV = new ThingTypeUID(BINDING_ID, "vizio_tv");
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_VIZIO_TV);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_VIZIO_TV);
 
     // List of all Channel id's
     public static final String POWER = "power";
index 2246218deea24be97569e86c9948ab96ca7d034f..e13c62754d953fd36e1b1e1056b6de5f17172b1a 100644 (file)
@@ -61,8 +61,7 @@ public class VizioHandlerFactory extends BaseThingHandlerFactory {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
         if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
-            VizioHandler handler = new VizioHandler(thing, httpClientFactory, stateDescriptionProvider, vizioAppsJson);
-            return handler;
+            return new VizioHandler(thing, httpClientFactory, stateDescriptionProvider, vizioAppsJson);
         }
 
         return null;
index f9d0b60ac319815320efa3695c97588d3ea4ed94..9e63eb4390cdc5e452928f57b9fe737c32bf8873 100644 (file)
@@ -65,8 +65,8 @@ public class VizioCommandExtension extends AbstractConsoleCommandExtension {
             VizioHandler handler = null;
             if (thing != null) {
                 thingHandler = thing.getHandler();
-                if (thingHandler instanceof VizioHandler) {
-                    handler = (VizioHandler) thingHandler;
+                if (thingHandler instanceof VizioHandler vizioHandler) {
+                    handler = vizioHandler;
                 }
             }
             if (thing == null) {
index 778e2654fd8873495d69f8e98561bdf246d0cf9a..0d5ddbb266a580866899f66a3893f85366d8709e 100644 (file)
@@ -31,13 +31,13 @@ public class VolvoOnCallException extends Exception {
     private final Logger logger = LoggerFactory.getLogger(VolvoOnCallException.class);
     private static final long serialVersionUID = -6215621577081394328L;
 
-    public static enum ErrorType {
+    public enum ErrorType {
         UNKNOWN,
         SERVICE_UNAVAILABLE,
         SERVICE_UNABLE_TO_START,
         IOEXCEPTION,
         INTERRUPTED,
-        JSON_SYNTAX;
+        JSON_SYNTAX
     }
 
     private final ErrorType cause;
index 15d37c9d9a9cb073437952fa011f4b9319bf24e5..40a786056900e88c306c5f4ef5fca2f95d705d75 100644 (file)
@@ -46,8 +46,8 @@ public class VolvoOnCallActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VehicleHandler) {
-            this.handler = (VehicleHandler) handler;
+        if (handler instanceof VehicleHandler vehicleHandler) {
+            this.handler = vehicleHandler;
         }
     }
 
index 74b98c9b1dfb126efe8728383eec47d99b48726e..75bd04079e9aec916a4096a1415951b8c0d1c440 100644 (file)
@@ -52,8 +52,8 @@ public class VolvoVehicleDiscoveryService extends AbstractDiscoveryService imple
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof VolvoOnCallBridgeHandler) {
-            this.handler = (VolvoOnCallBridgeHandler) handler;
+        if (handler instanceof VolvoOnCallBridgeHandler volvoOnCallBridgeHandler) {
+            this.handler = volvoOnCallBridgeHandler;
         }
     }
 
@@ -104,7 +104,6 @@ public class VolvoVehicleDiscoveryService extends AbstractDiscoveryService imple
                     logger.warn("Error while discovering vehicle: {}", e.getMessage());
                 }
             }
-            ;
         }
         stopScan();
     }
index a0f5cd87f911eee51f1962d29663d877d9cb37b9..1d23279151867bca4c4a4263b4395c0a1c94da8a 100644 (file)
@@ -27,7 +27,7 @@ import com.google.gson.annotations.SerializedName;
 @NonNullByDefault
 public class PostResponse extends VocAnswer {
 
-    public static enum Status {
+    public enum Status {
         @SerializedName("Started")
         STARTED,
         @SerializedName("MessageDelivered")
@@ -38,7 +38,7 @@ public class PostResponse extends VocAnswer {
         SUCCESSFULL
     }
 
-    public static enum ServiceType {
+    public enum ServiceType {
         RHBLF, // Remote Honk and Blink Lights ?
         RDU, // Remote door unlock
         ERS, // Remote engine start
index 3ed489c9067f18b1e0f8acf1fe33238ccf3e8b3a..ae8da71b0ffafe9759115cbfe87b14de7dd9c3c6 100644 (file)
@@ -38,7 +38,7 @@ public class Status extends VocAnswer {
         LOW,
         @SerializedName("VeryLow")
         VERY_LOW,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public double averageFuelConsumption = UNDEFINED;
index 1b2fac2226ddeae6518116d783f7b4c75d8bf578..7e07beaca5bd311e2ce90b7d4a75ee9a573bd8ce 100644 (file)
@@ -30,7 +30,7 @@ public class TyrePressure {
         NORMAL,
         @SerializedName("LowSoft")
         LOW_SOFT,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public PressureLevel frontLeftTyrePressure = PressureLevel.UNKNOWN;
index 2ad496041be76ccb53505026c5904322aefb324f..ec6194fdc99872e9bb262fa00645b3b73d50c847 100644 (file)
@@ -272,8 +272,7 @@ public class VehicleHandler extends BaseThingHandler {
             if (api != null) {
                 queryApiAndUpdateChannels(api);
             }
-        } else if (command instanceof OnOffType) {
-            OnOffType onOffCommand = (OnOffType) command;
+        } else if (command instanceof OnOffType onOffCommand) {
             if (ENGINE_START.equals(channelID) && onOffCommand == OnOffType.ON) {
                 actionStart(5);
             } else if (REMOTE_HEATER.equals(channelID) || PRECLIMATIZATION.equals(channelID)) {
@@ -549,7 +548,7 @@ public class VehicleHandler extends BaseThingHandler {
         VocHttpApi api = bridgeHandler.getApi();
         if (api != null) {
             try {
-                PostResponse postResponse = api.postURL(url.toString(), param);
+                PostResponse postResponse = api.postURL(url, param);
                 if (postResponse != null) {
                     pendingActions
                             .add(scheduler.schedule(new ActionResultController(api, postResponse, scheduler, this),
@@ -560,13 +559,12 @@ public class VehicleHandler extends BaseThingHandler {
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
             }
         }
-        ;
         pendingActions.removeIf(ScheduledFuture::isDone);
     }
 
     public void actionOpenClose(String action, OnOffType controlState) {
         if (activeOptions.containsKey(action)) {
-            if (!vehicleStatus.getCarLocked().isPresent() || vehicleStatus.getCarLocked().get() != controlState) {
+            if (vehicleStatus.getCarLocked().isEmpty() || vehicleStatus.getCarLocked().get() != controlState) {
                 post(String.format("vehicles/%s/%s", configuration.vin, action), "{}");
             } else {
                 logger.info("The car {} is already {}ed", configuration.vin, action);
@@ -599,6 +597,6 @@ public class VehicleHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(VolvoOnCallActions.class);
+        return List.of(VolvoOnCallActions.class);
     }
 }
index a255302b53e69fc7b799f2b83e998606a1dd65ad..e5ade7c8a1717777f2b5a16a1fdae55ac9fe9121 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.volvooncall.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -97,7 +97,7 @@ public class VolvoOnCallBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(VolvoVehicleDiscoveryService.class);
+        return Set.of(VolvoVehicleDiscoveryService.class);
     }
 
     @Override
index f67fa58324e6a093c6051323abe2b9286fbf4146..42d85cc182096f1ffa10941a5df1c4a1fad3ddbb 100644 (file)
@@ -87,7 +87,7 @@ public class MyWarmupApi {
 
         AuthResponseDTO ar = GSON.fromJson(response.getContentAsString(), AuthResponseDTO.class);
 
-        if (ar != null && ar.getStatus() != null && ar.getStatus().getResult().equals("success")) {
+        if (ar != null && ar.getStatus() != null && "success".equals(ar.getStatus().getResult())) {
             authToken = ar.getResponse().getToken();
         } else {
             throw new MyWarmupApiException("Authentication Failed");
@@ -101,9 +101,11 @@ public class MyWarmupApi {
      * @throws MyWarmupApiException API callout error
      */
     public synchronized QueryResponseDTO getStatus() throws MyWarmupApiException {
-        return callWarmupGraphQL("query QUERY { user { locations{ id name "
-                + " rooms { id roomName runMode overrideDur targetTemp currentTemp "
-                + " thermostat4ies{ deviceSN lastPoll }}}}}");
+        return callWarmupGraphQL("""
+                query QUERY { user { locations{ id name \
+                 rooms { id roomName runMode overrideDur targetTemp currentTemp \
+                 thermostat4ies{ deviceSN lastPoll }}}}}\
+                """);
     }
 
     /**
@@ -142,7 +144,7 @@ public class MyWarmupApi {
 
         QueryResponseDTO qr = GSON.fromJson(response.getContentAsString(), QueryResponseDTO.class);
 
-        if (qr != null && qr.getStatus().equals("success")) {
+        if (qr != null && "success".equals(qr.getStatus())) {
             return qr;
         } else {
             throw new MyWarmupApiException("Unexpected reponse from API");
index a090bbe391251338dbe26518b0efeb676f8f6494..a49cd5027699fbd4725ae9f8932a11dd3fa1b970 100644 (file)
@@ -103,8 +103,8 @@ public class WarmupDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable final ThingHandler handler) {
-        if (handler instanceof MyWarmupAccountHandler) {
-            bridgeHandler = (MyWarmupAccountHandler) handler;
+        if (handler instanceof MyWarmupAccountHandler accountHandler) {
+            bridgeHandler = accountHandler;
             bridgeUID = handler.getThing().getUID();
         } else {
             bridgeHandler = null;
index 15a254c034cb41ad7d2eedf93e828ba8f53a4c74..f46aadeeb312af82d46fa896f53f1d662a3ab6af 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.warmup.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -70,7 +70,7 @@ public class MyWarmupAccountHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(WarmupDiscoveryService.class);
+        return Set.of(WarmupDiscoveryService.class);
     }
 
     @Override
index 9b84d1c8dcf6f89fa5d6c8228846984761bd44cd..62e60aa8fbd860c5ecbf3e9dc37ef9e6c0a200f1 100644 (file)
@@ -60,11 +60,12 @@ public class RoomHandler extends WarmupThingHandler implements WarmupRefreshList
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
         super.handleCommand(channelUID, command);
-        if (CHANNEL_TARGET_TEMPERATURE.equals(channelUID.getId()) && command instanceof QuantityType<?>) {
-            setOverride((QuantityType<?>) command);
+        if (CHANNEL_TARGET_TEMPERATURE.equals(channelUID.getId())
+                && command instanceof QuantityType<?> quantityCommand) {
+            setOverride(quantityCommand);
         }
-        if (CHANNEL_FROST_PROTECTION_MODE.equals(channelUID.getId()) && command instanceof OnOffType) {
-            toggleFrostProtectionMode((OnOffType) command);
+        if (CHANNEL_FROST_PROTECTION_MODE.equals(channelUID.getId()) && command instanceof OnOffType onOffCommand) {
+            toggleFrostProtectionMode(onOffCommand);
         }
     }
 
index 7f34c6402e52f2412f567f1a9964b1635538ce25..4bc5e558375e237b687414093d9c1d9eef96d59d 100644 (file)
@@ -273,8 +273,7 @@ public abstract class WeatherCompanyAbstractHandler extends BaseThingHandler {
     protected DateTimeType getLocalDateTimeType(long epochSeconds) {
         Instant instant = Instant.ofEpochSecond(epochSeconds);
         ZonedDateTime localDateTime = instant.atZone(getZoneId());
-        DateTimeType dateTimeType = new DateTimeType(localDateTime);
-        return dateTimeType;
+        return new DateTimeType(localDateTime);
     }
 
     /*
index 070b6dbf65166d7b9e61fa99f053dae4172bd869..cf43a9cb128280ab2da0600e674d1b3df4b59fb2 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.binding.weatherunderground.internal;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -38,7 +37,7 @@ public class WeatherUndergroundBindingConstants {
     public static final ThingTypeUID THING_TYPE_WEATHER = new ThingTypeUID(BINDING_ID, "weather");
     public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
 
-    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_BRIDGE);
+    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(THING_TYPE_BRIDGE);
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(Arrays.asList(THING_TYPE_WEATHER));
 
     // Channel configuration Properties
index 5b5d9f266aa412b175375d3b26463f36bb8a1440..c56887eb2f9d9bbc5bb9b67ab03f94e890eaae5d 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.weatherunderground.internal.discovery;
 import static org.openhab.binding.weatherunderground.internal.WeatherUndergroundBindingConstants.*;
 import static org.openhab.binding.weatherunderground.internal.config.WeatherUndergroundConfiguration.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -44,7 +43,7 @@ import org.slf4j.LoggerFactory;
 public class WeatherUndergroundDiscoveryService extends AbstractDiscoveryService {
 
     private final Logger logger = LoggerFactory.getLogger(WeatherUndergroundDiscoveryService.class);
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_WEATHER);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_WEATHER);
     private static final int DISCOVER_TIMEOUT_SECONDS = 2;
     private static final int LOCATION_CHANGED_CHECK_INTERVAL = 60;
 
index 372eab0c71e2184b4b8b9538d1fefde312d51acd..4ddfc455692b2483d1463d75dcf793969ff9b16e 100644 (file)
@@ -67,7 +67,7 @@ public class WeatherUndergroundBridgeHandler extends BaseBridgeHandler {
 
         // Check if an api key has been provided during the bridge creation
         Object configApiKey = config.get(WeatherUndergroundBindingConstants.APIKEY);
-        if (configApiKey == null || !(configApiKey instanceof String) || ((String) configApiKey).trim().isEmpty()) {
+        if (!(configApiKey instanceof String) || ((String) configApiKey).trim().isEmpty()) {
             logger.debug("Setting thing '{}' to OFFLINE: Parameter 'apikey' must be configured.", getThing().getUID());
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                     "@text/offline.conf-error-missing-apikey");
index a6030813267330fae09778ad6ee6065da9a36f2b..95397d30871c32650527a55df69b63acfecddad3 100644 (file)
@@ -179,7 +179,7 @@ public class WeatherUndergroundJsonCurrent {
      * @return the current relative humidity or null if not defined
      */
     public Integer getRelativeHumidity() {
-        if (relative_humidity != null && !relative_humidity.isEmpty() && !relative_humidity.equalsIgnoreCase("N/A")) {
+        if (relative_humidity != null && !relative_humidity.isEmpty() && !"N/A".equalsIgnoreCase(relative_humidity)) {
             return WeatherUndergroundJsonUtils.convertToInteger(relative_humidity.replace("%", ""));
         }
         return null;
index e01c903e6376890bd914a5a01b31414a90b836d2..efd5ae4b7defb6b25a31d5494e3393948df35aed 100644 (file)
@@ -90,8 +90,8 @@ public class WeatherUndergroundJsonUtils {
     }
 
     private static boolean isValid(String value) {
-        return (value != null) && !value.isEmpty() && !value.equalsIgnoreCase("N/A") && !value.equalsIgnoreCase("NA")
-                && !value.equals("-") && !value.equals("--");
+        return (value != null) && !value.isEmpty() && !"N/A".equalsIgnoreCase(value) && !"NA".equalsIgnoreCase(value)
+                && !"-".equals(value) && !"--".equals(value);
     }
 
     /**
index 8b4703ef5b5c60f647623b69b2b9440a6d23918a..b429ee2aa36bdea999b401bd20db20105b1d8a8c 100644 (file)
@@ -168,16 +168,16 @@ public class WebexTeamsActions implements ThingActions {
     }
 
     public static boolean sendMessage(@Nullable ThingActions actions, @Nullable String text) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendMessage(text);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendMessage(text);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
     }
 
     public static boolean sendMessage(@Nullable ThingActions actions, @Nullable String text, @Nullable String attach) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendMessage(text, attach);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendMessage(text, attach);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
@@ -185,8 +185,8 @@ public class WebexTeamsActions implements ThingActions {
 
     public static boolean sendRoomMessage(@Nullable ThingActions actions, @Nullable String roomId,
             @Nullable String text) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendRoomMessage(roomId, text);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendRoomMessage(roomId, text);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
@@ -194,8 +194,8 @@ public class WebexTeamsActions implements ThingActions {
 
     public static boolean sendRoomMessage(@Nullable ThingActions actions, @Nullable String roomId,
             @Nullable String text, @Nullable String attach) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendRoomMessage(roomId, text, attach);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendRoomMessage(roomId, text, attach);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
@@ -203,8 +203,8 @@ public class WebexTeamsActions implements ThingActions {
 
     public static boolean sendPersonMessage(@Nullable ThingActions actions, @Nullable String personEmail,
             @Nullable String text) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendPersonMessage(personEmail, text);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendPersonMessage(personEmail, text);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
@@ -212,8 +212,8 @@ public class WebexTeamsActions implements ThingActions {
 
     public static boolean sendPersonMessage(@Nullable ThingActions actions, @Nullable String personEmail,
             @Nullable String text, @Nullable String attach) {
-        if (actions instanceof WebexTeamsActions) {
-            return ((WebexTeamsActions) actions).sendPersonMessage(personEmail, text, attach);
+        if (actions instanceof WebexTeamsActions teamsActions) {
+            return teamsActions.sendPersonMessage(personEmail, text, attach);
         } else {
             throw new IllegalArgumentException("Instance is not a WebexTeamsActions class.");
         }
@@ -221,8 +221,8 @@ public class WebexTeamsActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof WebexTeamsHandler) {
-            this.handler = (WebexTeamsHandler) handler;
+        if (handler instanceof WebexTeamsHandler teamsHandler) {
+            this.handler = teamsHandler;
         }
     }
 
index 16eb61b14a200301cb9be646a25076bf4e285410..5c8b884f468628b34bf490cf7601693b2c53b06e 100644 (file)
@@ -18,7 +18,7 @@ import java.io.IOException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -90,7 +90,7 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe
     // creates list of available Actions
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(WebexTeamsActions.class);
+        return List.of(WebexTeamsActions.class);
     }
 
     @Override
index cccfba57ff498212808c2587c6dcc9e3799d015a..9f17bbac649ac669d23fd40e5c3719321657242e 100644 (file)
@@ -74,8 +74,8 @@ public class WebexTeamsHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected synchronized void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof WebexTeamsHandler) {
-            authService.removeWebexTeamsHandler((WebexTeamsHandler) thingHandler);
+        if (thingHandler instanceof WebexTeamsHandler webexTeamsHandler) {
+            authService.removeWebexTeamsHandler(webexTeamsHandler);
         }
     }
 }
index 7e2fb4c7c4d5c9568b64374ef14389c04b2a40d4..b3e195ddc225f43ab06fcd3f02986425cf4d15d7 100644 (file)
@@ -78,8 +78,7 @@ public class WebexTeamsApi {
     public Person getPerson() throws WebexTeamsApiException, WebexAuthenticationException {
         URI url = getUri(WEBEX_API_ENDPOINT + "/people/me");
 
-        Person person = request(url, HttpMethod.GET, Person.class, null);
-        return person;
+        return request(url, HttpMethod.GET, Person.class, null);
     }
 
     private URI getUri(String url) throws WebexTeamsApiException {
@@ -133,8 +132,7 @@ public class WebexTeamsApi {
                 // Obtain the input stream on the response content
                 try (InputStream input = new ByteArrayInputStream(response.getContent())) {
                     Reader reader = new InputStreamReader(input);
-                    O entity = gson.fromJson(reader, clazz);
-                    return entity;
+                    return gson.fromJson(reader, clazz);
                 } catch (IOException | JsonIOException | JsonSyntaxException e) {
                     logger.warn("Exception while processing API response: {}", e.getMessage());
                     throw new WebexTeamsApiException("Exception while processing API response", e);
index 840c8fee2b3ab547f42ceda2db12ed578c9e4ee3..862aa9382938ebfcd4fb75b5c115c0e5ac6d7c01 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.webthing.internal;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingTypeUID;
@@ -31,8 +31,8 @@ public class WebThingBindingConstants {
 
     public static final ThingTypeUID THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "generic");
 
-    public static final Collection<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(WebThingBindingConstants.THING_TYPE_UID);
+    public static final Collection<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(WebThingBindingConstants.THING_TYPE_UID);
 
     public static final String MDNS_SERVICE_TYPE = "_webthing._tcp.local.";
 }
index abd7082bac7c5c0795b3e705924405d60e40d941..757b192f7330c695db433a7db11511dc1cb2c9cf 100644 (file)
@@ -261,9 +261,9 @@ public class WebThingHandler extends BaseThingHandler implements ChannelHandler
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
-        if (command instanceof State) {
+        if (command instanceof State stateCommand) {
             itemChangedListenerMap.getOrDefault(channelUID, EMPTY_ITEM_CHANGED_LISTENER).onItemStateChanged(channelUID,
-                    (State) command);
+                    stateCommand);
         } else if (command instanceof RefreshType) {
             tryReconnect();
         }
index bca6da4deda6b883980d8fbcc6b4de5301450a53..1846eeaa4b541350b637097343fde2794f3e73a9 100644 (file)
@@ -121,7 +121,7 @@ public class ConsumedThingImpl implements ConsumedThing {
         if (optionalProperty.isPresent()) {
             var propertyDescription = optionalProperty.get();
             for (var link : propertyDescription.links) {
-                if ((link.rel != null) && (link.href != null) && link.rel.equals("property")) {
+                if ((link.rel != null) && (link.href != null) && "property".equals(link.rel)) {
                     return Optional.of(webThingURI.resolve(link.href));
                 }
             }
index 091394c2ba1e34977cca559e5f2e9fdf20eb5d56..42cc4d9c351e382d4c6e40333f103ddb97e4139e 100644 (file)
@@ -75,7 +75,7 @@ public class DescriptionLoader {
 
                 // currently, the old and new location of the WebThings schema are supported only.
                 // In the future, other schemas such as http://iotschema.org/docs/full.html may be supported
-                if (schema.equals("https://webthings.io/schemas") || schema.equals("https://iot.mozilla.org/schemas")) {
+                if ("https://webthings.io/schemas".equals(schema) || "https://iot.mozilla.org/schemas".equals(schema)) {
                     return description;
                 }
                 logger.debug(
index 4aafd5823ec3c5751df77eea1063d16b9d9b372f..73171a59fab78b7285c23ccebb32679bac61a8fa 100644 (file)
@@ -57,7 +57,7 @@ public class WebThingDescription {
             var href = link.href;
             if ((href != null) && href.startsWith("ws")) {
                 var rel = Optional.ofNullable(link.rel).orElse("<undefined>");
-                if (rel.equals("alternate")) {
+                if ("alternate".equals(rel)) {
                     return Optional.of(URI.create(href));
                 }
             }
index 0ce449610327da06bcf25b8063388be9b3493c78..03f63382d57c3913f26a6be23138de2a0b5a3207 100644 (file)
@@ -53,7 +53,7 @@ class TypeConverters {
             case "color":
                 return new ColorTypeConverter();
             case "number":
-                if (propertyType.toLowerCase(Locale.ENGLISH).equals("integer")) {
+                if ("integer".equals(propertyType.toLowerCase(Locale.ENGLISH))) {
                     return new IntegerTypeConverter();
                 } else {
                     return new NumberTypeConverter();
@@ -169,8 +169,8 @@ class TypeConverters {
         @Override
         public Command toStateCommand(Object propertyValue) {
             String textValue = propertyValue.toString();
-            if (propertyValue instanceof Collection) {
-                textValue = ((Collection<Object>) propertyValue).stream()
+            if (propertyValue instanceof Collection collection) {
+                textValue = collection.stream()
                         .reduce("", (entry1, entry2) -> entry1.toString() + "\n" + entry2.toString()).toString();
             }
             return StringType.valueOf(textValue);
index 393a12c9951aaa9068e44573e7687aaee96d9e04..5ca2e236724af75dbc6ff14c9ce178f65aa6b84d 100644 (file)
@@ -96,7 +96,7 @@ public class TypeMapping {
                 break;
             case "LevelProperty":
                 if ((propertyMetadata.unit != null)
-                        && propertyMetadata.unit.toLowerCase(Locale.ENGLISH).equals("percent")) {
+                        && "percent".equals(propertyMetadata.unit.toLowerCase(Locale.ENGLISH))) {
                     type = CoreItemFactory.DIMMER;
                 } else {
                     type = CoreItemFactory.NUMBER;
index 2c7425ffca27a40fd519495d61cefbeaacd7c4f4..0d87bb516d3ade9dc2e37fe96e6d3b83f4307122 100644 (file)
@@ -132,25 +132,30 @@ public class WemoUtil {
 
     public static String createBinaryStateContent(boolean binaryState) {
         String binary = binaryState ? "1" : "0";
-        String content = "<?xml version=\"1.0\"?>"
-                + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                + "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>"
+        return """
+                <?xml version="1.0"?>\
+                <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                <s:Body>\
+                <u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">\
+                <BinaryState>\
+                """
                 + binary + "</BinaryState>" + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
-        return content;
     }
 
     public static String createStateRequestContent(String action, String actionService) {
-        String content = "<?xml version=\"1.0\"?>"
-                + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                + "<s:Body>" + "<u:" + action + " xmlns:u=\"urn:Belkin:service:" + actionService + ":1\">" + "</u:"
-                + action + ">" + "</s:Body>" + "</s:Envelope>";
-        return content;
+        return """
+                <?xml version="1.0"?>\
+                <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                <s:Body>\
+                <u:\
+                """
+                + action + " xmlns:u=\"urn:Belkin:service:" + actionService + ":1\">" + "</u:" + action + ">"
+                + "</s:Body>" + "</s:Envelope>";
     }
 
     public static String getCharacterDataFromElement(Element e) {
         Node child = e.getFirstChild();
-        if (child instanceof CharacterData) {
-            CharacterData cd = (CharacterData) child;
+        if (child instanceof CharacterData cd) {
             return cd.getData();
         }
         return "?";
index 3a4c84e2ef42bc139cafaa28c188118137f95d74..0e13395617f59d47bf204b3b323a7869345ed8ee 100644 (file)
@@ -17,7 +17,6 @@ import static org.openhab.binding.wemo.internal.WemoUtil.*;
 
 import java.io.StringReader;
 import java.net.URL;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -59,7 +58,7 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
 
     private final Logger logger = LoggerFactory.getLogger(WemoLinkDiscoveryService.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_MZ100);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MZ100);
 
     public static final String NORMALIZE_ID_REGEX = "[^a-zA-Z0-9_]";
 
@@ -119,11 +118,20 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
             logger.trace("devUDN = '{}'", devUDN);
 
             String soapHeader = "\"urn:Belkin:service:bridge:1#GetEndDevices\"";
-            String content = "<?xml version=\"1.0\"?>"
-                    + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                    + "<s:Body>" + "<u:GetEndDevices xmlns:u=\"urn:Belkin:service:bridge:1\">" + "<DevUDN>" + devUDN
-                    + "</DevUDN><ReqListType>PAIRED_LIST</ReqListType>" + "</u:GetEndDevices>" + "</s:Body>"
-                    + "</s:Envelope>";
+            String content = """
+                    <?xml version="1.0"?>\
+                    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                    <s:Body>\
+                    <u:GetEndDevices xmlns:u="urn:Belkin:service:bridge:1">\
+                    <DevUDN>\
+                    """
+                    + devUDN + """
+                            </DevUDN>\
+                            <ReqListType>PAIRED_LIST</ReqListType>\
+                            </u:GetEndDevices>\
+                            </s:Body>\
+                            </s:Envelope>\
+                            """;
 
             URL descriptorURL = service.getDescriptorURL(this);
 
@@ -274,8 +282,7 @@ public class WemoLinkDiscoveryService extends AbstractDiscoveryService implement
 
     public static String getCharacterDataFromElement(Element e) {
         Node child = e.getFirstChild();
-        if (child instanceof CharacterData) {
-            CharacterData cd = (CharacterData) child;
+        if (child instanceof CharacterData cd) {
             return cd.getData();
         }
         return "?";
index 02da650be98d2c16f2ca54924832810d1a17b54f..c9eb7f218312c166eb475e41814b2225ddd8ece3 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.wemo.internal.handler;
 
 import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -38,7 +37,7 @@ import org.slf4j.LoggerFactory;
 @NonNullByDefault
 public class WemoBridgeHandler extends BaseBridgeHandler {
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
 
     private final Logger logger = LoggerFactory.getLogger(WemoBridgeHandler.class);
 
index e531e3fa82aa5cf320d1d72ecf602ca4ce2ad39f..541934f2f4112e43104101c484df61b2d1a86774 100644 (file)
@@ -18,7 +18,6 @@ import static org.openhab.binding.wemo.internal.WemoUtil.*;
 import java.io.StringReader;
 import java.time.Instant;
 import java.time.ZonedDateTime;
-import java.util.Collections;
 import java.util.Set;
 import java.util.TimeZone;
 import java.util.concurrent.ScheduledFuture;
@@ -63,7 +62,7 @@ public class WemoCoffeeHandler extends WemoBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(WemoCoffeeHandler.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_COFFEE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_COFFEE);
 
     private final Object jobLock = new Object();
 
@@ -145,18 +144,23 @@ public class WemoCoffeeHandler extends WemoBaseThingHandler {
                     try {
                         String soapHeader = "\"urn:Belkin:service:deviceevent:1#SetAttributes\"";
 
-                        String content = "<?xml version=\"1.0\"?>"
-                                + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                                + "<s:Body>" + "<u:SetAttributes xmlns:u=\"urn:Belkin:service:deviceevent:1\">"
-                                + "<attributeList>&lt;attribute&gt;&lt;name&gt;Brewed&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;"
-                                + "&lt;attribute&gt;&lt;name&gt;LastCleaned&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;"
-                                + "&lt;name&gt;ModeTime&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;Brewing&lt;/name&gt;"
-                                + "&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;TimeRemaining&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;"
-                                + "&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;WaterLevelReached&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;"
-                                + "attribute&gt;&lt;name&gt;Mode&lt;/name&gt;&lt;value&gt;4&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;CleanAdvise&lt;/name&gt;"
-                                + "&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;FilterAdvise&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;"
-                                + "&lt;attribute&gt;&lt;name&gt;Cleaning&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;</attributeList>"
-                                + "</u:SetAttributes>" + "</s:Body>" + "</s:Envelope>";
+                        String content = """
+                                <?xml version="1.0"?>\
+                                <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                                <s:Body>\
+                                <u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1">\
+                                <attributeList>&lt;attribute&gt;&lt;name&gt;Brewed&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;\
+                                &lt;attribute&gt;&lt;name&gt;LastCleaned&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;\
+                                &lt;name&gt;ModeTime&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;Brewing&lt;/name&gt;\
+                                &lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;TimeRemaining&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;\
+                                &lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;WaterLevelReached&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;\
+                                attribute&gt;&lt;name&gt;Mode&lt;/name&gt;&lt;value&gt;4&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;CleanAdvise&lt;/name&gt;\
+                                &lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;&lt;attribute&gt;&lt;name&gt;FilterAdvise&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;\
+                                &lt;attribute&gt;&lt;name&gt;Cleaning&lt;/name&gt;&lt;value&gt;NULL&lt;/value&gt;&lt;/attribute&gt;</attributeList>\
+                                </u:SetAttributes>\
+                                </s:Body>\
+                                </s:Envelope>\
+                                """;
 
                         wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
                         updateState(CHANNEL_STATE, OnOffType.ON);
index 43b4627327777371e8da3cc497dab0fa52ba2a53..e06ac3950597e12a697161d6a56a184559655002 100644 (file)
@@ -52,7 +52,7 @@ public class WemoCrockpotHandler extends WemoBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(WemoCrockpotHandler.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_CROCKPOT);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_CROCKPOT);
 
     private final Object jobLock = new Object();
 
@@ -147,9 +147,13 @@ public class WemoCrockpotHandler extends WemoBaseThingHandler {
             }
             try {
                 String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
-                String content = "<?xml version=\"1.0\"?>"
-                        + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                        + "<s:Body>" + "<u:SetCrockpotState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<mode>"
+                String content = """
+                        <?xml version="1.0"?>\
+                        <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                        <s:Body>\
+                        <u:SetCrockpotState xmlns:u="urn:Belkin:service:basicevent:1">\
+                        <mode>\
+                        """
                         + mode + "</mode>" + "<time>" + time + "</time>" + "</u:SetCrockpotState>" + "</s:Body>"
                         + "</s:Envelope>";
                 wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
index 03be05685a88cea4ec6ffdc3299e03a58a93871a..609d960302ccc499dbb4cb6270690beb375d1cfa 100644 (file)
@@ -57,7 +57,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(WemoDimmerHandler.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_DIMMER);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_DIMMER);
 
     private final Object jobLock = new Object();
 
@@ -157,8 +157,8 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                             State brightnessState = new PercentType(currentBrightness);
                             updateState(CHANNEL_BRIGHTNESS, brightnessState);
                         }
-                    } else if (command instanceof PercentType) {
-                        int newBrightness = ((PercentType) command).intValue();
+                    } else if (command instanceof PercentType percentCommand) {
+                        int newBrightness = percentCommand.intValue();
                         value = String.valueOf(newBrightness);
                         currentBrightness = newBrightness;
                         argument = "brightness";
@@ -217,20 +217,36 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                         int commandValue = Integer.valueOf(String.valueOf(command));
                         commandValue = commandValue * 60;
                         String commandString = String.valueOf(commandValue);
-                        value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
-                                + "<brightness></brightness>" + "<fader>" + commandString + ":-1:1:0:0</fader>"
-                                + "<UDN></UDN>";
+                        value = """
+                                <BinaryState></BinaryState>\
+                                <Duration></Duration>\
+                                <EndAction></EndAction>\
+                                <brightness></brightness>\
+                                <fader>\
+                                """ + commandString + ":-1:1:0:0</fader><UDN></UDN>";
                         setBinaryState(action, argument, value);
                     }
                     break;
                 case CHANNEL_FADER_ENABLED:
                     argument = "Fader";
                     if (command.equals(OnOffType.ON)) {
-                        value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
-                                + "<brightness></brightness>" + "<fader>600:-1:1:0:0</fader>" + "<UDN></UDN>";
+                        value = """
+                                <BinaryState></BinaryState>\
+                                <Duration></Duration>\
+                                <EndAction></EndAction>\
+                                <brightness></brightness>\
+                                <fader>600:-1:1:0:0</fader>\
+                                <UDN></UDN>\
+                                """;
                     } else if (command.equals(OnOffType.OFF)) {
-                        value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
-                                + "<brightness></brightness>" + "<fader>600:-1:0:0:0</fader>" + "<UDN></UDN>";
+                        value = """
+                                <BinaryState></BinaryState>\
+                                <Duration></Duration>\
+                                <EndAction></EndAction>\
+                                <brightness></brightness>\
+                                <fader>600:-1:0:0:0</fader>\
+                                <UDN></UDN>\
+                                """;
                     }
                     setBinaryState(action, argument, value);
                     break;
@@ -253,14 +269,23 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                     }
                     if (faderSeconds != null && faderEnabled != null) {
                         if (OnOffType.ON.equals(command)) {
-                            value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
-                                    + "<brightness></brightness>" + "<fader>" + faderSeconds + ":" + timeStamp + ":"
-                                    + faderEnabled + ":0:0</fader>" + "<UDN></UDN>";
+                            value = """
+                                    <BinaryState></BinaryState>\
+                                    <Duration></Duration>\
+                                    <EndAction></EndAction>\
+                                    <brightness></brightness>\
+                                    <fader>\
+                                    """ + faderSeconds + ":" + timeStamp + ":" + faderEnabled + ":0:0</fader>"
+                                    + "<UDN></UDN>";
                             updateState(CHANNEL_STATE, OnOffType.ON);
                         } else if (OnOffType.OFF.equals(command)) {
-                            value = "<BinaryState></BinaryState>" + "<Duration></Duration>" + "<EndAction></EndAction>"
-                                    + "<brightness></brightness>" + "<fader>" + faderSeconds + ":-1:" + faderEnabled
-                                    + ":0:0</fader>" + "<UDN></UDN>";
+                            value = """
+                                    <BinaryState></BinaryState>\
+                                    <Duration></Duration>\
+                                    <EndAction></EndAction>\
+                                    <brightness></brightness>\
+                                    <fader>\
+                                    """ + faderSeconds + ":-1:" + faderEnabled + ":0:0</fader>" + "<UDN></UDN>";
                         }
                     }
                     setBinaryState(action, argument, value);
@@ -281,8 +306,8 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                 case CHANNEL_NIGHT_MODE_BRIGHTNESS:
                     action = "ConfigureNightMode";
                     argument = "NightModeConfiguration";
-                    if (command instanceof PercentType) {
-                        int newBrightness = ((PercentType) command).intValue();
+                    if (command instanceof PercentType percentCommand) {
+                        int newBrightness = percentCommand.intValue();
                         String newNightModeBrightness = String.valueOf(newBrightness);
                         value = "&lt;startTime&gt;0&lt;/startTime&gt; \\n&lt;nightMode&gt;" + currentNightModeState
                                 + "&lt;/nightMode&gt; \\n&lt;endTime&gt;23400&lt;/endTime&gt; \\n&lt;nightModeBrightness&gt;"
@@ -361,7 +386,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                         updateState(CHANNEL_FADER_COUNT_DOWN_TIME, faderMinutes);
                     }
                     if (splitFader[1] != null) {
-                        State isTimerRunning = splitFader[1].equals("-1") ? OnOffType.OFF : OnOffType.ON;
+                        State isTimerRunning = "-1".equals(splitFader[1]) ? OnOffType.OFF : OnOffType.ON;
                         logger.debug("isTimerRunning '{}' for device '{}' received", isTimerRunning,
                                 getThing().getUID());
                         updateState(CHANNEL_TIMER_START, isTimerRunning);
@@ -370,7 +395,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
                         }
                     }
                     if (splitFader[2] != null) {
-                        State isFaderEnabled = splitFader[1].equals("0") ? OnOffType.OFF : OnOffType.ON;
+                        State isFaderEnabled = "0".equals(splitFader[1]) ? OnOffType.OFF : OnOffType.ON;
                         logger.debug("isFaderEnabled '{}' for device '{}' received", isFaderEnabled,
                                 getThing().getUID());
                         updateState(CHANNEL_FADER_ENABLED, isFaderEnabled);
@@ -478,8 +503,7 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
             return null;
         }
         ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochSecond(value), TimeZone.getDefault().toZoneId());
-        State dateTimeState = new DateTimeType(zoned);
-        return dateTimeState;
+        return new DateTimeType(zoned);
     }
 
     public void setBinaryState(String action, String argument, String value) {
@@ -490,10 +514,14 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
         }
         try {
             String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
-            String content = "<?xml version=\"1.0\"?>"
-                    + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                    + "<s:Body>" + "<u:" + action + " xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<" + argument
-                    + ">" + value + "</" + argument + ">" + "</u:" + action + ">" + "</s:Body>" + "</s:Envelope>";
+            String content = """
+                    <?xml version="1.0"?>\
+                    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                    <s:Body>\
+                    <u:\
+                    """
+                    + action + " xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<" + argument + ">" + value + "</"
+                    + argument + ">" + "</u:" + action + ">" + "</s:Body>" + "</s:Envelope>";
 
             wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
             updateStatus(ThingStatus.ONLINE);
@@ -512,10 +540,13 @@ public class WemoDimmerHandler extends WemoBaseThingHandler {
         }
         try {
             String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\"";
-            String content = "<?xml version=\"1.0\"?>"
-                    + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                    + "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + value
-                    + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
+            String content = """
+                    <?xml version="1.0"?>\
+                    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                    <s:Body>\
+                    <u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">\
+                    """
+                    + value + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>";
             wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
             updateStatus(ThingStatus.ONLINE);
         } catch (Exception e) {
index 19b39af43bf9ff001472501142dc74e3c801ff3e..de174836c645a84893632d13d123343d5d36d533 100644 (file)
@@ -63,7 +63,7 @@ public class WemoHolmesHandler extends WemoBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(WemoHolmesHandler.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_PURIFIER);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PURIFIER);
 
     private static final int FILTER_LIFE_DAYS = 330;
     private static final int FILTER_LIFE_MINS = FILTER_LIFE_DAYS * 24 * 60;
@@ -239,10 +239,14 @@ public class WemoHolmesHandler extends WemoBaseThingHandler {
         }
         try {
             String soapHeader = "\"urn:Belkin:service:deviceevent:1#SetAttributes\"";
-            String content = "<?xml version=\"1.0\"?>"
-                    + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                    + "<s:Body>" + "<u:SetAttributes xmlns:u=\"urn:Belkin:service:deviceevent:1\">"
-                    + "<attributeList>&lt;attribute&gt;&lt;name&gt;" + attribute + "&lt;/name&gt;&lt;value&gt;" + value
+            String content = """
+                    <?xml version="1.0"?>\
+                    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                    <s:Body>\
+                    <u:SetAttributes xmlns:u="urn:Belkin:service:deviceevent:1">\
+                    <attributeList>&lt;attribute&gt;&lt;name&gt;\
+                    """
+                    + attribute + "&lt;/name&gt;&lt;value&gt;" + value
                     + "&lt;/value&gt;&lt;/attribute&gt;</attributeList>" + "</u:SetAttributes>" + "</s:Body>"
                     + "</s:Envelope>";
             wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
index 64305d3d22426dbd316300de3b5e423ee2274d39..db5d386e8dffe078ccd7b82b08a29d55e3851434 100644 (file)
@@ -126,8 +126,8 @@ public class WemoLightHandler extends WemoBaseThingHandler {
             return null;
         }
         ThingHandler handler = bridge.getHandler();
-        if (handler instanceof WemoBridgeHandler) {
-            this.wemoBridgeHandler = (WemoBridgeHandler) handler;
+        if (handler instanceof WemoBridgeHandler wemoBridgeHandler) {
+            this.wemoBridgeHandler = wemoBridgeHandler;
         } else {
             logger.debug("No available bridge handler found for {} bridge {} .", wemoLightID, bridge.getUID());
             return null;
@@ -187,8 +187,8 @@ public class WemoLightHandler extends WemoBaseThingHandler {
             switch (channelUID.getId()) {
                 case CHANNEL_BRIGHTNESS:
                     capability = "10008";
-                    if (command instanceof PercentType) {
-                        int newBrightness = ((PercentType) command).intValue();
+                    if (command instanceof PercentType percentCommand) {
+                        int newBrightness = percentCommand.intValue();
                         logger.trace("wemoLight received Value {}", newBrightness);
                         int value1 = Math.round(newBrightness * 255 / 100);
                         value = value1 + ":0";
@@ -239,11 +239,14 @@ public class WemoLightHandler extends WemoBaseThingHandler {
             try {
                 if (capability != null && value != null) {
                     String soapHeader = "\"urn:Belkin:service:bridge:1#SetDeviceStatus\"";
-                    String content = "<?xml version=\"1.0\"?>"
-                            + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                            + "<s:Body>" + "<u:SetDeviceStatus xmlns:u=\"urn:Belkin:service:bridge:1\">"
-                            + "<DeviceStatusList>"
-                            + "&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;DeviceStatus&gt;&lt;DeviceID&gt;"
+                    String content = """
+                            <?xml version="1.0"?>\
+                            <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                            <s:Body>\
+                            <u:SetDeviceStatus xmlns:u="urn:Belkin:service:bridge:1">\
+                            <DeviceStatusList>\
+                            &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;DeviceStatus&gt;&lt;DeviceID&gt;\
+                            """
                             + wemoLightID
                             + "&lt;/DeviceID&gt;&lt;IsGroupAction&gt;NO&lt;/IsGroupAction&gt;&lt;CapabilityID&gt;"
                             + capability + "&lt;/CapabilityID&gt;&lt;CapabilityValue&gt;" + value
@@ -289,9 +292,13 @@ public class WemoLightHandler extends WemoBaseThingHandler {
         }
         try {
             String soapHeader = "\"urn:Belkin:service:bridge:1#GetDeviceStatus\"";
-            String content = "<?xml version=\"1.0\"?>"
-                    + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
-                    + "<s:Body>" + "<u:GetDeviceStatus xmlns:u=\"urn:Belkin:service:bridge:1\">" + "<DeviceIDs>"
+            String content = """
+                    <?xml version="1.0"?>\
+                    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
+                    <s:Body>\
+                    <u:GetDeviceStatus xmlns:u="urn:Belkin:service:bridge:1">\
+                    <DeviceIDs>\
+                    """
                     + wemoLightID + "</DeviceIDs>" + "</u:GetDeviceStatus>" + "</s:Body>" + "</s:Envelope>";
 
             String wemoCallResponse = wemoHttpCaller.executeCall(wemoURL, soapHeader, content);
@@ -305,7 +312,7 @@ public class WemoLightHandler extends WemoBaseThingHandler {
                 updateState(CHANNEL_STATE, binaryState);
             }
             if (splitResponse[1] != null) {
-                String splitBrightness[] = splitResponse[1].split(":");
+                String[] splitBrightness = splitResponse[1].split(":");
                 if (splitBrightness[0] != null) {
                     int newBrightnessValue = Integer.valueOf(splitBrightness[0]);
                     int newBrightness = Math.round(newBrightnessValue * 100 / 255);
@@ -335,7 +342,7 @@ public class WemoLightHandler extends WemoBaseThingHandler {
                 updateState(CHANNEL_STATE, binaryState);
                 break;
             case "10008":
-                String splitValue[] = newValue.split(":");
+                String[] splitValue = newValue.split(":");
                 if (splitValue[0] != null) {
                     int newBrightnessValue = Integer.valueOf(splitValue[0]);
                     int newBrightness = Math.round(newBrightnessValue * 100 / 255);
index a2e620e827173bd37d36578562f3450cc4db5fc5..61b3d413c285c530e2ed0976acde8bd6b3474786 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.wemo.internal.WemoBindingConstants.*;
 import static org.openhab.binding.wemo.internal.WemoUtil.*;
 
 import java.io.StringReader;
-import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -56,7 +55,7 @@ public class WemoMakerHandler extends WemoBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(WemoMakerHandler.class);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_MAKER);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MAKER);
 
     private final Object jobLock = new Object();
 
index 858cc17ca26abccda19c27d867d52afddbbc2305..c51d0dec76d86d7e1b6bb0448b57db2d2e61cb71 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.wifiled.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public class WiFiLEDBindingConstants {
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_WIFILED = new ThingTypeUID(BINDING_ID, "wifiled");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_WIFILED);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_WIFILED);
 
     // List of all Channel IDs
     public static final String CHANNEL_POWER = "power";
index f3875271d509d909cb889b5e2643ca66bfc3c525..fe77238c3d6c5e63e42c12e00b57eed5fc18767d 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.wifiled.internal;
 
 import static org.openhab.binding.wifiled.internal.WiFiLEDBindingConstants.THING_TYPE_WIFILED;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.openhab.binding.wifiled.internal.handler.WiFiLEDHandler;
@@ -34,7 +33,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.wifiled")
 public class WiFiLEDHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_WIFILED);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_WIFILED);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index cdd32ed65b3bf9c85100ab8641e84c0f900065d0..388133e570a4d0ccaa9dbc2eeb2ffdc74b1c6761 100644 (file)
@@ -124,8 +124,8 @@ public class WiFiLEDHandler extends BaseThingHandler {
             } else if (channelUID.getId().equals(WiFiLEDBindingConstants.CHANNEL_WHITE2)) {
                 handleWhite2Command(command);
             } else if (channelUID.getId().equals(WiFiLEDBindingConstants.CHANNEL_PROGRAM)
-                    && (command instanceof StringType)) {
-                driver.setProgram((StringType) command);
+                    && (command instanceof StringType stringCommand)) {
+                driver.setProgram(stringCommand);
             } else if (channelUID.getId().equals(WiFiLEDBindingConstants.CHANNEL_PROGRAM_SPEED)) {
                 handleProgramSpeedCommand(command);
             }
@@ -135,14 +135,13 @@ public class WiFiLEDHandler extends BaseThingHandler {
     }
 
     private void handleColorCommand(Command command) throws IOException {
-        if (command instanceof HSBType) {
-            driver.setColor((HSBType) command);
-        } else if (command instanceof PercentType) {
-            driver.setBrightness((PercentType) command);
-        } else if (command instanceof OnOffType) {
-            driver.setPower((OnOffType) command);
-        } else if (command instanceof IncreaseDecreaseType) {
-            IncreaseDecreaseType increaseDecreaseType = (IncreaseDecreaseType) command;
+        if (command instanceof HSBType hsbCommand) {
+            driver.setColor(hsbCommand);
+        } else if (command instanceof PercentType percentCommand) {
+            driver.setBrightness(percentCommand);
+        } else if (command instanceof OnOffType onOffCommand) {
+            driver.setPower(onOffCommand);
+        } else if (command instanceof IncreaseDecreaseType increaseDecreaseType) {
             if (increaseDecreaseType.equals(IncreaseDecreaseType.INCREASE)) {
                 driver.incBrightness(INC_DEC_STEP);
             } else {
@@ -152,18 +151,16 @@ public class WiFiLEDHandler extends BaseThingHandler {
     }
 
     private void handleWhiteCommand(Command command) throws IOException {
-        if (command instanceof PercentType) {
-            driver.setWhite((PercentType) command);
-        } else if (command instanceof OnOffType) {
-            OnOffType onOffCommand = (OnOffType) command;
+        if (command instanceof PercentType percentCommand) {
+            driver.setWhite(percentCommand);
+        } else if (command instanceof OnOffType onOffCommand) {
             if (onOffCommand.equals(OnOffType.ON)) {
                 driver.setWhite(PercentType.HUNDRED);
             } else {
                 driver.setWhite(PercentType.ZERO);
             }
-        } else if (command instanceof IncreaseDecreaseType) {
-            IncreaseDecreaseType increaseDecreaseType = (IncreaseDecreaseType) command;
-            if (increaseDecreaseType.equals(IncreaseDecreaseType.INCREASE)) {
+        } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+            if (increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                 driver.incWhite(INC_DEC_STEP);
             } else {
                 driver.decWhite(INC_DEC_STEP);
@@ -172,18 +169,16 @@ public class WiFiLEDHandler extends BaseThingHandler {
     }
 
     private void handleWhite2Command(Command command) throws IOException {
-        if (command instanceof PercentType) {
-            driver.setWhite2((PercentType) command);
-        } else if (command instanceof OnOffType) {
-            OnOffType onOffCommand = (OnOffType) command;
+        if (command instanceof PercentType percentCommand) {
+            driver.setWhite2(percentCommand);
+        } else if (command instanceof OnOffType onOffCommand) {
             if (onOffCommand.equals(OnOffType.ON)) {
                 driver.setWhite2(PercentType.HUNDRED);
             } else {
                 driver.setWhite2(PercentType.ZERO);
             }
-        } else if (command instanceof IncreaseDecreaseType) {
-            IncreaseDecreaseType increaseDecreaseType = (IncreaseDecreaseType) command;
-            if (increaseDecreaseType.equals(IncreaseDecreaseType.INCREASE)) {
+        } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+            if (increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                 driver.incWhite2(INC_DEC_STEP);
             } else {
                 driver.decWhite2(INC_DEC_STEP);
@@ -192,18 +187,16 @@ public class WiFiLEDHandler extends BaseThingHandler {
     }
 
     private void handleProgramSpeedCommand(Command command) throws IOException {
-        if (command instanceof PercentType) {
-            driver.setProgramSpeed((PercentType) command);
-        } else if (command instanceof OnOffType) {
-            OnOffType onOffCommand = (OnOffType) command;
+        if (command instanceof PercentType percentCommand) {
+            driver.setProgramSpeed(percentCommand);
+        } else if (command instanceof OnOffType onOffCommand) {
             if (onOffCommand.equals(OnOffType.ON)) {
                 driver.setProgramSpeed(PercentType.HUNDRED);
             } else {
                 driver.setProgramSpeed(PercentType.ZERO);
             }
-        } else if (command instanceof IncreaseDecreaseType) {
-            IncreaseDecreaseType increaseDecreaseType = (IncreaseDecreaseType) command;
-            if (increaseDecreaseType.equals(IncreaseDecreaseType.INCREASE)) {
+        } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+            if (increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                 driver.incProgramSpeed(INC_DEC_STEP);
             } else {
                 driver.decProgramSpeed(INC_DEC_STEP);
index cd859847ce2db8a0e3c7689f3a507986ac375dfe..008cecf55a5d9e62d8a84a5c4840a0709661084b 100644 (file)
@@ -151,7 +151,7 @@ public class WindcentraleDiscoveryService extends AbstractDiscoveryService
     }
 
     private void addWindmillDiscoveryResult(ThingUID bridgeUID, Windmill windmill, int shares) {
-        String deviceId = windmill.getName().toLowerCase().replaceAll(" ", "-");
+        String deviceId = windmill.getName().toLowerCase().replace(" ", "-");
         ThingUID thingUID = new ThingUID(THING_TYPE_WINDMILL, bridgeUID, deviceId);
 
         thingDiscovered(DiscoveryResultBuilder.create(thingUID) //
index b18d0abf4fbbc84c5534c3fff4293ebb26c4dc5c..b5d8451d7f23adf24a24ec3b833caba00399283f 100644 (file)
@@ -45,7 +45,7 @@ public class DataUtil {
 
     @SuppressWarnings("null")
     public Reader openDataReader(String fileName) throws FileNotFoundException {
-        String packagePath = (DataUtil.class.getPackage().getName()).replaceAll("\\.", "/");
+        String packagePath = (DataUtil.class.getPackage().getName()).replace(".", "/");
         String filePath = "src/test/resources/" + packagePath + "/" + fileName;
 
         InputStream inputStream = new FileInputStream(filePath);
index b370a33389d47d6cc08b4fbb83945201438c1cef..68b98d712b9bac71a72af3e31ebe2fa26bba9c37 100644 (file)
@@ -55,7 +55,6 @@ public class WlanThermoEsp32CommandHandler {
 
     public static State getState(ChannelUID channelUID, Data data, Settings settings)
             throws WlanThermoUnknownChannelException, WlanThermoInputException {
-
         String groupId = requireNonNull(channelUID.getGroupId());
         System system = data.getSystem();
         Unit<Temperature> unit = "F".equals(system.getUnit()) ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS;
@@ -186,9 +185,9 @@ public class WlanThermoEsp32CommandHandler {
                         }
                         return false;
                     case CHANNEL_MIN:
-                        if (command instanceof QuantityType) {
+                        if (command instanceof QuantityType quantityCommand) {
                             try {
-                                channel.setMin(requireNonNull(((QuantityType<?>) command).toUnit(unit)).doubleValue());
+                                channel.setMin(requireNonNull(quantityCommand.toUnit(unit)).doubleValue());
                                 return true;
                             } catch (WlanThermoInputException ignore) {
                                 return false;
@@ -196,9 +195,9 @@ public class WlanThermoEsp32CommandHandler {
                         }
                         return false;
                     case CHANNEL_MAX:
-                        if (command instanceof QuantityType) {
+                        if (command instanceof QuantityType quantityCommand) {
                             try {
-                                channel.setMax(requireNonNull(((QuantityType<?>) command).toUnit(unit)).doubleValue());
+                                channel.setMax(requireNonNull(quantityCommand.toUnit(unit)).doubleValue());
                                 return true;
                             } catch (WlanThermoInputException ignore) {
                                 return false;
@@ -230,14 +229,14 @@ public class WlanThermoEsp32CommandHandler {
                         }
                         return false;
                     case CHANNEL_COLOR_NAME:
-                        if (command instanceof StringType) {
-                            channel.setColor(WlanThermoEsp32Util.toHex(((StringType) command).toString()));
+                        if (command instanceof StringType stringCommand) {
+                            channel.setColor(WlanThermoEsp32Util.toHex(stringCommand.toString()));
                             return true;
                         }
                         return false;
                     case CHANNEL_COLOR:
-                        if (command instanceof HSBType) {
-                            channel.setColor(WlanThermoUtil.toHex((HSBType) command));
+                        if (command instanceof HSBType hsbCommand) {
+                            channel.setColor(WlanThermoUtil.toHex(hsbCommand));
                             return true;
                         }
                         return false;
@@ -264,8 +263,8 @@ public class WlanThermoEsp32CommandHandler {
                         }
                     case CHANNEL_PITMASTER_STATE:
                         String state = ((StringType) command).toString();
-                        if (state.equalsIgnoreCase("off") || state.equalsIgnoreCase("manual")
-                                || state.equalsIgnoreCase("auto")) {
+                        if ("off".equalsIgnoreCase(state) || "manual".equalsIgnoreCase(state)
+                                || "auto".equalsIgnoreCase(state)) {
                             pm.setTyp(state);
                             return true;
                         }
index a150148d6c775060c9e22eb20bd40b7213ba59c7..bb6181def17a0a090dee3d169429bef1fa79df24 100644 (file)
@@ -134,7 +134,7 @@ public class WlanThermoMiniCommandHandler {
                 case WlanThermoBindingConstants.CHANNEL_PITMASTER_DUTY_CYCLE:
                     return new DecimalType(pit.getControlOut());
                 case WlanThermoBindingConstants.CHANNEL_PITMASTER_LID_OPEN:
-                    return OnOffType.from(pit.getOpenLid().equals("True"));
+                    return OnOffType.from("True".equals(pit.getOpenLid()));
                 case WlanThermoBindingConstants.CHANNEL_PITMASTER_CHANNEL_ID:
                     return new DecimalType(pit.getCh());
             }
index a0ddb0a808689577eef202b53e4313a24c5c11df..d1bc7d7101045f07f6bef9dec4e5ffd3e24f0603 100644 (file)
@@ -130,7 +130,7 @@ public class WlanThermoNanoV1CommandHandler {
             }
         } else if (channelUID.getId().startsWith(CHANNEL_PITMASTER_1)) {
             if (data.getPitmaster() != null && data.getPitmaster().getPm() != null
-                    && data.getPitmaster().getPm().size() > 0) {
+                    && !data.getPitmaster().getPm().isEmpty()) {
                 Pm pm = data.getPitmaster().getPm().get(0);
                 switch (channelUID.getIdWithoutGroup()) {
                     case CHANNEL_PITMASTER_CHANNEL_ID:
@@ -175,9 +175,9 @@ public class WlanThermoNanoV1CommandHandler {
                         }
                         return false;
                     case CHANNEL_MIN:
-                        if (command instanceof QuantityType) {
+                        if (command instanceof QuantityType quantityCommand) {
                             try {
-                                channel.setMin(requireNonNull(((QuantityType<?>) command).toUnit(unit)).doubleValue());
+                                channel.setMin(requireNonNull(quantityCommand.toUnit(unit)).doubleValue());
                                 return true;
                             } catch (WlanThermoInputException ignore) {
                                 return false;
@@ -185,9 +185,9 @@ public class WlanThermoNanoV1CommandHandler {
                         }
                         return false;
                     case CHANNEL_MAX:
-                        if (command instanceof QuantityType) {
+                        if (command instanceof QuantityType quantityCommand) {
                             try {
-                                channel.setMax(requireNonNull(((QuantityType<?>) command).toUnit(unit)).doubleValue());
+                                channel.setMax(requireNonNull(quantityCommand.toUnit(unit)).doubleValue());
                                 return true;
                             } catch (WlanThermoInputException ignore) {
                                 return false;
@@ -219,8 +219,8 @@ public class WlanThermoNanoV1CommandHandler {
                         }
                         return false;
                     case CHANNEL_COLOR_NAME:
-                        if (command instanceof StringType) {
-                            channel.setColor(WlanThermoNanoV1Util.toHex(((StringType) command).toString()));
+                        if (command instanceof StringType stringCommand) {
+                            channel.setColor(WlanThermoNanoV1Util.toHex(stringCommand.toString()));
                             return true;
                         }
                         return false;
@@ -228,7 +228,7 @@ public class WlanThermoNanoV1CommandHandler {
             }
         } else if (channelUID.getId().startsWith(CHANNEL_PITMASTER_1)) {
             if (data.getPitmaster() != null && data.getPitmaster().getPm() != null
-                    && data.getPitmaster().getPm().size() > 0) {
+                    && !data.getPitmaster().getPm().isEmpty()) {
                 Pm pm = data.getPitmaster().getPm().get(0);
                 switch (channelUID.getIdWithoutGroup()) {
                     case CHANNEL_PITMASTER_CHANNEL_ID:
@@ -246,8 +246,8 @@ public class WlanThermoNanoV1CommandHandler {
                         }
                     case CHANNEL_PITMASTER_STATE:
                         String state = ((StringType) command).toString();
-                        if (state.equalsIgnoreCase("off") || state.equalsIgnoreCase("manual")
-                                || state.equalsIgnoreCase("auto")) {
+                        if ("off".equalsIgnoreCase(state) || "manual".equalsIgnoreCase(state)
+                                || "auto".equalsIgnoreCase(state)) {
                             pm.setTyp(state);
                             return true;
                         }
@@ -260,7 +260,6 @@ public class WlanThermoNanoV1CommandHandler {
 
     public static String getTrigger(ChannelUID channelUID, Data data)
             throws WlanThermoUnknownChannelException, WlanThermoInputException {
-
         String groupId = requireNonNull(channelUID.getGroupId());
         List<Channel> channelList = data.getChannel();
 
index 4adcf0641d5cae16885e87cb909cf4db27a4180c..ed28ae929f7e48482ff91b56f4060758346e33e9 100644 (file)
@@ -52,8 +52,8 @@ public class WLedActions implements ThingActions {
     }
 
     public static void savePreset(@Nullable ThingActions actions, int presetNumber) {
-        if (actions instanceof WLedActions) {
-            ((WLedActions) actions).savePreset(presetNumber, "");
+        if (actions instanceof WLedActions wLedActions) {
+            wLedActions.savePreset(presetNumber, "");
         } else {
             throw new IllegalArgumentException("Instance is not a WLED class.");
         }
@@ -70,8 +70,8 @@ public class WLedActions implements ThingActions {
     }
 
     public static void savePreset(@Nullable ThingActions actions, int presetNumber, String presetName) {
-        if (actions instanceof WLedActions) {
-            ((WLedActions) actions).savePreset(presetNumber, presetName);
+        if (actions instanceof WLedActions wLedActions) {
+            wLedActions.savePreset(presetNumber, presetName);
         } else {
             throw new IllegalArgumentException("Instance is not a WLED class.");
         }
index ea68130d02e5733201237849299eeb4506749e41..c285337a8dfdbe46e54dcfb6a515c4f589a278ca 100644 (file)
@@ -85,7 +85,7 @@ public class WLedDiscoveryService implements MDNSDiscoveryParticipant {
         if (!name.contains("wled")) {
             return null;
         }
-        String address[] = service.getURLs();
+        String[] address = service.getURLs();
         if ((address == null) || address.length < 1) {
             logger.debug("WLED discovered with empty IP address-{}", service);
             return null;
index aa5086d50f679bb30718e430a580cd451af916a6..0a5d162a39d29ee64d578b2c912d578ba373521d 100644 (file)
@@ -84,8 +84,8 @@ public class WLedSegmentDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof WLedBridgeHandler) {
-            bridgeHandler = (WLedBridgeHandler) handler;
+        if (handler instanceof WLedBridgeHandler wLedBridgeHandler) {
+            bridgeHandler = wLedBridgeHandler;
             bridgeUID = bridgeHandler.getThing().getUID();
         }
     }
index fd05bc9bb79cb47c54d37ccbab73f6b2d93a17f1..57e83cb0ab1f4104b2442036e7a887c10f61da99 100644 (file)
@@ -218,7 +218,7 @@ public class WledApiV084 implements WledApi {
             fxOptions.add(new StateOption(Integer.toString(counter++), value));
         }
         if (handler.config.sortEffects) {
-            fxOptions.sort(Comparator.comparing(o -> o.getValue().equals("0") ? "" : o.getLabel()));
+            fxOptions.sort(Comparator.comparing(o -> "0".equals(o.getValue()) ? "" : o.getLabel()));
         }
         return fxOptions;
     }
@@ -231,7 +231,7 @@ public class WledApiV084 implements WledApi {
             palleteOptions.add(new StateOption(Integer.toString(counter++), value));
         }
         if (handler.config.sortPalettes) {
-            palleteOptions.sort(Comparator.comparing(o -> o.getValue().equals("0") ? "" : o.getLabel()));
+            palleteOptions.sort(Comparator.comparing(o -> "0".equals(o.getValue()) ? "" : o.getLabel()));
         }
         return palleteOptions;
     }
@@ -241,7 +241,7 @@ public class WledApiV084 implements WledApi {
         state.infoResponse = getInfo();
         String temp = state.infoResponse.ver;
         logger.debug("Firmware for WLED is ver:{}", temp);
-        temp = temp.replaceAll("\\.", "");
+        temp = temp.replace(".", "");
         if (temp.length() > 4) {
             temp = temp.substring(0, 4);
         }
index a19df70e64a3873ec784b4d6695f3d3e99c17f4d..be26b441a04fb25535c6b86800b0196c5bb3d826 100644 (file)
@@ -148,12 +148,12 @@ public class WLedBridgeHandler extends BaseBridgeHandler {
                 case CHANNEL_GLOBAL_BRIGHTNESS:
                     if (command instanceof OnOffType) {
                         localApi.setGlobalOn(OnOffType.ON.equals(command));
-                    } else if (command instanceof PercentType) {
+                    } else if (command instanceof PercentType percentCommand) {
                         if (PercentType.ZERO.equals(command)) {
                             localApi.setGlobalOn(false);
                             return;
                         }
-                        localApi.setGlobalBrightness((PercentType) command);
+                        localApi.setGlobalBrightness(percentCommand);
                     }
                     break;
                 case CHANNEL_SLEEP:
@@ -163,18 +163,18 @@ public class WLedBridgeHandler extends BaseBridgeHandler {
                     localApi.setSleepMode(command.toString());
                     break;
                 case CHANNEL_SLEEP_BRIGHTNESS:
-                    if (command instanceof PercentType) {
-                        localApi.setSleepTargetBrightness((PercentType) command);
+                    if (command instanceof PercentType percentCommand) {
+                        localApi.setSleepTargetBrightness(percentCommand);
                     }
                     break;
                 case CHANNEL_SLEEP_DURATION:
-                    if (command instanceof QuantityType) {
-                        QuantityType<?> minutes = ((QuantityType<?>) command).toUnit(Units.MINUTE);
+                    if (command instanceof QuantityType quantityCommand) {
+                        QuantityType<?> minutes = quantityCommand.toUnit(Units.MINUTE);
                         if (minutes != null) {
                             localApi.setSleepDuration(new BigDecimal(minutes.intValue()));
                         }
-                    } else if (command instanceof DecimalType) {
-                        localApi.setSleepDuration(new BigDecimal(((DecimalType) command).intValue()));
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        localApi.setSleepDuration(new BigDecimal(decimalCommand.intValue()));
                     }
                     break;
                 case CHANNEL_PLAYLISTS:
@@ -193,26 +193,24 @@ public class WLedBridgeHandler extends BaseBridgeHandler {
                     localApi.setPreset(command.toString());
                     break;
                 case CHANNEL_TRANS_TIME:
-                    if (command instanceof QuantityType) {
-                        QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(Units.SECOND);
+                    if (command instanceof QuantityType quantityCommand) {
+                        QuantityType<?> seconds = quantityCommand.toUnit(Units.SECOND);
                         if (seconds != null) {
                             localApi.setTransitionTime(new BigDecimal(seconds.multiply(BigDecimal.TEN).intValue()));
                         }
-                    } else if (command instanceof DecimalType) {
-                        localApi.setTransitionTime(
-                                new BigDecimal(((DecimalType) command).intValue()).multiply(BigDecimal.TEN));
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        localApi.setTransitionTime(new BigDecimal(decimalCommand.intValue()).multiply(BigDecimal.TEN));
                     }
                     break;
                 case CHANNEL_PRESET_DURATION:// ch removed in firmware 0.13.0 and newer
-                    if (command instanceof QuantityType) {
-                        QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(Units.SECOND);
+                    if (command instanceof QuantityType quantityCommand) {
+                        QuantityType<?> seconds = quantityCommand.toUnit(Units.SECOND);
                         if (seconds != null) {
                             BigDecimal bigTemp = new BigDecimal(seconds.intValue()).multiply(new BigDecimal(1000));
                             localApi.sendGetRequest("/win&PT=" + bigTemp.intValue());
                         }
-                    } else if (command instanceof DecimalType) {
-                        BigDecimal bigTemp = new BigDecimal(((DecimalType) command).intValue())
-                                .multiply(new BigDecimal(1000));
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        BigDecimal bigTemp = new BigDecimal(decimalCommand.intValue()).multiply(new BigDecimal(1000));
                         localApi.sendGetRequest("/win&PT=" + bigTemp.intValue());
                     }
                     break;
index 9f0d962fad2334a40ce9253b4dd8fa088a08831c..c28db192ca3b454aee706ce81313c6639bb1bcf6 100644 (file)
@@ -112,40 +112,38 @@ public class WLedSegmentHandler extends BaseThingHandler {
                 case CHANNEL_SEGMENT_BRIGHTNESS:
                     if (command instanceof OnOffType) {
                         localApi.setMasterOn(OnOffType.ON.equals(command), config.segmentIndex);
-                    } else if (command instanceof PercentType) {
+                    } else if (command instanceof PercentType percentCommand) {
                         if (PercentType.ZERO.equals(command)) {
                             localApi.setMasterOn(false, config.segmentIndex);
                             return;
                         }
-                        localApi.setMasterBrightness((PercentType) command, config.segmentIndex);
+                        localApi.setMasterBrightness(percentCommand, config.segmentIndex);
                     }
                     break;
                 case CHANNEL_MIRROR:
                     localApi.setMirror(OnOffType.ON.equals(command), config.segmentIndex);
                     break;
                 case CHANNEL_SPACING:
-                    if (command instanceof DecimalType) {
-                        localApi.setSpacing(((DecimalType) command).intValue(), config.segmentIndex);
+                    if (command instanceof DecimalType decimalCommand) {
+                        localApi.setSpacing(decimalCommand.intValue(), config.segmentIndex);
                     }
                     break;
                 case CHANNEL_GROUPING:
-                    if (command instanceof DecimalType) {
-                        localApi.setGrouping(((DecimalType) command).intValue(), config.segmentIndex);
+                    if (command instanceof DecimalType decimalCommand) {
+                        localApi.setGrouping(decimalCommand.intValue(), config.segmentIndex);
                     }
                     break;
                 case CHANNEL_REVERSE:
                     localApi.setReverse(OnOffType.ON.equals(command), config.segmentIndex);
                     break;
                 case CHANNEL_PRIMARY_WHITE:
-                    if (command instanceof PercentType) {
-                        localApi.sendGetRequest(
-                                "/win&W=" + ((PercentType) command).toBigDecimal().multiply(BIG_DECIMAL_2_55));
+                    if (command instanceof PercentType percentCommand) {
+                        localApi.sendGetRequest("/win&W=" + percentCommand.toBigDecimal().multiply(BIG_DECIMAL_2_55));
                     }
                     break;
                 case CHANNEL_SECONDARY_WHITE:
-                    if (command instanceof PercentType) {
-                        localApi.sendGetRequest(
-                                "/win&W2=" + ((PercentType) command).toBigDecimal().multiply(BIG_DECIMAL_2_55));
+                    if (command instanceof PercentType percentCommand) {
+                        localApi.sendGetRequest("/win&W2=" + percentCommand.toBigDecimal().multiply(BIG_DECIMAL_2_55));
                     }
                     break;
                 case CHANNEL_MASTER_CONTROLS:
@@ -169,50 +167,48 @@ public class WLedSegmentHandler extends BaseThingHandler {
                                 localApi.sendGetRequest("/win&TT=1000&A=0");
                             }
                         }
-                    } else if (command instanceof HSBType) {
-                        if ((((HSBType) command).getBrightness()).equals(PercentType.ZERO)) {
+                    } else if (command instanceof HSBType hsbCommand) {
+                        if ((hsbCommand.getBrightness()).equals(PercentType.ZERO)) {
                             localApi.setMasterOn(false, config.segmentIndex);
                             return;
                         }
                         localApi.setGlobalOn(true);
-                        primaryColor = (HSBType) command;
+                        primaryColor = hsbCommand;
                         if (primaryColor.getSaturation().intValue() < bridgeHandler.config.saturationThreshold
                                 && bridgeHandler.hasWhite) {
-                            localApi.setWhiteOnly((PercentType) command, config.segmentIndex);
+                            localApi.setWhiteOnly(hsbCommand, config.segmentIndex);
                         } else if (primaryColor.getSaturation().intValue() == 32
                                 && primaryColor.getHue().intValue() == 36 && bridgeHandler.hasWhite) {
-                            localApi.setWhiteOnly((PercentType) command, config.segmentIndex);
+                            localApi.setWhiteOnly(hsbCommand, config.segmentIndex);
                         } else {
-                            localApi.setMasterHSB((HSBType) command, config.segmentIndex);
+                            localApi.setMasterHSB(hsbCommand, config.segmentIndex);
                         }
-                    } else if (command instanceof PercentType) {
-                        localApi.setMasterBrightness((PercentType) command, config.segmentIndex);
+                    } else if (command instanceof PercentType percentCommand) {
+                        localApi.setMasterBrightness(percentCommand, config.segmentIndex);
                     }
                     return;
                 case CHANNEL_PRIMARY_COLOR:
-                    if (command instanceof HSBType) {
-                        primaryColor = (HSBType) command;
-                    } else if (command instanceof PercentType) {
-                        primaryColor = new HSBType(primaryColor.getHue(), primaryColor.getSaturation(),
-                                ((PercentType) command));
+                    if (command instanceof HSBType hsbCommand) {
+                        primaryColor = hsbCommand;
+                    } else if (command instanceof PercentType percentCommand) {
+                        primaryColor = new HSBType(primaryColor.getHue(), primaryColor.getSaturation(), percentCommand);
                     }
                     localApi.setPrimaryColor(primaryColor, config.segmentIndex);
                     return;
                 case CHANNEL_SECONDARY_COLOR:
-                    if (command instanceof HSBType) {
-                        secondaryColor = (HSBType) command;
-                    } else if (command instanceof PercentType) {
+                    if (command instanceof HSBType hsbCommand) {
+                        secondaryColor = hsbCommand;
+                    } else if (command instanceof PercentType percentCommand) {
                         secondaryColor = new HSBType(secondaryColor.getHue(), secondaryColor.getSaturation(),
-                                ((PercentType) command));
+                                percentCommand);
                     }
                     localApi.setSecondaryColor(secondaryColor, config.segmentIndex);
                     return;
                 case CHANNEL_THIRD_COLOR:
-                    if (command instanceof HSBType) {
-                        thirdColor = (HSBType) command;
-                    } else if (command instanceof PercentType) {
-                        thirdColor = new HSBType(thirdColor.getHue(), thirdColor.getSaturation(),
-                                ((PercentType) command));
+                    if (command instanceof HSBType hsbCommand) {
+                        thirdColor = hsbCommand;
+                    } else if (command instanceof PercentType percentCommand) {
+                        thirdColor = new HSBType(thirdColor.getHue(), thirdColor.getSaturation(), percentCommand);
                     }
                     localApi.setTertiaryColor(thirdColor, config.segmentIndex);
                     return;
index d3bd14bcf86199491b2e1285869476c7d0145cd6..2fc890fc38db14c1e94a626812a2c8e9185bfd45 100644 (file)
@@ -125,7 +125,6 @@ public class WolfSmartsetApi {
                 logger.trace("Login succeeded but failed to create session {}", loginFailedCounter);
                 return false;
             }
-
         } catch (WolfSmartsetCloudException e) {
             logger.debug("Error logging on to Wolf Smartset ({}): {}", loginFailedCounter, e.getMessage());
             loginFailedCounter++;
index 010ab5f016e48a4656e88fd29e8defef231f57b8..dce929fbdf53415dc400758556795c68ab8fc4dc 100644 (file)
@@ -56,8 +56,8 @@ public class WolfSmartsetAccountDiscoveryService extends AbstractDiscoveryServic
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof WolfSmartsetAccountBridgeHandler) {
-            this.bridgeHandler = (WolfSmartsetAccountBridgeHandler) handler;
+        if (handler instanceof WolfSmartsetAccountBridgeHandler accountBridgeHandler) {
+            this.bridgeHandler = accountBridgeHandler;
         }
     }
 
index 521b2927773d61dac9b8fdc702cee32242264319..d62b4a36ef871a370a4e595f70e781947e4db767 100644 (file)
@@ -57,8 +57,8 @@ public class WolfSmartsetSystemDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof WolfSmartsetSystemBridgeHandler) {
-            this.bridgeHandler = (WolfSmartsetSystemBridgeHandler) handler;
+        if (handler instanceof WolfSmartsetSystemBridgeHandler systemBridgeHandler) {
+            this.bridgeHandler = systemBridgeHandler;
         }
     }
 
@@ -151,7 +151,7 @@ public class WolfSmartsetSystemDiscoveryService extends AbstractDiscoveryService
         properties.put(CONFIG_UNIT_ID, unit.menuItemTabViewDTO.bundleId.toString());
         var tabName = unit.menuItemTabViewDTO.tabName;
         var menuName = unit.subMenuEntryDTO.getName();
-        tabName = tabName.isEmpty() || tabName.equalsIgnoreCase("NULL") || menuName.equalsIgnoreCase(tabName) ? ""
+        tabName = tabName.isEmpty() || "NULL".equalsIgnoreCase(tabName) || menuName.equalsIgnoreCase(tabName) ? ""
                 : "-" + tabName;
 
         return DiscoveryResultBuilder.create(unitUID).withProperties(properties)
index 45c5e20b47037b79bab6666edc82a0bb70b65ae1..dc1927641e0670349fffb8bdc5a195d8da29d021 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.wolfsmartset.internal.handler;
 import static org.openhab.binding.wolfsmartset.internal.WolfSmartsetBindingConstants.CONFIG_SYSTEM_ID;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -126,7 +125,7 @@ public class WolfSmartsetAccountBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(WolfSmartsetAccountDiscoveryService.class);
+        return Set.of(WolfSmartsetAccountDiscoveryService.class);
     }
 
     @Override
@@ -212,7 +211,7 @@ public class WolfSmartsetAccountBridgeHandler extends BaseBridgeHandler {
 
                 var systemConfigs = systemHandlers.values().stream().map(s -> s.getSystemConfig())
                         .filter(s -> s != null).collect(Collectors.toSet());
-                if (systemConfigs != null && systemConfigs.size() > 0) {
+                if (systemConfigs != null && !systemConfigs.isEmpty()) {
                     var systemStates = api.getSystemState(systemConfigs);
                     if (systemStates != null) {
                         for (var systemState : systemStates) {
index 7e7bd004211e4d8e8f5b6e434716b3b70aea091d..7b49ca4f2ccc120819434ed70b7781c7b5342c43 100644 (file)
@@ -16,9 +16,9 @@ import static org.openhab.binding.wolfsmartset.internal.WolfSmartsetBindingConst
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -77,7 +77,7 @@ public class WolfSmartsetSystemBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(WolfSmartsetSystemDiscoveryService.class);
+        return Set.of(WolfSmartsetSystemDiscoveryService.class);
     }
 
     @Override
index 5d16632c530406df8173d0cd3b3a2bec895ceffd..116ee1f3df29eaf9f71b36b0700cdeab28891044 100644 (file)
@@ -77,6 +77,7 @@ public class WundergroundUpdateReceiverServlet extends HttpServlet
         active = discoveryService.isBackgroundDiscoveryEnabled();
     }
 
+    @Override
     public boolean isActive() {
         synchronized (LOCK) {
             return this.active;
@@ -127,6 +128,7 @@ public class WundergroundUpdateReceiverServlet extends HttpServlet
     }
 
     @Deactivate
+    @Override
     public void disable() {
         errorDetail = "";
         active = false;
index 1e22675638e2ae84fdafe0bfed5a83b26ea57c3a..42be283b80b8ea53314bc8f50df35a56857610fa 100644 (file)
@@ -74,9 +74,18 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     @Test
     void programmaticChannelsAreAddedCorrectlyOnce() {
         // Given
-        final String queryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "humidity=74&" + "AqPM2.5=30&"
-                + "windspdmph_avg2m=10&" + "dateutc=2021-02-07%2014:04:03&" + "softwaretype=WH2600%20V2.2.8&"
-                + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String queryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                humidity=74&\
+                AqPM2.5=30&\
+                windspdmph_avg2m=10&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request = new MetaData.Request("GET",
                 new HttpURI("http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + queryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -128,12 +137,33 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     void aRequestWithAnUnregisteredStationidIsAddedToTheQueueOnce()
             throws ServletException, NamespaceException, IOException {
         // Given
-        final String queryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "tempf=26.1&" + "humidity=74&" + "dewptf=18.9&"
-                + "windchillf=26.1&" + "winddir=14&" + "windspeedmph=1.34&" + "windgustmph=2.46&" + "rainin=0.00&"
-                + "dailyrainin=0.00&" + "weeklyrainin=0.00&" + "monthlyrainin=0.08&" + "yearlyrainin=3.06&"
-                + "solarradiation=42.24&" + "UV=1&indoortempf=69.3&" + "indoorhumidity=32&" + "baromin=30.39&"
-                + "AqNOX=21&" + "lowbatt=1&" + "dateutc=2021-02-07%2014:04:03&" + "softwaretype=WH2600%20V2.2.8&"
-                + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String queryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                tempf=26.1&\
+                humidity=74&\
+                dewptf=18.9&\
+                windchillf=26.1&\
+                winddir=14&\
+                windspeedmph=1.34&\
+                windgustmph=2.46&\
+                rainin=0.00&\
+                dailyrainin=0.00&\
+                weeklyrainin=0.00&\
+                monthlyrainin=0.08&\
+                yearlyrainin=3.06&\
+                solarradiation=42.24&\
+                UV=1&indoortempf=69.3&\
+                indoorhumidity=32&\
+                baromin=30.39&\
+                AqNOX=21&\
+                lowbatt=1&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         WundergroundUpdateReceiverDiscoveryService discoveryService = mock(
                 WundergroundUpdateReceiverDiscoveryService.class);
         WundergroundUpdateReceiverServlet sut = new WundergroundUpdateReceiverServlet(discoveryService);
@@ -164,9 +194,21 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     @Test
     void multipleIndexedParametersOfTheSameChanneltypeAreCorrectlyDiscovered() throws IOException {
         // Given
-        final String queryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "temp1f=26.1&" + "humidity=74&" + "temp2f=25.1&"
-                + "lowbatt=1&" + "soilmoisture1=78&" + "soilmoisture2=73&" + "dateutc=2021-02-07%2014:04:03&"
-                + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String queryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                temp1f=26.1&\
+                humidity=74&\
+                temp2f=25.1&\
+                lowbatt=1&\
+                soilmoisture1=78&\
+                soilmoisture2=73&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request = new MetaData.Request("GET",
                 new HttpURI("http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + queryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -209,9 +251,17 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     @Test
     void unregisteredChannelsAreAddedOnTheFlyWhenDiscovered() throws IOException {
         // Given
-        final String firstDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "tempf=26.1&" + "humidity=74&"
-                + "dateutc=2021-02-07%2014:04:03&" + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&"
-                + "realtime=1&" + "rtfreq=5";
+        final String firstDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                tempf=26.1&\
+                humidity=74&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request1 = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + firstDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -247,9 +297,19 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
         assertThat(before, hasItems(expectedBefore));
 
         // When
-        final String secondDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "lowbatt=1&" + "soilmoisture1=78&"
-                + "soilmoisture2=73&" + "solarradiation=42.24&" + "dateutc=2021-02-07%2014:04:03&"
-                + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String secondDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                lowbatt=1&\
+                soilmoisture1=78&\
+                soilmoisture2=73&\
+                solarradiation=42.24&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + secondDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -275,9 +335,17 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     @Test
     void unregisteredChannelsAreNotAddedOnUnmanagedThings() throws IOException {
         // Given
-        final String firstDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "tempf=26.1&" + "humidity=74&"
-                + "dateutc=2021-02-07%2014:04:03&" + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&"
-                + "realtime=1&" + "rtfreq=5";
+        final String firstDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                tempf=26.1&\
+                humidity=74&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request1 = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + firstDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -313,9 +381,19 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
         assertThat(before, hasItems(expectedBefore));
 
         // When
-        final String secondDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "lowbatt=1&" + "soilmoisture1=78&"
-                + "soilmoisture2=73&" + "solarradiation=42.24&" + "dateutc=2021-02-07%2014:04:03&"
-                + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String secondDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                lowbatt=1&\
+                soilmoisture1=78&\
+                soilmoisture2=73&\
+                solarradiation=42.24&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + secondDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -338,9 +416,17 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
     @Test
     void lastQueryTriggerIsMigratedSuccessfully() throws IOException {
         // Given
-        final String firstDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "tempf=26.1&" + "humidity=74&"
-                + "dateutc=2021-02-07%2014:04:03&" + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&"
-                + "realtime=1&" + "rtfreq=5";
+        final String firstDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                tempf=26.1&\
+                humidity=74&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request1 = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + firstDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
@@ -387,9 +473,19 @@ class WundergroundUpdateReceiverDiscoveryServiceTest {
         handler.dispose();
         handler.initialize();
 
-        final String secondDeviceQueryString = "ID=dfggger&" + "PASSWORD=XXXXXX&" + "lowbatt=1&" + "soilmoisture1=78&"
-                + "soilmoisture2=73&" + "solarradiation=42.24&" + "dateutc=2021-02-07%2014:04:03&"
-                + "softwaretype=WH2600%20V2.2.8&" + "action=updateraw&" + "realtime=1&" + "rtfreq=5";
+        final String secondDeviceQueryString = """
+                ID=dfggger&\
+                PASSWORD=XXXXXX&\
+                lowbatt=1&\
+                soilmoisture1=78&\
+                soilmoisture2=73&\
+                solarradiation=42.24&\
+                dateutc=2021-02-07%2014:04:03&\
+                softwaretype=WH2600%20V2.2.8&\
+                action=updateraw&\
+                realtime=1&\
+                rtfreq=5\
+                """;
         MetaData.Request request = new MetaData.Request("GET", new HttpURI(
                 "http://localhost" + WundergroundUpdateReceiverServlet.SERVLET_URL + "?" + secondDeviceQueryString),
                 HttpVersion.HTTP_1_1, new HttpFields());
index e31f40ef4293e979116d6c0a83807d5a16873521..2db340dabe51cd9c5db9b79938f4955dff323bf2 100644 (file)
@@ -81,8 +81,8 @@ public class XmlTVDiscoveryService extends AbstractDiscoveryService implements T
 
     @Override
     public void setThingHandler(ThingHandler handler) {
-        if (handler instanceof XmlTVHandler) {
-            this.handler = (XmlTVHandler) handler;
+        if (handler instanceof XmlTVHandler tvHandler) {
+            this.handler = tvHandler;
         }
     }
 
index 63ad225a8457cb992457596c43982ea42d6f9b18..328fc572307ec575a1d379556541bc4ede58b252 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.xmltv.internal.handler;
 
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.time.Instant;
@@ -77,7 +76,7 @@ public class XmlTVHandler extends BaseBridgeHandler {
             XMLStreamReader xsr = null;
             try {
                 // This can take some seconds depending upon weight of the XmlTV source file
-                xsr = xif.createXMLStreamReader(new FileInputStream(new File(config.filePath)), config.encoding);
+                xsr = xif.createXMLStreamReader(new FileInputStream(config.filePath), config.encoding);
                 try {
                     Tv xmlFile = (Tv) unmarshaller.unmarshal(xsr);
                     // Remove all finished programmes
index 4812d2b25b99d680c7014e4f8cdacb1e932b4634..8c7de1346840a16e61f1506b9736a4b4158385b3 100644 (file)
@@ -77,8 +77,7 @@ public class Programme {
     }
 
     private long iso860DateToEpoch(String date) {
-        long epoch = ZonedDateTime.parse(date, XMLTV_DATE_FORMAT).toInstant().toEpochMilli();
-        return epoch;
+        return ZonedDateTime.parse(date, XMLTV_DATE_FORMAT).toInstant().toEpochMilli();
     }
 
     public List<Icon> getIcons() {
index db5283895bca8fe310cff18debfde5be59bece8e..f291c3a9f8e2f8aeaee13d89f3748ac494a323ad 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.xmppclient.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.openhab.binding.xmppclient.internal.handler.XMPPClientHandler;
@@ -32,8 +31,8 @@ import org.osgi.service.component.annotations.Component;
  */
 @Component(configurationPid = "binding.xmppclient", service = ThingHandlerFactory.class)
 public class XMPPClientHandlerFactory extends BaseThingHandlerFactory {
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(XMPPClientBindingConstants.BRIDGE_TYPE_XMPP);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(XMPPClientBindingConstants.BRIDGE_TYPE_XMPP);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index d28b9d63f86b9bfd3385d8a8a5bd7d907893267e..29aee5ba7099d70986568478dc4a37052b4d885d 100644 (file)
@@ -14,9 +14,9 @@ package org.openhab.binding.xmppclient.internal.handler;
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import org.jivesoftware.smack.SmackException;
@@ -57,7 +57,7 @@ public class XMPPClientHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(XMPPActions.class);
+        return Set.of(XMPPActions.class);
     }
 
     @Override
index a42eba855b7ffa71e0c737355e69e72c14eb6683..666dd35090e5d47f06af916ff3ba5c8da32004cb 100644 (file)
@@ -299,7 +299,7 @@ public class YamahaMusiccastHandler extends BaseThingHandler {
                     if (distributioninfo != null) {
                         responseCode = distributioninfo.getResponseCode();
                         localRole = distributioninfo.getRole();
-                        if (command.toString().equals("")) {
+                        if ("".equals(command.toString())) {
                             action = "unlink";
                             groupId = distributioninfo.getGroupId();
                         } else if (command.toString().contains("***")) {
@@ -354,12 +354,12 @@ public class YamahaMusiccastHandler extends BaseThingHandler {
                                         httpResponse = startDistribution(mclinkSetupServer);
                                         localDefaultAfterMCLink = getThing().getConfiguration()
                                                 .get("defaultAfterMCLink").toString();
-                                        httpResponse = setInput(localDefaultAfterMCLink.toString(), zone, this.host);
+                                        httpResponse = setInput(localDefaultAfterMCLink, zone, this.host);
                                     } else if ("".equals(mclinkSetupServer)) {
                                         // fallback in case client is removed from group by ending group on server side
                                         localDefaultAfterMCLink = getThing().getConfiguration()
                                                 .get("defaultAfterMCLink").toString();
-                                        httpResponse = setInput(localDefaultAfterMCLink.toString(), zone, this.host);
+                                        httpResponse = setInput(localDefaultAfterMCLink, zone, this.host);
                                     }
                                 }
                             }
@@ -795,8 +795,8 @@ public class YamahaMusiccastHandler extends BaseThingHandler {
                         JsonObject presetObject = pr.getAsJsonObject();
                         String text = presetObject.get("text").getAsString();
                         if (!"".equals(text)) {
-                            optionsPresets.add(new StateOption(String.valueOf(presetCounter),
-                                    "#" + String.valueOf(presetCounter) + " " + text));
+                            optionsPresets.add(
+                                    new StateOption(String.valueOf(presetCounter), "#" + presetCounter + " " + text));
                             if (inputText.equals(text)) {
                                 currentPreset = presetCounter;
                             }
index 59e4808f11aee4295a681253c09143b3873f1e57..c2557ddbc8dfd1d13b31620f3fd31ca65ebb59d8 100644 (file)
@@ -16,11 +16,11 @@ import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingC
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -49,7 +49,7 @@ public class ChannelsTypeProviderAvailableInputs implements ChannelTypeProvider,
 
     @Override
     public Collection<ChannelType> getChannelTypes(@Nullable Locale locale) {
-        return Collections.singleton(channelType);
+        return Set.of(channelType);
     }
 
     @Override
index 37bbe6966d21cfa28f7b1133ee129afb164ab42c..901cf74056424389dd964ffc112ed7cc1258dd45 100644 (file)
@@ -16,9 +16,9 @@ import static java.util.stream.Collectors.toList;
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
+import java.util.Set;
 import java.util.stream.IntStream;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -49,7 +49,7 @@ public class ChannelsTypeProviderPreset implements ChannelTypeProvider, ThingHan
 
     @Override
     public Collection<ChannelType> getChannelTypes(@Nullable Locale locale) {
-        return Collections.singleton(channelType);
+        return Set.of(channelType);
     }
 
     @Override
index 02163142578b28a0f5f0992de0761194e70f6b3f..4a303b5badb1e604b3db77124d3b4692fef04fe7 100644 (file)
@@ -35,8 +35,8 @@ public class YamahaReceiverBindingConstants {
     public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "yamahaAV");
     public static final ThingTypeUID ZONE_THING_TYPE = new ThingTypeUID(BINDING_ID, "zone");
 
-    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(BRIDGE_THING_TYPE);
-    public static final Set<ThingTypeUID> ZONE_THING_TYPES_UIDS = Collections.singleton(ZONE_THING_TYPE);
+    public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE);
+    public static final Set<ThingTypeUID> ZONE_THING_TYPES_UIDS = Set.of(ZONE_THING_TYPE);
 
     // List of channel IDs for zone control (except power which is also a non-zone/bridge channel)
     public static final String CHANNEL_POWER = "power";
index 2284ad7fc1ccc8ebaabe09d2f8423088afd5fc04..e3059ff47c0cb5eeb85aa7895c15313f542dde57 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingC
 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Configs.CONFIG_HOST_NAME;
 
 import java.net.URL;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,7 @@ public class YamahaDiscoveryParticipant implements UpnpDiscoveryParticipant {
 
     private final Logger logger = LoggerFactory.getLogger(YamahaDiscoveryParticipant.class);
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(BRIDGE_THING_TYPE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(BRIDGE_THING_TYPE);
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
index 3a8b150e598e9bc324e4b1f7be2cf6d59ca5ea12..81dc9642fcd1ba3878944db738cc03bf2fb3244c 100644 (file)
@@ -16,10 +16,10 @@ import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingC
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -316,7 +316,7 @@ public class YamahaBridgeHandler extends BaseBridgeHandler
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ZoneDiscoveryService.class);
+        return Set.of(ZoneDiscoveryService.class);
     }
 
     /**
@@ -336,7 +336,7 @@ public class YamahaBridgeHandler extends BaseBridgeHandler
                 bridgeConfig.getPort());
 
         Optional<String> host = bridgeConfig.getHostWithPort();
-        if (!host.isPresent()) {
+        if (host.isEmpty()) {
             String msg = "Host or port not set. Double check your thing settings.";
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, msg);
             logger.warn(msg);
index 9603243f91a5ad8db4b5537291c35ab5ae0b0b03..3efc129fb2a5ef06ac893ea4a8b58839e65ca5fd 100644 (file)
@@ -145,8 +145,7 @@ public class DeviceInformationXML implements DeviceInformation {
 
     private boolean isFeatureSupported(Node node, String name) {
         String value = getNodeContentOrEmpty(node, name);
-        boolean supported = "1".equals(value) || "Available".equals(value);
-        return supported;
+        return "1".equals(value) || "Available".equals(value);
     }
 
     private <T> void checkFeature(Node node, String name, T value, Set<T> set) {
index e4756630e7f16dc0f65936a039095ab3ef95b17f..c383ec6b2326b59b75954ea372743de88791eb19 100644 (file)
@@ -205,8 +205,7 @@ public class InputWithNavigationControlXML extends AbstractInputControlXML imple
         if (sameMenu) {
             if (!selectItem(selectItemName)) {
                 observer.navigationError("Item '" + selectItemName + "' doesn't exist in menu " + state.menuName
-                        + " at level " + String.valueOf(state.menuLayer) + ". Available options are: "
-                        + state.getAllItemLabels());
+                        + " at level " + state.menuLayer + ". Available options are: " + state.getAllItemLabels());
             }
             return;
         }
@@ -220,8 +219,7 @@ public class InputWithNavigationControlXML extends AbstractInputControlXML imple
         for (String pathElement : pathArr) {
             if (!selectItem(pathElement)) {
                 observer.navigationError("Item '" + pathElement + "' doesn't exist in menu " + state.menuName
-                        + " at level " + String.valueOf(state.menuLayer) + ". Available options are: "
-                        + state.getAllItemLabels());
+                        + " at level " + state.menuLayer + ". Available options are: " + state.getAllItemLabels());
                 return;
             }
         }
@@ -258,8 +256,7 @@ public class InputWithNavigationControlXML extends AbstractInputControlXML imple
 
             int index = findItemOnCurrentPage(name);
             if (index > 0) {
-                com.send(wrInput(
-                        "<List_Control><Direct_Sel>Line_" + String.valueOf(index) + "</Direct_Sel></List_Control>"));
+                com.send(wrInput("<List_Control><Direct_Sel>Line_" + index + "</Direct_Sel></List_Control>"));
                 update();
                 return true;
             }
index 54ea99516b7d0c437d5e44a7ad1920d9d811c1a8..88ca8b555bdf93b48fbf310ec6e2d2892155ab46 100644 (file)
@@ -84,8 +84,7 @@ public class XMLProtocolService {
         if (doc.getFirstChild() == null) {
             throw new ReceivedMessageParseException("The command '" + cmd + "' failed: " + response);
         }
-        Node content = XMLUtils.getNode(doc.getFirstChild(), path);
-        return content;
+        return XMLUtils.getNode(doc.getFirstChild(), path);
     }
 
     /**
index bd67650af9815277b64730467455b758c5fd87a3..ee172056ef705017a046196f7432a98c5b1172f7 100644 (file)
@@ -24,7 +24,7 @@ public class NavigationControlState implements Invalidateable {
     public int menuLayer = -1;
     public int currentLine = 0;
     public int maxLine = -1;
-    public String items[] = new String[InputWithNavigationControlXML.MAX_PER_PAGE];
+    public String[] items = new String[InputWithNavigationControlXML.MAX_PER_PAGE];
 
     public String getCurrentItemName() {
         if (currentLine < 1 || currentLine > items.length) {
index 8543fcdae9f1496d0dbf73f58df55407f649a825..5b6fdea950058cb563fa5c6c4f51a9bbc644a608 100644 (file)
@@ -180,46 +180,44 @@ public abstract class YeelightHandlerBase extends BaseThingHandler
         }
         switch (channelUID.getId()) {
             case CHANNEL_BRIGHTNESS:
-                if (command instanceof PercentType) {
-                    handlePercentMessage((PercentType) command);
-                } else if (command instanceof OnOffType) {
-                    handleOnOffCommand((OnOffType) command);
-                } else if (command instanceof IncreaseDecreaseType) {
-                    handleIncreaseDecreaseBrightnessCommand((IncreaseDecreaseType) command);
+                if (command instanceof PercentType percentCommand) {
+                    handlePercentMessage(percentCommand);
+                } else if (command instanceof OnOffType onOffCommand) {
+                    handleOnOffCommand(onOffCommand);
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    handleIncreaseDecreaseBrightnessCommand(increaseDecreaseCommand);
                 }
                 break;
             case CHANNEL_COLOR:
-                if (command instanceof HSBType) {
-                    HSBType hsbCommand = (HSBType) command;
+                if (command instanceof HSBType hsbCommand) {
                     if (hsbCommand.getBrightness().intValue() == 0) {
                         handleOnOffCommand(OnOffType.OFF);
                     } else {
                         handleHSBCommand(hsbCommand);
                     }
-                } else if (command instanceof PercentType) {
-                    handlePercentMessage((PercentType) command);
-                } else if (command instanceof OnOffType) {
-                    handleOnOffCommand((OnOffType) command);
-                } else if (command instanceof IncreaseDecreaseType) {
-                    handleIncreaseDecreaseBrightnessCommand((IncreaseDecreaseType) command);
+                } else if (command instanceof PercentType percentCommand) {
+                    handlePercentMessage(percentCommand);
+                } else if (command instanceof OnOffType onOffCommand) {
+                    handleOnOffCommand(onOffCommand);
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    handleIncreaseDecreaseBrightnessCommand(increaseDecreaseCommand);
                 }
                 break;
             case CHANNEL_COLOR_TEMPERATURE:
-                if (command instanceof PercentType) {
-                    handleColorTemperatureCommand((PercentType) command);
-                } else if (command instanceof IncreaseDecreaseType) {
-                    handleIncreaseDecreaseBrightnessCommand((IncreaseDecreaseType) command);
+                if (command instanceof PercentType percentCommand) {
+                    handleColorTemperatureCommand(percentCommand);
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    handleIncreaseDecreaseBrightnessCommand(increaseDecreaseCommand);
                 }
                 break;
 
             case CHANNEL_BACKGROUND_COLOR:
-                if (command instanceof HSBType) {
-                    HSBType hsbCommand = (HSBType) command;
+                if (command instanceof HSBType hsbCommand) {
                     handleBackgroundHSBCommand(hsbCommand);
-                } else if (command instanceof PercentType) {
-                    handleBackgroundBrightnessPercentMessage((PercentType) command);
-                } else if (command instanceof OnOffType) {
-                    handleBackgroundOnOffCommand((OnOffType) command);
+                } else if (command instanceof PercentType percentCommand) {
+                    handleBackgroundBrightnessPercentMessage(percentCommand);
+                } else if (command instanceof OnOffType onOffCommand) {
+                    handleBackgroundOnOffCommand(onOffCommand);
                 }
                 break;
             case CHANNEL_NIGHTLIGHT:
index fb9e5198626a3e34f4c52cd700df7e936ae74f14..36a3b4eb1dd02d77555d0a893e0476336a7b9190 100644 (file)
@@ -51,9 +51,9 @@ public class CeilingDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index 6f4b35871eaad966e23842aa7751f76ec6ba4511..7d425be9f2b240ec72ec1f58c4240639d94757f9 100644 (file)
@@ -51,9 +51,9 @@ public class CtBulbDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index 1709cccf935d6fd96043b105bf5b57e37e9e3976..4f87f619af047ba79ba7fb064e6064d132d6b126 100644 (file)
@@ -51,9 +51,9 @@ public class DesklampDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index f933e62493e9d0bf577df55791b23f08d9c30ba7..75622ce78db79841762f7ae13e80b7ef4be66996 100644 (file)
@@ -80,7 +80,7 @@ public abstract class DeviceBase {
         try {
             if (message.has("method")) {
                 String method = message.get("method").toString().replace("\"", "");
-                if (method.equals("props")) {// Property notify
+                if ("props".equals(method)) {// Property notify
                     String params = message.get("params").toString();
                     JsonObject propsObject = JsonParser.parseString(params).getAsJsonObject();
                     for (Entry<String, JsonElement> prop : propsObject.entrySet()) {
@@ -92,9 +92,9 @@ public abstract class DeviceBase {
 
                         switch (property) {
                             case POWER:
-                                if (prop.getValue().toString().equals("\"off\"")) {
+                                if ("\"off\"".equals(prop.getValue().toString())) {
                                     mDeviceStatus.setPowerOff(true);
-                                } else if (prop.getValue().toString().equals("\"on\"")) {
+                                } else if ("\"on\"".equals(prop.getValue().toString())) {
                                     mDeviceStatus.setPowerOff(false);
                                 }
                                 break;
@@ -222,7 +222,7 @@ public abstract class DeviceBase {
             } else if (message.has("id") && message.has("result")) {
                 // no method, but result : ["ok"]
                 JsonArray result = message.get("result").getAsJsonArray();
-                if (result.get(0).toString().equals("\"ok\"")) {
+                if ("\"ok\"".equals(result.get(0).toString())) {
                     logger.info("######### this is control command response, don't need to notify status change!");
                     needNotify = false;
                 }
index 13f533218a5a4b16972f69a4762ecdebbfaae062..027a8454967e973f64a992fae8544511c8858207 100644 (file)
@@ -49,9 +49,9 @@ public class MonoDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index a593c923f0f0b7f3e6e3d09582ed0aca61f6aab7..56466156cdf32db415a65a1d640e99f6dcfb5d77 100644 (file)
@@ -52,9 +52,9 @@ public class PitayaDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index e445188a643706b8eb15ffc00e7ab9d7bc900280..05eda32000d48054d0a1887faf1d9dd30c06ec25 100644 (file)
@@ -52,9 +52,9 @@ public class WonderDevice extends DeviceBase {
                     JsonArray status = result.get("result").getAsJsonArray();
 
                     // power:
-                    if (status.get(0).toString().equals("\"off\"")) {
+                    if ("\"off\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(true);
-                    } else if (status.get(0).toString().equals("\"on\"")) {
+                    } else if ("\"on\"".equals(status.get(0).toString())) {
                         mDeviceStatus.setPowerOff(false);
                     }
 
index 091ed07d3a53701281c54b4ce0f50afb73de63fb..91c68dbef27fd2bff2e6cb5c3b94ac0b2fa10fa9 100644 (file)
@@ -251,37 +251,36 @@ public class DeviceManager {
                     device.decreaseCt(action.intDuration());
                     break;
                 case background_color:
-                    if (device instanceof DeviceWithAmbientLight) {
+                    if (device instanceof DeviceWithAmbientLight light) {
                         final String[] split = action.strValue().split(",");
 
-                        ((DeviceWithAmbientLight) device).setBackgroundColor(Integer.parseInt(split[0]),
-                                Integer.parseInt(split[1]), action.intDuration());
+                        light.setBackgroundColor(Integer.parseInt(split[0]), Integer.parseInt(split[1]),
+                                action.intDuration());
                     }
                     break;
                 case background_brightness:
-                    if (device instanceof DeviceWithAmbientLight) {
-                        ((DeviceWithAmbientLight) device).setBackgroundBrightness(action.intValue(),
-                                action.intDuration());
+                    if (device instanceof DeviceWithAmbientLight light) {
+                        light.setBackgroundBrightness(action.intValue(), action.intDuration());
                     }
                     break;
                 case background_on:
-                    if (device instanceof DeviceWithAmbientLight) {
-                        ((DeviceWithAmbientLight) device).setBackgroundPower(true, action.intDuration());
+                    if (device instanceof DeviceWithAmbientLight light) {
+                        light.setBackgroundPower(true, action.intDuration());
                     }
                     break;
                 case background_off:
-                    if (device instanceof DeviceWithAmbientLight) {
-                        ((DeviceWithAmbientLight) device).setBackgroundPower(false, action.intDuration());
+                    if (device instanceof DeviceWithAmbientLight light) {
+                        light.setBackgroundPower(false, action.intDuration());
                     }
                     break;
                 case nightlight_off:
-                    if (device instanceof DeviceWithNightlight) {
-                        ((DeviceWithNightlight) device).toggleNightlightMode(false);
+                    if (device instanceof DeviceWithNightlight nightlight) {
+                        nightlight.toggleNightlightMode(false);
                     }
                     break;
                 case nightlight_on:
-                    if (device instanceof DeviceWithNightlight) {
-                        ((DeviceWithNightlight) device).toggleNightlightMode(true);
+                    if (device instanceof DeviceWithNightlight nightlight) {
+                        nightlight.toggleNightlightMode(true);
                     }
                     break;
                 default:
@@ -327,7 +326,7 @@ public class DeviceManager {
     }
 
     public static String getDefaultName(DeviceBase device) {
-        if (device.getDeviceModel() != null && !device.getDeviceName().equals("")) {
+        if (device.getDeviceModel() != null && !"".equals(device.getDeviceName())) {
             return device.getDeviceName();
         }
         switch (device.getDeviceType()) {
index 83fe75519ad8701ad1bdb676adc9af2e43f9e12a..be3656505c0b975691fe88e5924f76a09b74989c 100644 (file)
@@ -27,7 +27,7 @@ public class YIOremoteBindingConstants {
     public static final String BINDING_ID = "yioremote";
 
     // List of all used global variables
-    public static enum YioRemoteDockHandleStatus {
+    public enum YioRemoteDockHandleStatus {
         UNINITIALIZED_STATE,
         AUTHENTICATION_PROCESS,
         AUTHENTICATION_FAILED,
@@ -37,15 +37,15 @@ public class YIOremoteBindingConstants {
         CONNECTION_FAILED,
         CONNECTION_ESTABLISHED,
         COMMUNICATION_ERROR,
-        RECONNECTION_PROCESS;
+        RECONNECTION_PROCESS
     }
 
-    public static enum YioRemoteMessages {
+    public enum YioRemoteMessages {
         IR_SEND,
         AUTHENTICATE_MESSAGE,
         HEARTBEAT_MESSAGE,
         IR_RECEIVER_ON,
-        IR_RECEIVER_OFF;
+        IR_RECEIVER_OFF
     }
 
     // List of all Thing Type UIDs
index c45051b0d5214253ea89d053b87b76d68d89dd50..cd6c112bb2a85dc9c13bd67e3ee9aa618d8b0ed6 100644 (file)
@@ -17,7 +17,7 @@ import static org.openhab.binding.yioremote.internal.YIOremoteBindingConstants.*
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -177,20 +177,20 @@ public class YIOremoteDockHandler extends BaseThingHandler {
         boolean success = false;
 
         if (message.has("type")) {
-            if (message.get("type").toString().equalsIgnoreCase("\"auth_required\"")) {
+            if ("\"auth_required\"".equalsIgnoreCase(message.get("type").toString())) {
                 success = true;
                 receivedStatus = "Authentication required";
-            } else if (message.get("type").toString().equalsIgnoreCase("\"auth_ok\"")) {
+            } else if ("\"auth_ok\"".equalsIgnoreCase(message.get("type").toString())) {
                 authenticationOk = true;
                 success = true;
                 receivedStatus = "Authentication ok";
-            } else if (message.get("type").toString().equalsIgnoreCase("\"dock\"") && message.has("message")) {
-                if (message.get("message").toString().equalsIgnoreCase("\"pong\"")) {
+            } else if ("\"dock\"".equalsIgnoreCase(message.get("type").toString()) && message.has("message")) {
+                if ("\"pong\"".equalsIgnoreCase(message.get("message").toString())) {
                     heartBeat = true;
                     success = true;
                     receivedStatus = "Heart beat received";
-                } else if (message.get("message").toString().equalsIgnoreCase("\"ir_send\"")) {
-                    if (message.get("success").toString().equalsIgnoreCase("true")) {
+                } else if ("\"ir_send\"".equalsIgnoreCase(message.get("message").toString())) {
+                    if ("true".equalsIgnoreCase(message.get("success").toString())) {
                         receivedStatus = "Send IR Code successfully";
                         success = true;
                     } else {
@@ -203,7 +203,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
                     heartBeat = false;
                     success = false;
                 }
-            } else if (message.get("command").toString().equalsIgnoreCase("\"ir_receive\"")) {
+            } else if ("\"ir_receive\"".equalsIgnoreCase(message.get("command").toString())) {
                 receivedStatus = message.get("code").toString().replace("\"", "");
                 if (receivedStatus.matches("[0-9]?[0-9][;]0[xX][0-9a-fA-F]+[;][0-9]+[;][0-9]")) {
                     irCodeReceivedHandler.setCode(message.get("code").toString().replace("\"", ""));
@@ -241,8 +241,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
             }
             return result;
         } catch (IllegalArgumentException e) {
-            JsonObject result = new JsonObject();
-            return result;
+            return new JsonObject();
         }
     }
 
@@ -253,7 +252,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(YIOremoteDockActions.class);
+        return Set.of(YIOremoteDockActions.class);
     }
 
     @Override
index d2ec1b16ce839738a8dd0df329b1072724142147..d9cb435fea7b147bed452a4ad9de0f5f47e071f7 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.yioremote.internal;
 
 import static org.openhab.binding.yioremote.internal.YIOremoteBindingConstants.THING_TYPE_YIOREMOTEDOCK;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -36,7 +35,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(configurationPid = "binding.yioremote", service = ThingHandlerFactory.class)
 public class YIOremoteHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_YIOREMOTEDOCK);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_YIOREMOTEDOCK);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index b6fb22ea457ca50a67da78d5fe6a662caaf7b331..8bddcb4bbfd9b4c495671c6ea486dd3922a69906 100644 (file)
@@ -42,8 +42,8 @@ public class ZmActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ZmMonitorHandler) {
-            this.handler = (ZmMonitorHandler) handler;
+        if (handler instanceof ZmMonitorHandler zmMonitorHandler) {
+            this.handler = zmMonitorHandler;
         }
     }
 
index 581cdd1e0e9d59f7e2b455ded4dcc38eddd4f131..b4792c46e9211452d4a7c685eb99d94b229fe301 100644 (file)
@@ -70,8 +70,8 @@ public class MonitorDiscoveryService extends AbstractDiscoveryService implements
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ZmBridgeHandler) {
-            bridgeHandler = (ZmBridgeHandler) handler;
+        if (handler instanceof ZmBridgeHandler zmBridgeHandler) {
+            bridgeHandler = zmBridgeHandler;
         }
     }
 
index 5f6b8e88625c8ab182c1938d04b133d9d80a1180..a82f7d086afc1d986c21ca6411bb10320604234a 100644 (file)
@@ -222,7 +222,7 @@ public class ZmBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(MonitorDiscoveryService.class);
+        return Set.of(MonitorDiscoveryService.class);
     }
 
     public boolean isBackgroundDiscoveryEnabled() {
@@ -294,8 +294,7 @@ public class ZmBridgeHandler extends BaseBridgeHandler {
         try {
             ContentResponse response = request.send();
             if (response.getStatus() == HttpStatus.OK_200) {
-                RawType image = new RawType(response.getContent(), response.getHeaders().get(HttpHeader.CONTENT_TYPE));
-                return image;
+                return new RawType(response.getContent(), response.getHeaders().get(HttpHeader.CONTENT_TYPE));
             } else {
                 errorMsg = String.format("HTTP GET failed: %d, %s", response.getStatus(), response.getReason());
             }
index 45619e94b0969de6ddf613fe1d5c53e30bd94fda..b0b341b112fef713ccd1315ce5101cca76f36e7d 100644 (file)
@@ -16,8 +16,8 @@ import static org.openhab.binding.zoneminder.internal.ZmBindingConstants.*;
 
 import java.time.ZonedDateTime;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -125,8 +125,8 @@ public class ZmMonitorHandler extends BaseThingHandler {
                 }
                 break;
             case CHANNEL_ENABLE:
-                if (command instanceof OnOffType) {
-                    localHandler.setEnabled(monitorId, (OnOffType) command);
+                if (command instanceof OnOffType onOffCommand) {
+                    localHandler.setEnabled(monitorId, onOffCommand);
                     logger.debug("Monitor {}: Set monitor enable to {}", monitorId, command);
                 }
                 break;
@@ -147,7 +147,7 @@ public class ZmMonitorHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ZmActions.class);
+        return Set.of(ZmActions.class);
     }
 
     public String getId() {
index 96a1b8b42dc73c9491fe21e2d4ee5582cd28acc0..d9aa2606aa8848df997911da909bffe06b1eedc1 100644 (file)
@@ -40,8 +40,7 @@ public class ZWayBindingConstants {
             .unmodifiableSet(Stream.of(THING_TYPE_DEVICE, THING_TYPE_VIRTUAL_DEVICE).collect(Collectors.toSet()));
 
     // List of ignored devices for Discovery
-    public static final Set<String> DISCOVERY_IGNORED_DEVICES = Collections
-            .unmodifiableSet(Collections.singleton(("BatteryPolling")));
+    public static final Set<String> DISCOVERY_IGNORED_DEVICES = Collections.unmodifiableSet(Set.of(("BatteryPolling")));
 
     // List of all Channel IDs
     public static final String BATTERY_CHANNEL = "battery";
index be6ae37f8df7b3b7b0bb9e1db00ee4a342dfa322..4805c1d9f2dcaea17e4666c894aabd1c64df2b38 100644 (file)
@@ -151,10 +151,7 @@ public class ZWayDeviceStateConverter {
     private static State getColorState(@Nullable Color colorSwitchState) {
         if (colorSwitchState != null && colorSwitchState.getRed() != null && colorSwitchState.getGreen() != null
                 && colorSwitchState.getBlue() != null) {
-            HSBType hsbType = HSBType.fromRGB(colorSwitchState.getRed(), colorSwitchState.getGreen(),
-                    colorSwitchState.getBlue());
-
-            return hsbType;
+            return HSBType.fromRGB(colorSwitchState.getRed(), colorSwitchState.getGreen(), colorSwitchState.getBlue());
         }
 
         return UnDefType.UNDEF;
index 31c84f35b72395acf1d7bd6f55a140ce4f95e7c0..468f5176c216145a83978a41c21b2564f36fa6f5 100644 (file)
@@ -117,7 +117,7 @@ public class ZWayBridgeDiscoveryService extends AbstractDiscoveryService {
 
                 if (connection.getResponseCode() == 401) {
                     ThingUID thingUID = new ThingUID(ZWayBindingConstants.THING_TYPE_BRIDGE,
-                            ipAddress.replaceAll("\\.", "_"));
+                            ipAddress.replace(".", "_"));
 
                     // Attention: if is already present as thing in the ThingRegistry
                     // the configuration for thing will be updated!
index ffb0cc884b99cec091413d97756520facdd028a1..89cc5e86aca81e85339a40a9fbf75843a78a00f4 100644 (file)
@@ -113,14 +113,14 @@ public class ZWayDeviceDiscoveryService extends AbstractDiscoveryService {
                 ZWaveDevice zwaveDevice = mBridgeHandler.getZWayApi().getZWaveDevice(nodeId);
                 if (zwaveDevice != null) {
                     String givenName = "Device " + nodeId;
-                    if (!zwaveDevice.getData().getGivenName().getValue().equals("")) {
+                    if (!"".equals(zwaveDevice.getData().getGivenName().getValue())) {
                         givenName = zwaveDevice.getData().getGivenName().getValue();
-                    } else if (!zwaveDevice.getData().getDeviceTypeString().getValue().equals("")) {
+                    } else if (!"".equals(zwaveDevice.getData().getDeviceTypeString().getValue())) {
                         givenName += " - " + zwaveDevice.getData().getDeviceTypeString().getValue();
                     }
                     // Add additional information as properties
                     String vendorString = zwaveDevice.getData().getVendorString().getValue();
-                    if (!zwaveDevice.getData().getVendorString().getValue().equals("")) {
+                    if (!"".equals(zwaveDevice.getData().getVendorString().getValue())) {
                         givenName += " (" + vendorString + ")";
                     }
                     String manufacturerId = zwaveDevice.getData().getManufacturerId().getValue();
index 9810e4d4542fcfd197b250ce5f6a950aaf7a1eef..2e5f07e329cc966f4ef1c1d48867e4c1bc3c6b7f 100644 (file)
@@ -310,7 +310,7 @@ public class ZWayBridgeHandler extends BaseBridgeHandler implements IZWayApiCall
             updateProperties(properties);
 
             // Update channels
-            if (zwaveController.getData().getSecureInclusion().getValue().equals("true")) {
+            if ("true".equals(zwaveController.getData().getSecureInclusion().getValue())) {
                 updateState(SECURE_INCLUSION_CHANNEL, OnOffType.ON);
             } else {
                 updateState(SECURE_INCLUSION_CHANNEL, OnOffType.OFF);
index b65632269f22749e37044643c631e9bbd650471f..84fd7998da373140c22abadf6ecffad9a354c144 100644 (file)
@@ -156,8 +156,8 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler {
             return null;
         }
         ThingHandler handler = bridge.getHandler();
-        if (handler instanceof ZWayBridgeHandler) {
-            return (ZWayBridgeHandler) handler;
+        if (handler instanceof ZWayBridgeHandler bridgeHandler) {
+            return bridgeHandler;
         } else {
             return null;
         }
@@ -448,14 +448,12 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler {
                             }
                         } else if (device instanceof SwitchRGBW) {
                             // possible commands: on(), off(), exact(red, green, blue)
-                            if (command instanceof HSBType) {
+                            if (command instanceof HSBType hsb) {
                                 logger.debug("Handle command: HSBType");
 
-                                HSBType hsb = (HSBType) command;
-
                                 // first set on/off
                                 if (hsb.getBrightness().intValue() > 0) {
-                                    if (device.getMetrics().getLevel().toLowerCase().equals("off")) {
+                                    if ("off".equals(device.getMetrics().getLevel().toLowerCase())) {
                                         device.on();
                                     }
 
@@ -578,7 +576,7 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler {
             }
 
             // 2. Check if device information includes further information about sensor type
-            if (!device.getProbeType().equals("")) {
+            if (!"".equals(device.getProbeType())) {
                 if (device instanceof SensorMultilevel) {
                     switch (device.getProbeType()) {
                         case PROBE_TYPE_TEMPERATURE:
@@ -680,7 +678,7 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler {
                             break;
                     }
                 }
-            } else if (!device.getMetrics().getProbeTitle().equals("")) {
+            } else if (!"".equals(device.getMetrics().getProbeTitle())) {
                 if (device instanceof SensorMultilevel) {
                     switch (device.getMetrics().getProbeTitle()) {
                         case PROBE_TITLE_CO2_LEVEL:
@@ -691,7 +689,7 @@ public abstract class ZWayDeviceHandler extends BaseThingHandler {
                             break;
                     }
                 }
-            } else if (!device.getMetrics().getIcon().equals("")) {
+            } else if (!"".equals(device.getMetrics().getIcon())) {
                 if (device instanceof SwitchBinary) {
                     switch (device.getMetrics().getIcon()) {
                         case ICON_SWITCH:
index 1dc1ad9b36ee5d954556d7e314ab6475a1d90ac0..2ebed415bc32ccf945790e7cdc6198bf4da462ec 100644 (file)
@@ -101,7 +101,7 @@ public class ZWayZWaveDeviceHandler extends ZWayDeviceHandler {
                         // Check command classes (only for ThermostatMode)
                         ZWaveDevice zwaveDevice = getZWayBridgeHandler().getZWayApi()
                                 .getZWaveDevice(mConfig.getNodeId());
-                        if (!zwaveDevice.getInstances().get0().getCommandClasses().get64().getName().equals("")) {
+                        if (!"".equals(zwaveDevice.getInstances().get0().getCommandClasses().get64().getName())) {
                             // Load available thermostat modes
                             Map<Integer, String> modes = zwaveDevice.getInstances().get0().getCommandClasses().get64()
                                     .getThermostatModes();