]> git.basschouten.com Git - openhab-addons.git/commitdiff
Java 17 features (A-G) (#15516)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Tue, 5 Sep 2023 20:30:16 +0000 (22:30 +0200)
committerGitHub <noreply@github.com>
Tue, 5 Sep 2023 20:30:16 +0000 (22:30 +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

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
486 files changed:
bundles/org.openhab.binding.adorne/src/main/java/org/openhab/binding/adorne/internal/discovery/AdorneDiscoveryService.java
bundles/org.openhab.binding.adorne/src/main/java/org/openhab/binding/adorne/internal/handler/AdorneDimmerHandler.java
bundles/org.openhab.binding.adorne/src/main/java/org/openhab/binding/adorne/internal/hub/AdorneHubConnection.java
bundles/org.openhab.binding.ahawastecollection/src/main/java/org/openhab/binding/ahawastecollection/internal/AhaCollectionScheduleImpl.java
bundles/org.openhab.binding.airq/src/main/java/org/openhab/binding/airq/internal/AirqHandlerFactory.java
bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/api/Pollutant.java
bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/api/dto/ResponseRoot.java
bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/config/SensitiveGroupConfiguration.java
bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/discovery/AirQualityDiscoveryService.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/AirVisualNodeBindingConstants.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/discovery/AirVisualNodeDiscoveryService.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/dto/airvisual/Measurements.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/dto/airvisual/NodeData.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/dto/airvisualpro/Measurements.java
bundles/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/dto/airvisualpro/ProNodeData.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/actions/BridgeActions.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ADBridgeHandler.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/KeypadHandler.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/VZoneHandler.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/ZoneHandler.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/protocol/EXPMessage.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/protocol/KeypadMessage.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/protocol/LRRMessage.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/protocol/RFXMessage.java
bundles/org.openhab.binding.alarmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/protocol/VersionMessage.java
bundles/org.openhab.binding.allplay/src/main/java/org/openhab/binding/allplay/internal/AllPlayBindingProperties.java
bundles/org.openhab.binding.allplay/src/main/java/org/openhab/binding/allplay/internal/AllPlayHandlerFactory.java
bundles/org.openhab.binding.allplay/src/main/java/org/openhab/binding/allplay/internal/discovery/AllPlaySpeakerDiscoveryService.java
bundles/org.openhab.binding.allplay/src/main/java/org/openhab/binding/allplay/internal/handler/AllPlayHandler.java
bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/AmazonDashButtonHandlerFactory.java
bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/discovery/AmazonDashButtonDiscoveryService.java
bundles/org.openhab.binding.amazondashbutton/src/main/java/org/openhab/binding/amazondashbutton/internal/pcap/PcapUtil.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AmazonEchoControlHandlerFactory.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/channelhandler/ChannelHandlerAnnouncement.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/channelhandler/IEchoThingHandler.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/AccountHandler.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/DynamicStateDescriptionSmartHome.java
bundles/org.openhab.binding.ambientweather/src/main/java/org/openhab/binding/ambientweather/internal/handler/AmbientWeatherEventListener.java
bundles/org.openhab.binding.amplipi/src/gen/java/org/openhab/binding/amplipi/internal/model/StreamCommand.java
bundles/org.openhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/AmpliPiGroupHandler.java
bundles/org.openhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/AmpliPiHandler.java
bundles/org.openhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/AmpliPiZoneHandler.java
bundles/org.openhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/InputStateOptionProvider.java
bundles/org.openhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/discovery/AmpliPiMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/AndroidDebugBridgeDevice.java
bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/discovery/AndroidDebugBridgeDiscoveryService.java
bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/discovery/AndroidTVMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.androiddebugbridge/src/main/java/org/openhab/binding/androiddebugbridge/internal/discovery/FireTVStickMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.anel/src/test/java/org/openhab/binding/anel/internal/AnelStateUpdaterTest.java
bundles/org.openhab.binding.anel/src/test/java/org/openhab/binding/anel/internal/AnelUdpConnectorTest.java
bundles/org.openhab.binding.anel/src/test/java/org/openhab/binding/anel/internal/IAnelTestStatus.java
bundles/org.openhab.binding.anthem/src/main/java/org/openhab/binding/anthem/internal/handler/AnthemHandler.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/action/AstroActions.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/calc/MoonCalc.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/handler/AstroThingHandler.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/job/Job.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/job/SunPhaseJob.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/EclipseKind.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/EclipseType.java
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/util/PropertyUtils.java
bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/AtlonaHandlerFactory.java
bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/discovery/AtlonaDiscovery.java
bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/net/SocketChannelSession.java
bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3Handler.java
bundles/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java
bundles/org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal/discovery/AutelisDiscoveryParticipant.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/bridge/AutomowerBridgeHandler.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/discovery/AutomowerDiscoveryService.java
bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/things/AutomowerHandler.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryService.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseBridgeHandler.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzButtonHandler.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzHeatingActionsHandler.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/GroupHandler.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java
bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzTemplateListModelTest.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBestpriceConfiguration.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarConsecutiveBestPriceResult.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarNonConsecutiveBestPriceResult.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarUtil.java
bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarPriceHandler.java
bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/enums/Switch.java
bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java
bundles/org.openhab.binding.bluetooth.am43/src/main/java/org/openhab/binding/bluetooth/am43/internal/AM43DiscoveryParticipant.java
bundles/org.openhab.binding.bluetooth.am43/src/main/java/org/openhab/binding/bluetooth/am43/internal/AM43Handler.java
bundles/org.openhab.binding.bluetooth.am43/src/main/java/org/openhab/binding/bluetooth/am43/internal/AM43HandlerFactory.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/BlueGigaBluetoothCharacteristic.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/BlueGigaBluetoothDevice.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/handler/BlueGigaBridgeHandler.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/BlueGigaConfiguration.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/BlueGigaResponsePackets.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/BlueGigaSerialHandler.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/BlueGigaTransactionManager.java
bundles/org.openhab.binding.bluetooth.bluegiga/src/main/java/org/openhab/binding/bluetooth/bluegiga/internal/factory/BlueGigaHandlerFactory.java
bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZBridgeHandler.java
bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZDiscoveryService.java
bundles/org.openhab.binding.bluetooth.bluez/src/main/java/org/openhab/binding/bluetooth/bluez/internal/BlueZHandlerFactory.java
bundles/org.openhab.binding.bluetooth.blukii/src/main/java/org/openhab/binding/bluetooth/blukii/internal/BlukiiDiscoveryParticipant.java
bundles/org.openhab.binding.bluetooth.blukii/src/main/java/org/openhab/binding/bluetooth/blukii/internal/BlukiiHandlerFactory.java
bundles/org.openhab.binding.bluetooth.daikinmadoka/src/main/java/org/openhab/binding/bluetooth/daikinmadoka/internal/DaikinMadokaHandlerFactory.java
bundles/org.openhab.binding.bluetooth.enoceanble/src/main/java/org/openhab/binding/bluetooth/enoceanble/internal/EnoceanBleDiscoveryParticipant.java
bundles/org.openhab.binding.bluetooth.enoceanble/src/main/java/org/openhab/binding/bluetooth/enoceanble/internal/EnoceanBleHandlerFactory.java
bundles/org.openhab.binding.bluetooth.generic/src/main/java/org/openhab/binding/bluetooth/generic/internal/CharacteristicChannelTypeProvider.java
bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBindingConstants.java
bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingBridgeHandler.java
bundles/org.openhab.binding.bluetooth.roaming/src/main/java/org/openhab/binding/bluetooth/roaming/internal/RoamingHandlerFactory.java
bundles/org.openhab.binding.bluetooth.ruuvitag/src/main/java/org/openhab/binding/bluetooth/ruuvitag/internal/RuuviTagDiscoveryParticipant.java
bundles/org.openhab.binding.bluetooth.ruuvitag/src/main/java/org/openhab/binding/bluetooth/ruuvitag/internal/RuuviTagHandlerFactory.java
bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/ConnectedBluetoothHandler.java
bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/util/RetryFuture.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryServiceTest.java
bundles/org.openhab.binding.bondhome/src/main/java/org/openhab/binding/bondhome/internal/BondHomeHandlerFactory.java
bundles/org.openhab.binding.bondhome/src/main/java/org/openhab/binding/bondhome/internal/api/BondHttpApi.java
bundles/org.openhab.binding.bondhome/src/main/java/org/openhab/binding/bondhome/internal/discovery/BondDiscoveryService.java
bundles/org.openhab.binding.bondhome/src/main/java/org/openhab/binding/bondhome/internal/handler/BondBridgeHandler.java
bundles/org.openhab.binding.bondhome/src/main/java/org/openhab/binding/bondhome/internal/handler/BondDeviceHandler.java
bundles/org.openhab.binding.boschindego/src/main/java/org/openhab/binding/boschindego/internal/AuthorizationController.java
bundles/org.openhab.binding.boschindego/src/main/java/org/openhab/binding/boschindego/internal/IndegoController.java
bundles/org.openhab.binding.boschindego/src/main/java/org/openhab/binding/boschindego/internal/IndegoDeviceController.java
bundles/org.openhab.binding.boschindego/src/main/java/org/openhab/binding/boschindego/internal/handler/BoschAccountHandler.java
bundles/org.openhab.binding.boschindego/src/main/java/org/openhab/binding/boschindego/internal/handler/BoschIndegoHandler.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandler.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/climatecontrol/ClimateControlHandler.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/intrusion/IntrusionDetectionHandler.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/services/intrusion/dto/AlarmState.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/services/intrusion/dto/ArmingState.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/services/shuttercontact/ShutterContactState.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/services/shuttercontrol/OperationState.java
bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/services/smokedetectorcheck/SmokeDetectorCheckService.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/AbstractBatteryPoweredDeviceHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/AbstractPowerSwitchHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschHttpClientTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/bridge/BridgeHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/bridge/LongPollingTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/climatecontrol/ClimateControlHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/intrusion/IntrusionDetectionHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/motiondetector/MotionDetectorHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/smartbulb/SmartBulbHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/thermostat/ThermostatHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/twinguard/TwinguardHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/devices/wallthermostat/WallThermostatHandlerTest.java
bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/services/intrusion/IntrusionDetectionControlStateServiceTest.java
bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/BoseSoundTouchHandlerFactory.java
bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/ContentItem.java
bundles/org.openhab.binding.broadlinkthermostat/src/main/java/org/openhab/binding/broadlinkthermostat/internal/discovery/BroadlinkDiscoveryService.java
bundles/org.openhab.binding.broadlinkthermostat/src/main/java/org/openhab/binding/broadlinkthermostat/internal/handler/FloureonThermostatHandler.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/handler/BsbLanBaseThingHandler.java
bundles/org.openhab.binding.bsblan/src/main/java/org/openhab/binding/bsblan/internal/helper/BsbLanParameterConverter.java
bundles/org.openhab.binding.bsblan/src/test/java/org/openhab/binding/bsblan/internal/api/BsbLanApiContentConverterTests.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/SmartherApiConnector.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Location.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/api/dto/Modules.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/discovery/SmartherModuleDiscoveryService.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/factory/SmartherHandlerFactory.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherBridgeHandler.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/handler/SmartherModuleHandler.java
bundles/org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/util/StringUtil.java
bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/BuienradarHandler.java
bundles/org.openhab.binding.buienradar/src/main/java/org/openhab/binding/buienradar/internal/BuienradarHandlerFactory.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/CaddxMessageContext.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/action/CaddxBridgeActions.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/action/CaddxKeypadActions.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/action/CaddxPanelActions.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/action/CaddxPartitionActions.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/action/CaddxZoneActions.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/discovery/CaddxDiscoveryService.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBaseThingHandler.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxBridgeHandler.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/CaddxThingType.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/ThingHandlerKeypad.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/ThingHandlerPanel.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/ThingHandlerPartition.java
bundles/org.openhab.binding.caddx/src/main/java/org/openhab/binding/caddx/internal/handler/ThingHandlerZone.java
bundles/org.openhab.binding.caddx/src/test/java/org/openhab/binding/caddx/internal/message/CaddxMessageParseTest.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusCGateHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusDaliHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusGroupHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusLightHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusNetworkHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusTemperatureHandler.java
bundles/org.openhab.binding.cbus/src/main/java/org/openhab/binding/cbus/handler/CBusTriggerHandler.java
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/ChromecastAudioSink.java
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/ChromecastCommander.java
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/ChromecastStatusUpdater.java
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/action/ChromecastActions.java
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/Cm11aHandlerFactory.java
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10ReceivedData.java
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/handler/Cm11aLampHandler.java
bundles/org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler/HVACHandler.java
bundles/org.openhab.binding.coronastats/src/main/java/org/openhab/binding/coronastats/internal/handler/CoronaStatsCountryHandler.java
bundles/org.openhab.binding.coronastats/src/main/java/org/openhab/binding/coronastats/internal/handler/CoronaStatsWorldHandler.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/airbase/AirbaseZoneInfo.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/discovery/DaikinACUnitDiscoveryService.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java
bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDeviceHandler.java
bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDt8DeviceHandler.java
bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliRgbHandler.java
bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliserverBridgeHandler.java
bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnit.java
bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnitCommunicationController.java
bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnitHandlerFactory.java
bundles/org.openhab.binding.dbquery/src/main/java/org/openhab/binding/dbquery/action/DBQueryActions.java
bundles/org.openhab.binding.dbquery/src/main/java/org/openhab/binding/dbquery/internal/QueryHandler.java
bundles/org.openhab.binding.dbquery/src/main/java/org/openhab/binding/dbquery/internal/Value2StateConverter.java
bundles/org.openhab.binding.dbquery/src/main/java/org/openhab/binding/dbquery/internal/dbimpl/influx2/Influx2Database.java
bundles/org.openhab.binding.dbquery/src/main/java/org/openhab/binding/dbquery/internal/domain/DBQueryJSONEncoder.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/BridgeActions.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/action/GroupActions.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/BridgeDiscoveryParticipant.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThermostatThingHandler.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/DenonMarantzHandlerFactory.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/DenonMarantzConnector.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/telnet/DenonMarantzTelnetConnector.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/discovery/DenonMarantzDiscoveryParticipant.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/xml/adapters/OnOffAdapter.java
bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/xml/adapters/VolumeAdapter.java
bundles/org.openhab.binding.deutschebahn/src/main/java/org/openhab/binding/deutschebahn/internal/EventAttribute.java
bundles/org.openhab.binding.deutschebahn/src/main/java/org/openhab/binding/deutschebahn/internal/TripLabelAttribute.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/communication/events/TroubleStatus.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/discovery/DigiplexDiscoveryService.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/handler/DigiplexAreaHandler.java
bundles/org.openhab.binding.digiplex/src/main/java/org/openhab/binding/digiplex/internal/handler/DigiplexBridgeHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/DigitalSTROMHandlerFactory.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/BridgeMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/DeviceDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/DiscoveryServiceManager.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/SceneDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/ZoneTemperatureControlDiscoveryService.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/BridgeHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/CircuitHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/DeviceHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/SceneHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler/ZoneTemperatureControlHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/DeviceStatusManagerImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/manager/impl/SceneManagerImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/sensorjobexecutor/sensorjob/impl/DeviceConsumptionSensorJob.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/sensorjobexecutor/sensorjob/impl/DeviceOutputValueSensorJob.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/sensorjobexecutor/sensorjob/impl/SceneConfigReadingJob.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/sensorjobexecutor/sensorjob/impl/SceneOutputValueReadingJob.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/DsAPIImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/impl/JSONResponseHandler.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/serverconnection/simpledsrequestbuilder/SimpleRequestBuilder.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DSID.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DSUID.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DeviceStateUpdateImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/devices/impl/DeviceImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/impl/JSONDetailedGroupInfoImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/lib/structure/impl/JSONZoneImpl.java
bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/providers/DsDeviceThingTypeProvider.java
bundles/org.openhab.binding.dlinksmarthome/src/main/java/org/openhab/binding/dlinksmarthome/internal/DLinkSmartHomeBindingConstants.java
bundles/org.openhab.binding.dlinksmarthome/src/main/java/org/openhab/binding/dlinksmarthome/internal/DLinkSmartHomeDiscoveryParticipant.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/DmxBindingConstants.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/DmxBridgeHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/DmxHandlerFactory.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/action/DmxActions.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/ArtnetBridgeHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/ChaserThingHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/ColorThingHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/DimmerThingHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/SacnBridgeHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/handler/TunableWhiteThingHandler.java
bundles/org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse/BaseDmxChannel.java
bundles/org.openhab.binding.dmx/src/test/java/org/openhab/binding/dmx/test/TestBridgeHandler.java
bundles/org.openhab.binding.doorbird/src/main/java/org/openhab/binding/doorbird/internal/action/DoorbirdActions.java
bundles/org.openhab.binding.doorbird/src/test/java/org/openhab/binding/doorbird/internal/DoorbirdInfoTest.java
bundles/org.openhab.binding.doorbird/src/test/java/org/openhab/binding/doorbird/internal/SipStatusTest.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/DraytonWiserBindingConstants.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/discovery/DraytonWiserDiscoveryService.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/discovery/DraytonWiserMDNSDiscoveryParticipant.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/handler/HeatHubHandler.java
bundles/org.openhab.binding.draytonwiser/src/main/java/org/openhab/binding/draytonwiser/internal/handler/RoomHandler.java
bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmMessage.java
bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/discovery/DSCAlarmDiscoveryService.java
bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/discovery/EnvisalinkBridgeDiscovery.java
bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/PanelThingHandler.java
bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/ZoneThingHandler.java
bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/cosem/OBISIdentifier.java
bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRBridgeDiscoveryService.java
bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDiscoveryService.java
bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/meter/DSMRMeter.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/device/p1telegram/P1TelegramParserTest.java
bundles/org.openhab.binding.dsmr/src/test/java/org/openhab/binding/dsmr/internal/discovery/DSMRMeterDetectorTest.java
bundles/org.openhab.binding.dwdpollenflug/src/main/java/org/openhab/binding/dwdpollenflug/internal/handler/DWDPollenflugBridgeHandler.java
bundles/org.openhab.binding.dwdpollenflug/src/main/java/org/openhab/binding/dwdpollenflug/internal/handler/DWDPollenflugRegionHandler.java
bundles/org.openhab.binding.dwdunwetter/src/main/java/org/openhab/binding/dwdunwetter/internal/factory/DwdUnwetterHandlerFactory.java
bundles/org.openhab.binding.dwdunwetter/src/test/java/org/openhab/binding/dwdunwetter/internal/handler/DwdUnwetterHandlerTest.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/Utils.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/command/AbstractCommand.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/command/AbstractWriteCommand.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/discovery/EaseeSiteDiscoveryService.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/handler/EaseeSiteHandler.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/handler/EaseeThingHandler.java
bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/model/CustomResponseTransformer.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetClass.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetDevice.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetDiscoveryService.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetLiteBridgeHandler.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetLiteHandler.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetObject.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/EchonetPropertyMap.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/Epc.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/InstanceKey.java
bundles/org.openhab.binding.echonetlite/src/main/java/org/openhab/binding/echonetlite/internal/StateCodec.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/action/EcobeeActions.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/api/EcobeeAuthState.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/discovery/EcobeeDiscoveryService.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeAccountBridgeHandler.java
bundles/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/handler/EcobeeThermostatBridgeHandler.java
bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java
bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/action/EcovacsVacuumActions.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetActiveMapIdCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetBatteryInfoCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetChargeStateCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetCleanStateCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetComponentLifeSpanCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetContinuousCleaningCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetErrorCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetMapSpotAreasWithMapIdCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetMoppingWaterAmountCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetNetworkInfoCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetSuctionPowerCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetTotalStatsCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetVolumeCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/commands/GetWaterSystemPresentCommand.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/impl/EcovacsApiImpl.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/impl/EcovacsIotMqDevice.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/impl/EcovacsXmppDevice.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/impl/PortalTodo.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/api/model/ChargeMode.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/discovery/EcovacsDeviceDiscoveryService.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/handler/EcovacsApiHandler.java
bundles/org.openhab.binding.ecovacs/src/main/java/org/openhab/binding/ecovacs/internal/handler/EcovacsVacuumHandler.java
bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java
bundles/org.openhab.binding.electroluxair/src/main/java/org/openhab/binding/electroluxair/internal/discovery/ElectroluxAirDiscoveryService.java
bundles/org.openhab.binding.electroluxair/src/main/java/org/openhab/binding/electroluxair/internal/handler/ElectroluxAirBridgeHandler.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/EleroTransmitterStickHandlerFactory.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/discovery/EleroChannelDiscoveryService.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/handler/EleroChannelHandler.java
bundles/org.openhab.binding.elerotransmitterstick/src/main/java/org/openhab/binding/elerotransmitterstick/internal/stick/TransmitterStick.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/ElroConnectsBindingConstants.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/ElroConnectsDynamicStateDescriptionProvider.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/devices/ElroConnectsDevice.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/discovery/ElroConnectsBridgeDiscoveryService.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/discovery/ElroConnectsDiscoveryService.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/handler/ElroConnectsAccountHandler.java
bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/handler/ElroConnectsBridgeHandler.java
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/retry/strategy/FixedTime.java
bundles/org.openhab.binding.enigma2/src/main/java/org/openhab/binding/enigma2/internal/Enigma2BindingConstants.java
bundles/org.openhab.binding.enigma2/src/main/java/org/openhab/binding/enigma2/internal/handler/Enigma2Handler.java
bundles/org.openhab.binding.enigma2/src/test/java/org/openhab/binding/enigma2/internal/Enigma2ClientTest.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/discovery/EnOceanDeviceDiscoveryService.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_20/A5_20_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_38/A5_38_08_Blinds.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_38/A5_38_08_Dimming.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_EltakoFRM.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_3F/A5_3F_7F_EltakoFSB.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_09_Permundo.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0F_NodON.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_12_NodON.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00_NodON.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_50/D2_50.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPFactory.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_02/F6_02_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_02/F6_02_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseThingHandler.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBridgeHandler.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanClassicDeviceHandler.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/ESP2Packet.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/ESP3Packet.java
bundles/org.openhab.binding.enphase/src/main/java/org/openhab/binding/enphase/internal/discovery/EnphaseDevicesDiscoveryService.java
bundles/org.openhab.binding.enphase/src/main/java/org/openhab/binding/enphase/internal/discovery/EnvoyDiscoveryParticipant.java
bundles/org.openhab.binding.enphase/src/main/java/org/openhab/binding/enphase/internal/handler/EnvoyBridgeHandler.java
bundles/org.openhab.binding.enturno/src/main/java/org/openhab/binding/enturno/internal/EnturNoHandlerFactory.java
bundles/org.openhab.binding.epsonprojector/src/main/java/org/openhab/binding/epsonprojector/internal/enums/Switch.java
bundles/org.openhab.binding.etherrain/src/main/java/org/openhab/binding/etherrain/internal/EtherRainBindingConstants.java
bundles/org.openhab.binding.etherrain/src/main/java/org/openhab/binding/etherrain/internal/config/EtherRainConfiguration.java
bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal/EvccHandler.java
bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java
bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeHeatingZoneHandler.java
bundles/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/internal/ExecHandlerFactory.java
bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/FeicanBindingConstants.java
bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/handler/FeicanHandler.java
bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/FineOffsetWeatherStationHandlerFactory.java
bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/discovery/FineOffsetGatewayDiscoveryService.java
bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/Measurand.java
bundles/org.openhab.binding.flicbutton/src/3rdparty/java/io/flic/fliclib/javaclient/Packets.java
bundles/org.openhab.binding.flicbutton/src/main/java/org/openhab/binding/flicbutton/internal/FlicButtonBindingConstants.java
bundles/org.openhab.binding.flicbutton/src/main/java/org/openhab/binding/flicbutton/internal/handler/ChildThingHandler.java
bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/FMISID.java
bundles/org.openhab.binding.fmiweather/src/main/java/org/openhab/binding/fmiweather/internal/client/LatLon.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/AbstractWeatherHandlerTest.java
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/FMIRequestTest.java
bundles/org.openhab.binding.folderwatcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/S3Actions.java
bundles/org.openhab.binding.folderwatcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/auth/AWS4SignerBase.java
bundles/org.openhab.binding.folderwatcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/auth/AWS4SignerForAuthorizationHeader.java
bundles/org.openhab.binding.folderwatcher/src/main/java/org/openhab/binding/folderwatcher/internal/handler/FtpFolderWatcherHandler.java
bundles/org.openhab.binding.folding/src/main/java/org/openhab/binding/folding/internal/discovery/FoldingSlotDiscoveryService.java
bundles/org.openhab.binding.folding/src/main/java/org/openhab/binding/folding/internal/handler/FoldingClientHandler.java
bundles/org.openhab.binding.folding/src/main/java/org/openhab/binding/folding/internal/handler/SlotHandler.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/FoobotHandlerFactory.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/discovery/FoobotAccountDiscoveryService.java
bundles/org.openhab.binding.foobot/src/main/java/org/openhab/binding/foobot/internal/handler/FoobotAccountHandler.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/FreeboxBindingConstants.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/api/FreeboxApiManager.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/api/model/FreeboxAirMediaReceiverRequest.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/api/model/FreeboxAuthorizationStatus.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/console/FreeboxCommandExtension.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/discovery/FreeboxDiscoveryService.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/handler/FreeboxHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/Response.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/APManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/AfpManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/CallManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/ConnectionManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeboxOsSession.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeplugManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LanBrowserManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LanManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LoginManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/MediaReceiverManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PhoneManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PlayerManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/RepeaterManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/SystemManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/VmManager.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/console/FreeboxOsCommandExtension.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/CallHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/DectHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeboxOsHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeplugHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/PlayerHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RevolutionHandler.java
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBridgeHandler.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/FSInternetRadioDiscoveryParticipant.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/FSInternetRadioHandlerFactory.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/handler/FSInternetRadioHandler.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/radio/FrontierSiliconRadioApiResult.java
bundles/org.openhab.binding.fsinternetradio/src/test/java/org/openhab/binding/fsinternetradio/test/FSInternetRadioHandlerJavaTest.java
bundles/org.openhab.binding.ftpupload/src/main/java/org/openhab/binding/ftpupload/internal/FtpUploadHandlerFactory.java
bundles/org.openhab.binding.gardena/src/main/java/org/openhab/binding/gardena/internal/handler/GardenaAccountHandler.java
bundles/org.openhab.binding.gardena/src/main/java/org/openhab/binding/gardena/internal/handler/GardenaThingHandler.java
bundles/org.openhab.binding.gardena/src/main/java/org/openhab/binding/gardena/internal/model/dto/command/ValveCommand.java
bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/action/Ipx800Actions.java
bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/handler/Ipx800v3Handler.java
bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/model/M2MMessageParser.java
bundles/org.openhab.binding.gce/src/main/java/org/openhab/binding/gce/internal/model/StatusFileInterpreter.java
bundles/org.openhab.binding.generacmobilelink/src/main/java/org/openhab/binding/generacmobilelink/internal/discovery/GeneracMobileLinkDiscoveryService.java
bundles/org.openhab.binding.generacmobilelink/src/main/java/org/openhab/binding/generacmobilelink/internal/handler/GeneracMobileLinkAccountHandler.java
bundles/org.openhab.binding.generacmobilelink/src/main/java/org/openhab/binding/generacmobilelink/internal/handler/GeneracMobileLinkGeneratorHandler.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/command/CommandGetserial.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/command/CommandSendir.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/command/CommandSendserial.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/command/CommandSetserial.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/command/CommandSetstate.java
bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java
bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/GoEChargerHandlerFactory.java
bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerHandler.java
bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerV2Handler.java
bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/message/NotificationHandler.java
bundles/org.openhab.binding.gpstracker/src/main/java/org/openhab/binding/gpstracker/internal/provider/AbstractCallbackServlet.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/GreeBindingConstants.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeAirDevice.java
bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler/GreeHandler.java
bundles/org.openhab.binding.groheondus/src/main/java/org/openhab/binding/groheondus/internal/handler/GroheOndusSenseGuardHandler.java
bundles/org.openhab.binding.groheondus/src/main/java/org/openhab/binding/groheondus/internal/handler/GroheOndusSenseHandler.java
bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/bridge/GroupePSABridgeHandler.java
bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/discovery/GroupePSADiscoveryService.java
bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/rest/api/GroupePSAConnectApi.java
bundles/org.openhab.binding.groupepsa/src/main/java/org/openhab/binding/groupepsa/internal/things/GroupePSAHandler.java

index 33dec534d99296defd2f1952e4a842f003e67539..40064794e0215fed1b270de44b3649635da1befd 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.adorne.internal.discovery;
 
 import static org.openhab.binding.adorne.internal.AdorneBindingConstants.*;
 
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -52,7 +52,7 @@ public class AdorneDiscoveryService extends AbstractDiscoveryService implements
      */
     public AdorneDiscoveryService() {
         // Passing false as last argument to super constructor turns off background discovery
-        super(Collections.singleton(new ThingTypeUID(BINDING_ID, "-")), DISCOVERY_TIMEOUT_SECONDS, false);
+        super(Set.of(new ThingTypeUID(BINDING_ID, "-")), DISCOVERY_TIMEOUT_SECONDS, false);
 
         // We create the hub controller with default host and port. In the future we could let users create hubs
         // manually with custom host and port settings and then perform discovery here for those hubs.
@@ -76,10 +76,9 @@ public class AdorneDiscoveryService extends AbstractDiscoveryService implements
 
         // Future enhancement: Need a timeout for each future execution to recover from bugs in the hub controller, but
         // Java8 doesn't yet offer that
-        adorneHubController.start().thenCompose(Void -> {
-            // We use the hub's MAC address as its unique identifier
-            return adorneHubController.getMACAddress();
-        }).thenCompose(macAddress -> {
+        adorneHubController.start().thenCompose(Void ->
+        // We use the hub's MAC address as its unique identifier
+        adorneHubController.getMACAddress()).thenCompose(macAddress -> {
             String macAddressNoColon = macAddress.replace(':', '-'); // Colons are not allowed in ThingUIDs
             bridgeUID[0] = new ThingUID(THING_TYPE_HUB, macAddressNoColon);
             // We have fully discovered the hub
index 7ca99db1ee8fef424eb9e847633ca75763622f4c..e8ca0c6366c3dac26a038a412712a66dc8799790 100644 (file)
@@ -50,10 +50,10 @@ public class AdorneDimmerHandler extends AdorneSwitchHandler {
             if (channelUID.getId().equals(CHANNEL_BRIGHTNESS)) {
                 if (command instanceof RefreshType) {
                     refreshBrightness();
-                } else if (command instanceof PercentType) {
+                } else if (command instanceof PercentType percentCommand) {
                     // Change the brightness through the hub controller
                     AdorneHubController adorneHubController = getAdorneHubController();
-                    int level = ((PercentType) command).intValue();
+                    int level = percentCommand.intValue();
                     if (level >= 1 && level <= 100) { // Ignore commands outside of the supported 1-100 range
                         adorneHubController.setBrightness(zoneId, level);
                     } else {
index b911b8992230e78cbcc279f8e6c5d16afbba8d7b..011319754f7120b9c02e94abf1b68d53dd3cfb74 100644 (file)
@@ -86,8 +86,8 @@ public class AdorneHubConnection {
             return null; // Eat empty messages
         }
         logger.debug("Received message {}", msg);
-        if (msg instanceof JsonObject) {
-            msgJsonObject = (JsonObject) msg;
+        if (msg instanceof JsonObject object) {
+            msgJsonObject = object;
         }
         return msgJsonObject;
     }
index 6e888a3d53d50ae82af9fc1bdfc284698cdfc8b9..10ec2fadbc336fc3f55ed42d4fdab96cd64cb46a 100644 (file)
@@ -81,7 +81,7 @@ final class AhaCollectionScheduleImpl implements AhaCollectionSchedule {
 
         final Elements table = doc.select("table");
 
-        if (table.size() == 0) {
+        if (table.isEmpty()) {
             logger.warn("No result table found.");
             return Collections.emptyMap();
         }
@@ -91,7 +91,7 @@ final class AhaCollectionScheduleImpl implements AhaCollectionSchedule {
 
         while (rowIt.hasNext()) {
             final Element currentRow = rowIt.next();
-            if (!currentRow.tagName().equals("tr")) {
+            if (!"tr".equals(currentRow.tagName())) {
                 continue;
             }
             // Skip header, empty and download button rows.
index 2e6adbeaecf0cff0ce2364a26f6d4fa982715dc4..d9c2bd2dd26e23be50353a91721562c05420d76d 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.airq.internal;
 
 import static org.openhab.binding.airq.internal.AirqBindingConstants.THING_TYPE_AIRQ;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -38,7 +37,7 @@ import org.osgi.service.component.annotations.Reference;
 @Component(configurationPid = "binding.airq", service = ThingHandlerFactory.class)
 public class AirqHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRQ);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIRQ);
     private final HttpClientFactory httpClientFactory;
 
     @Activate
index 2957b6729656e55b8b6da20b5ae97d02a7322f9c..f5c5c6ebd1ee046c82d7e51dde2b1a9794b552ee 100644 (file)
@@ -64,12 +64,12 @@ public enum Pollutant {
             new ConcentrationRange(205, 404, TWO_HUNDRED), new ConcentrationRange(405, 504, THREE_HUNDRED),
             new ConcentrationRange(505, 604, FOUR_HUNDRED));
 
-    public static enum SensitiveGroup {
+    public enum SensitiveGroup {
         RESPIRATORY,
         HEART,
         ELDERLY,
         CHILDREN,
-        ASTHMA;
+        ASTHMA
     }
 
     public final Set<SensitiveGroup> sensitiveGroups;
index 09c665f7eb5c51b50aa86daceeed575381333f99..3dbcb18283b9225921a087aa52855d2b9858a5cb 100644 (file)
@@ -22,11 +22,11 @@ import com.google.gson.annotations.SerializedName;
  * @author Gaël L'hopital - Initial contribution
  */
 public class ResponseRoot {
-    public static enum ResponseStatus {
+    public enum ResponseStatus {
         @SerializedName("error")
         ERROR,
         @SerializedName("ok")
-        OK;
+        OK
     }
 
     protected ResponseStatus status = ResponseStatus.OK;
index 47afa4fec541564e242acf5f6db215b81c32be23..1df1e9d5972d77cf50c99325a802d8a5596d878e 100644 (file)
@@ -28,8 +28,7 @@ public class SensitiveGroupConfiguration {
 
     public @Nullable SensitiveGroup asSensitiveGroup() {
         try {
-            SensitiveGroup value = SensitiveGroup.valueOf(group);
-            return value;
+            return SensitiveGroup.valueOf(group);
         } catch (IllegalArgumentException e) {
             return null;
         }
index 0edc187ddfaa7df97bcfcd9490b39adda7ee6e59..f30c05b2d1a270aa77a66c779de7884ce7c8a50c 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.airquality.internal.discovery;
 import static org.openhab.binding.airquality.internal.AirQualityBindingConstants.*;
 import static org.openhab.binding.airquality.internal.config.AirQualityConfiguration.LOCATION;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
 @NonNullByDefault
 public class AirQualityDiscoveryService extends AbstractDiscoveryService implements ThingHandlerService {
     private static final int DISCOVER_TIMEOUT_SECONDS = 2;
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_STATION);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_STATION);
 
     private final Logger logger = LoggerFactory.getLogger(AirQualityDiscoveryService.class);
 
@@ -59,9 +58,8 @@ public class AirQualityDiscoveryService extends AbstractDiscoveryService impleme
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof AirQualityBridgeHandler) {
-            final AirQualityBridgeHandler bridgeHandler = (AirQualityBridgeHandler) handler;
-            this.bridgeHandler = bridgeHandler;
+        if (handler instanceof AirQualityBridgeHandler bridgeHandlerInstance) {
+            this.bridgeHandler = bridgeHandlerInstance;
             this.locationProvider = bridgeHandler.getLocationProvider();
         }
     }
index 72c3d3ab845a9cbde6ff7a9d0e908fd14b3bc6be..1924e2ebe5139b3f508c1ceb52d1dd722690fd60 100644 (file)
@@ -12,9 +12,6 @@
  */
 package org.openhab.binding.airvisualnode.internal;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -51,12 +48,10 @@ public class AirVisualNodeBindingConstants {
             .getUID().getId();
 
     // List of all supported Thing UIDs
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_AVNODE)));
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AVNODE);
 
     // List of all supported Channel ids
-    public static final Set<String> SUPPORTED_CHANNEL_IDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(CHANNEL_CO2, CHANNEL_HUMIDITY, CHANNEL_AQI_US, CHANNEL_PM_25,
-                    CHANNEL_PM_10, CHANNEL_PM_01, CHANNEL_TEMP_CELSIUS, CHANNEL_BATTERY_LEVEL, CHANNEL_WIFI_STRENGTH,
-                    CHANNEL_TIMESTAMP, CHANNEL_USED_MEMORY)));
+    public static final Set<String> SUPPORTED_CHANNEL_IDS = Set.of(CHANNEL_CO2, CHANNEL_HUMIDITY, CHANNEL_AQI_US,
+            CHANNEL_PM_25, CHANNEL_PM_10, CHANNEL_PM_01, CHANNEL_TEMP_CELSIUS, CHANNEL_BATTERY_LEVEL,
+            CHANNEL_WIFI_STRENGTH, CHANNEL_TIMESTAMP, CHANNEL_USED_MEMORY);
 }
index 850049dfccc64cf04eeeb35dd8a3c47eaf464c95..ce6ebbd51da465385b5c2c43723011d23d2ab6b0 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.airvisualnode.internal.discovery;
 
 import java.io.IOException;
 import java.net.UnknownHostException;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
@@ -55,7 +55,7 @@ public class AirVisualNodeDiscoveryService extends AbstractDiscoveryService {
     private @Nullable ScheduledFuture<?> backgroundDiscoveryFuture;
 
     public AirVisualNodeDiscoveryService() {
-        super(Collections.singleton(AirVisualNodeBindingConstants.THING_TYPE_AVNODE), 600, true);
+        super(Set.of(AirVisualNodeBindingConstants.THING_TYPE_AVNODE), 600, true);
     }
 
     @Override
index cbdcb73ae09a9c91042c0bffec8fb44d4d726018..6d316c61ba14474b8b880a3c65ad144c414e886e 100644 (file)
@@ -49,6 +49,7 @@ public class Measurements implements MeasurementsInterface {
         this.vocPpb = vocPpb;
     }
 
+    @Override
     public int getCo2Ppm() {
         return co2Ppm;
     }
@@ -57,6 +58,7 @@ public class Measurements implements MeasurementsInterface {
         this.co2Ppm = co2Ppm;
     }
 
+    @Override
     public int getHumidityRH() {
         return humidityRH;
     }
@@ -65,6 +67,7 @@ public class Measurements implements MeasurementsInterface {
         this.humidityRH = humidityRH;
     }
 
+    @Override
     public int getPm25AQICN() {
         return pm25AQICN;
     }
@@ -73,6 +76,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm25AQICN = pm25AQICN;
     }
 
+    @Override
     public int getPm25AQIUS() {
         return pm25AQIUS;
     }
@@ -91,6 +95,7 @@ public class Measurements implements MeasurementsInterface {
         return 0;
     }
 
+    @Override
     public float getPm25Ugm3() {
         return pm25Ugm3;
     }
@@ -99,6 +104,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm25Ugm3 = pm25Ugm3;
     }
 
+    @Override
     public float getTemperatureC() {
         return temperatureC;
     }
@@ -107,6 +113,7 @@ public class Measurements implements MeasurementsInterface {
         this.temperatureC = temperatureC;
     }
 
+    @Override
     public float getTemperatureF() {
         return temperatureF;
     }
@@ -115,6 +122,7 @@ public class Measurements implements MeasurementsInterface {
         this.temperatureF = temperatureF;
     }
 
+    @Override
     public int getVocPpb() {
         return vocPpb;
     }
index 4694d44cbe86cb62345c2c946e208f8abcc98c6a..8a7f055fa3d9fa1c23b3cca41d9d3f71b1bfec91 100644 (file)
@@ -40,6 +40,7 @@ public class NodeData implements NodeDataInterface {
         this.status = status;
     }
 
+    @Override
     public DateAndTime getDateAndTime() {
         return dateAndTime;
     }
@@ -48,6 +49,7 @@ public class NodeData implements NodeDataInterface {
         this.dateAndTime = dateAndTime;
     }
 
+    @Override
     public MeasurementsInterface getMeasurements() {
         return measurements;
     }
@@ -56,6 +58,7 @@ public class NodeData implements NodeDataInterface {
         this.measurements = measurements;
     }
 
+    @Override
     public String getSerialNumber() {
         return serialNumber;
     }
@@ -64,6 +67,7 @@ public class NodeData implements NodeDataInterface {
         this.serialNumber = serialNumber;
     }
 
+    @Override
     public Settings getSettings() {
         return settings;
     }
@@ -72,6 +76,7 @@ public class NodeData implements NodeDataInterface {
         this.settings = settings;
     }
 
+    @Override
     public Status getStatus() {
         return status;
     }
index 481843e415f407044e79444cac5793b662834830..ffcfe87a11d87bfd41ab96946f23af50809bd3fc 100644 (file)
@@ -66,6 +66,7 @@ public class Measurements implements MeasurementsInterface {
         this.vocPpb = vocPpb;
     }
 
+    @Override
     public int getCo2Ppm() {
         return co2Ppm;
     }
@@ -74,6 +75,7 @@ public class Measurements implements MeasurementsInterface {
         this.co2Ppm = co2Ppm;
     }
 
+    @Override
     public int getHumidityRH() {
         return humidityRH;
     }
@@ -82,6 +84,7 @@ public class Measurements implements MeasurementsInterface {
         this.humidityRH = humidityRH;
     }
 
+    @Override
     public int getPm25AQICN() {
         return pm25AQICN;
     }
@@ -90,6 +93,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm25AQICN = pm25AQICN;
     }
 
+    @Override
     public int getPm25AQIUS() {
         return pm25AQIUS;
     }
@@ -98,6 +102,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm25AQIUS = pm25AQIUS;
     }
 
+    @Override
     public float getPm01Ugm3() {
         return pm01Ugm3;
     }
@@ -106,6 +111,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm01Ugm3 = pm01Ugm3;
     }
 
+    @Override
     public float getPm10Ugm3() {
         return pm10Ugm3;
     }
@@ -114,6 +120,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm10Ugm3 = pm10Ugm3;
     }
 
+    @Override
     public float getPm25Ugm3() {
         return pm25Ugm3;
     }
@@ -122,6 +129,7 @@ public class Measurements implements MeasurementsInterface {
         this.pm25Ugm3 = pm25Ugm3;
     }
 
+    @Override
     public float getTemperatureC() {
         return temperatureC;
     }
@@ -130,6 +138,7 @@ public class Measurements implements MeasurementsInterface {
         this.temperatureC = temperatureC;
     }
 
+    @Override
     public float getTemperatureF() {
         return temperatureF;
     }
@@ -138,6 +147,7 @@ public class Measurements implements MeasurementsInterface {
         this.temperatureF = temperatureF;
     }
 
+    @Override
     public int getVocPpb() {
         return vocPpb;
     }
index b5162b7155e608f67ce14d00eeb329f37f54add2..2082a2f9fd2432a4dc4adc53d092f411c7227f12 100644 (file)
@@ -44,6 +44,7 @@ public class ProNodeData implements NodeDataInterface {
         this.status = status;
     }
 
+    @Override
     public DateAndTime getDateAndTime() {
         return dateAndTime;
     }
@@ -52,6 +53,7 @@ public class ProNodeData implements NodeDataInterface {
         this.dateAndTime = dateAndTime;
     }
 
+    @Override
     public MeasurementsInterface getMeasurements() {
         return measurements.get(0);
     }
@@ -60,6 +62,7 @@ public class ProNodeData implements NodeDataInterface {
         this.measurements = measurements;
     }
 
+    @Override
     public String getSerialNumber() {
         return serialNumber;
     }
@@ -68,6 +71,7 @@ public class ProNodeData implements NodeDataInterface {
         this.serialNumber = serialNumber;
     }
 
+    @Override
     public Settings getSettings() {
         return settings;
     }
@@ -76,6 +80,7 @@ public class ProNodeData implements NodeDataInterface {
         this.settings = settings;
     }
 
+    @Override
     public Status getStatus() {
         return status;
     }
index b21d41a83900a0a19e66ce184289c54cb2c2d796..33114c893d5bac15a3f034a1be1a91f7341ddfe3 100644 (file)
@@ -42,8 +42,8 @@ public class BridgeActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ADBridgeHandler) {
-            this.bridge = (ADBridgeHandler) handler;
+        if (handler instanceof ADBridgeHandler bridgeHandler) {
+            this.bridge = bridgeHandler;
         }
     }
 
index e5b7a49d6224e4194f5bebfd2fb4e803301d4274..453beb1f953c0b95ee11005d9a77c9e6fefdfe57 100644 (file)
@@ -20,8 +20,8 @@ import java.io.IOException;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -87,7 +87,7 @@ public abstract class ADBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(BridgeActions.class);
+        return List.of(BridgeActions.class);
     }
 
     public void setDiscoveryService(AlarmDecoderDiscoveryService discoveryService) {
index 34740a64a15e28157455b30aa5d9cc6e6fb9015b..fb255805ed0b582a79af27015a46826640844576 100644 (file)
@@ -113,13 +113,13 @@ public class KeypadHandler extends ADThingHandler {
         IntCommandMap intCommandMap = this.intCommandMap;
 
         if (channelUID.getId().equals(CHANNEL_KP_COMMAND)) {
-            if (command instanceof StringType) {
-                String cmd = ((StringType) command).toString();
+            if (command instanceof StringType commandString) {
+                String cmd = commandString.toString();
                 handleKeypadCommand(cmd);
             }
         } else if (channelUID.getId().equals(CHANNEL_KP_INTCOMMAND)) {
-            if (command instanceof Number) {
-                int icmd = ((Number) command).intValue();
+            if (command instanceof Number numberCommand) {
+                int icmd = numberCommand.intValue();
                 if (intCommandMap != null) {
                     String cmd = intCommandMap.getCommand(icmd);
                     if (cmd != null) {
index 5e7e4822d23189c97bd565dceb54dff560153bd0..b6827d0b352aa2aac75682ffb9ded9e08dea201b 100644 (file)
@@ -78,8 +78,8 @@ public class VZoneHandler extends ADThingHandler {
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
         if (channelUID.getId().equals(CHANNEL_COMMAND)) {
-            if (command instanceof StringType) {
-                String cmd = ((StringType) command).toString();
+            if (command instanceof StringType stringCommand) {
+                String cmd = stringCommand.toString();
                 if (CMD_OPEN.equalsIgnoreCase(cmd)) {
                     sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_OPEN));
                     setChannelState(OnOffType.OFF);
index 9154f719f68e7c7de8337ce36c615b21438219af..952f40fa1acedb14c853fd6edab3c24d307fd90e 100644 (file)
@@ -46,7 +46,7 @@ public class ZoneHandler extends ADThingHandler {
     }
 
     /** Construct zone id from address and channel */
-    public static final String zoneID(int address, int channel) {
+    public static String zoneID(int address, int channel) {
         return String.format("%d-%d", address, channel);
     }
 
index b320f7c42ad331daa1d35a5621ff02ee9b27970a..c0d5c582b5e490aecab75ee4dee86d6c9ea86c6c 100644 (file)
@@ -40,7 +40,7 @@ public class EXPMessage extends ADMessage {
     public EXPMessage(String message) throws IllegalArgumentException {
         super(message);
 
-        String topLevel[] = message.split(":");
+        String[] topLevel = message.split(":");
         if (topLevel.length != 2) {
             throw new IllegalArgumentException("Multiple colons found in EXP message");
         }
index cb9cad16efae3e8b1db4111572c249084214796a..ce9891b312cdf0cd7d6140eead12b411ab9ec9fd 100644 (file)
@@ -143,8 +143,7 @@ public class KeypadMessage extends ADMessage {
             return false;
         } else if (this == obj) {
             return true;
-        } else if (obj instanceof KeypadMessage) {
-            KeypadMessage other = (KeypadMessage) obj;
+        } else if (obj instanceof KeypadMessage other) {
             return this.message.equals(other.message);
         } else {
             return false;
index 3857b9e82e8cf5486b02cdc14fe26b28802a3658..c39ae7f74d17b91735c6a5eb11dc1d63be5dfbea 100644 (file)
@@ -43,7 +43,7 @@ public class LRRMessage extends ADMessage {
     public LRRMessage(String message) throws IllegalArgumentException {
         super(message);
 
-        String topLevel[] = message.split(":");
+        String[] topLevel = message.split(":");
         if (topLevel.length != 2) {
             throw new IllegalArgumentException("multiple colons in LRR message");
         }
index 0dc687faeb61e397eaa7e44bd79ef63e4595b073..5175c4599f33d66edd8ec41e79192b2319f1b974 100644 (file)
@@ -43,7 +43,7 @@ public class RFXMessage extends ADMessage {
     public RFXMessage(String message) throws IllegalArgumentException {
         super(message);
 
-        String topLevel[] = message.split(":");
+        String[] topLevel = message.split(":");
         if (topLevel.length != 2) {
             throw new IllegalArgumentException("Multiple colons found in RFX message");
         }
index 3819ee8969c9e2a7b7dfb281a7134b5be2e441c6..2cd570ca5de2f5f306c57642a0c4beebb031706b 100644 (file)
@@ -38,7 +38,7 @@ public class VersionMessage extends ADMessage {
     public VersionMessage(String message) throws IllegalArgumentException {
         super(message);
 
-        String topLevel[] = message.split(":");
+        String[] topLevel = message.split(":");
         if (topLevel.length != 2) {
             throw new IllegalArgumentException("Multiple colons found in VER message");
         }
index 823b0222986260b7b1284d993f188c9fe9e3f610..2f208918a9bf0cef663618daa1fceef14a93fbf1 100644 (file)
@@ -63,9 +63,9 @@ public class AllPlayBindingProperties {
     private int getIntegerProperty(Dictionary<String, Object> properties, String propertyKey, int defaultValue) {
         Object configValue = properties.get(propertyKey);
         int value = defaultValue;
-        if (configValue instanceof String) {
+        if (configValue instanceof String stringValue) {
             try {
-                value = Integer.parseInt((String) configValue);
+                value = Integer.parseInt(stringValue);
             } catch (NumberFormatException e) {
                 logger.warn("Unable to convert value {} for config property {} to integer. Using default value.",
                         configValue, propertyKey);
index e7615d79b8a355324d2e81087eecf21e30e68467..8d3a43f55e075a14bb4220880cf023c947aa677e 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.allplay.internal;
 
 import static org.openhab.binding.allplay.internal.AllPlayBindingConstants.SPEAKER_THING_TYPE;
 
-import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
@@ -54,7 +53,7 @@ public class AllPlayHandlerFactory extends BaseThingHandlerFactory {
 
     private final Logger logger = LoggerFactory.getLogger(AllPlayHandlerFactory.class);
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(SPEAKER_THING_TYPE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(SPEAKER_THING_TYPE);
     private final Map<String, ServiceRegistration<AudioSink>> audioSinkRegistrations = new ConcurrentHashMap<>();
 
     private AllPlay allPlay;
index f42baef7bbabcd7e04a5559a057db82a39619c9e..54fa0fb47129065afd58fa1f8203d55ae2dea91c 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.allplay.internal.discovery;
 
 import static org.openhab.binding.allplay.internal.AllPlayBindingConstants.SPEAKER_THING_TYPE;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,7 @@ public class AllPlaySpeakerDiscoveryService extends AbstractDiscoveryService imp
     private final Logger logger = LoggerFactory.getLogger(AllPlaySpeakerDiscoveryService.class);
 
     private static final int DISCOVERY_TIMEOUT = 30;
-    private static final Set<ThingTypeUID> DISCOVERABLE_THING_TYPES_UIDS = Collections.singleton(SPEAKER_THING_TYPE);
+    private static final Set<ThingTypeUID> DISCOVERABLE_THING_TYPES_UIDS = Set.of(SPEAKER_THING_TYPE);
     private AllPlay allPlay;
 
     public AllPlaySpeakerDiscoveryService() {
index 495c11a179882c5db07c18969249acb1ce0cded3..49c2d6a7035bf048cbe33dd16739f259d6efcd86 100644 (file)
@@ -343,8 +343,8 @@ public class AllPlayHandler extends BaseThingHandler
      * @throws SpeakerException Exception if the volume change failed
      */
     public void handleVolumeCommand(Command command) throws SpeakerException {
-        if (command instanceof PercentType) {
-            speaker.volume().setVolume(convertPercentToAbsoluteVolume((PercentType) command));
+        if (command instanceof PercentType percentCommand) {
+            speaker.volume().setVolume(convertPercentToAbsoluteVolume(percentCommand));
         } else if (command instanceof IncreaseDecreaseType) {
             int stepSize = (command == IncreaseDecreaseType.DECREASE ? -getVolumeStepSize() : getVolumeStepSize());
             speaker.volume().adjustVolume(stepSize);
index 135c05222af999b97a790ac1a33368f523ea85cd..c8f952799e4a35db3d892e2a7cbe9bb12ffad589 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.amazondashbutton.internal;
 
 import static org.openhab.binding.amazondashbutton.internal.AmazonDashButtonBindingConstants.DASH_BUTTON_THING_TYPE;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.openhab.binding.amazondashbutton.internal.handler.AmazonDashButtonHandler;
@@ -34,7 +33,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.amazondashbutton")
 public class AmazonDashButtonHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(DASH_BUTTON_THING_TYPE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(DASH_BUTTON_THING_TYPE);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 626e5fca1838577850928089977e6f9b00a20a68..e6782b3c4736f04eeeb67eb95b923d06afc3bc70 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.amazondashbutton.internal.discovery;
 import static org.openhab.binding.amazondashbutton.internal.AmazonDashButtonBindingConstants.*;
 
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -108,7 +107,7 @@ public class AmazonDashButtonDiscoveryService extends AbstractDiscoveryService i
     private boolean backgroundScanning = false;
 
     public AmazonDashButtonDiscoveryService() {
-        super(Collections.singleton(DASH_BUTTON_THING_TYPE), DISCOVER_TIMEOUT_SECONDS, false);
+        super(Set.of(DASH_BUTTON_THING_TYPE), DISCOVER_TIMEOUT_SECONDS, false);
     }
 
     @Override
index 1b272ac317656691bc1ccadbe307e19f03489e80..d15fde52c555732eb5d4c86b9a30f402ad570564 100644 (file)
@@ -36,9 +36,8 @@ public class PcapUtil {
      */
     public static Set<PcapNetworkInterfaceWrapper> getAllNetworkInterfaces() {
         try {
-            final Set<PcapNetworkInterfaceWrapper> allNetworkInterfaces = Collections.unmodifiableSet(Pcaps
-                    .findAllDevs().stream().map(PcapNetworkInterfaceWrapper.TRANSFORMER).collect(Collectors.toSet()));
-            return allNetworkInterfaces;
+            return Collections.unmodifiableSet(Pcaps.findAllDevs().stream().map(PcapNetworkInterfaceWrapper.TRANSFORMER)
+                    .collect(Collectors.toSet()));
         } catch (PcapNativeException e) {
             throw new RuntimeException(e);
         }
index 85f4bf3dc7236a2487ccfa5525c8c1fd9610ede1..86dde679b3deabb9d610658894d5f589bc10e7c5 100644 (file)
@@ -146,10 +146,10 @@ public class AmazonEchoControlHandlerFactory extends BaseThingHandlerFactory {
                             .getService(serviceReg.getReference());
                     serviceReg.unregister();
                     if (service != null) {
-                        if (service instanceof AmazonEchoDiscovery) {
-                            ((AmazonEchoDiscovery) service).deactivate();
-                        } else if (service instanceof SmartHomeDevicesDiscovery) {
-                            ((SmartHomeDevicesDiscovery) service).deactivate();
+                        if (service instanceof AmazonEchoDiscovery discovery) {
+                            discovery.deactivate();
+                        } else if (service instanceof SmartHomeDevicesDiscovery discovery) {
+                            discovery.deactivate();
                         } else {
                             logger.warn("Found unknown discovery-service instance: {}", service);
                         }
index 9b7c1295e5eaa7742591e2103c78d2b396993981..860784bf61a9c3685b497d7409886fc66a708ea2 100644 (file)
@@ -49,8 +49,8 @@ public class ChannelHandlerAnnouncement extends ChannelHandler {
     public boolean tryHandleCommand(Device device, Connection connection, String channelId, Command command)
             throws IOException, URISyntaxException {
         if (channelId.equals(CHANNEL_NAME)) {
-            if (command instanceof StringType) {
-                String commandValue = ((StringType) command).toFullString();
+            if (command instanceof StringType stringCommand) {
+                String commandValue = stringCommand.toFullString();
                 String body = commandValue;
                 String title = null;
                 String speak = commandValue;
index d7afb03d03dfc4e40bb41953ee9e064306345a44..2020bdd1e0dbe3a32cd042b5273b105f80b44f06 100644 (file)
@@ -26,6 +26,7 @@ import org.openhab.binding.amazonechocontrol.internal.jsons.JsonDevices.Device;
  */
 @NonNullByDefault
 public interface IEchoThingHandler extends IAmazonThingHandler {
+    @Override
     void startAnnouncement(Device device, String speak, String bodyText, @Nullable String title,
             @Nullable Integer volume) throws IOException, URISyntaxException;
 }
index 2cb40b64069f43ff3db2b1fd548538e816d23e4a..41cccfe1682a56f562d72792b13ad3c32eee8f93 100644 (file)
@@ -143,8 +143,7 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
             String deviceName = null;
             Map<String, Object> props = new HashMap<>();
 
-            if (smartHomeDevice instanceof SmartHomeDevice) {
-                SmartHomeDevice shd = (SmartHomeDevice) smartHomeDevice;
+            if (smartHomeDevice instanceof SmartHomeDevice shd) {
                 logger.trace("Found SmartHome device: {}", shd);
 
                 String entityId = shd.entityId;
@@ -165,7 +164,7 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
                     // Connected through skill
                     continue;
                 }
-                if (!(smartHomeDeviceDiscoveryMode == 2) && "openHAB".equalsIgnoreCase(shd.manufacturerName)) {
+                if (smartHomeDeviceDiscoveryMode != 2 && "openHAB".equalsIgnoreCase(shd.manufacturerName)) {
                     // OpenHAB device
                     continue;
                 }
@@ -203,8 +202,7 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
                     deviceName = shd.friendlyName;
                 }
                 props.put(DEVICE_PROPERTY_ID, id);
-            } else if (smartHomeDevice instanceof SmartHomeGroup) {
-                SmartHomeGroup shg = (SmartHomeGroup) smartHomeDevice;
+            } else if (smartHomeDevice instanceof SmartHomeGroup shg) {
                 logger.trace("Found SmartHome device: {}", shg);
 
                 String id = shg.findId();
index 9c773ac4cc8a5db90fb195b8b5a1454012079ca6..1eb78b4d31904ba68ee62c65e9ee5b1e6a4bc641 100644 (file)
@@ -821,8 +821,7 @@ public class AccountHandler extends BaseBridgeHandler implements IWebSocketComma
             // create new id map
             Map<String, SmartHomeBaseDevice> newJsonIdSmartHomeDeviceMapping = new HashMap<>();
             for (Object smartHomeDevice : smartHomeDevices) {
-                if (smartHomeDevice instanceof SmartHomeBaseDevice) {
-                    SmartHomeBaseDevice smartHomeBaseDevice = (SmartHomeBaseDevice) smartHomeDevice;
+                if (smartHomeDevice instanceof SmartHomeBaseDevice smartHomeBaseDevice) {
                     String id = smartHomeBaseDevice.findId();
                     if (id != null) {
                         newJsonIdSmartHomeDeviceMapping.put(id, smartHomeBaseDevice);
index 367667db4132ca83b8c91311052f99aeebc91ffe..13fa2b3e81aeca8cc998670765e7b085cc4de430 100644 (file)
@@ -293,8 +293,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
             }
             // Notification commands
             if (channelId.equals(CHANNEL_NOTIFICATION_VOLUME)) {
-                if (command instanceof PercentType) {
-                    int volume = ((PercentType) command).intValue();
+                if (command instanceof PercentType percentCommand) {
+                    int volume = percentCommand.intValue();
                     connection.notificationVolume(device, volume);
                     this.notificationVolumeLevel = volume;
                     waitForUpdate = -1;
@@ -318,21 +318,18 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
             // Media progress commands
             Long mediaPosition = null;
             if (channelId.equals(CHANNEL_MEDIA_PROGRESS)) {
-                if (command instanceof PercentType) {
-                    PercentType value = (PercentType) command;
-                    int percent = value.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    int percent = percentCommand.intValue();
                     mediaPosition = Math.round((mediaLengthMs / 1000d) * (percent / 100d));
                 }
             }
             if (channelId.equals(CHANNEL_MEDIA_PROGRESS_TIME)) {
-                if (command instanceof DecimalType) {
-                    DecimalType value = (DecimalType) command;
-                    mediaPosition = value.longValue();
+                if (command instanceof DecimalType decimalCommand) {
+                    mediaPosition = decimalCommand.longValue();
                 }
-                if (command instanceof QuantityType<?>) {
-                    QuantityType<?> value = (QuantityType<?>) command;
+                if (command instanceof QuantityType<?> quantityCommand) {
                     @Nullable
-                    QuantityType<?> seconds = value.toUnit(Units.SECOND);
+                    QuantityType<?> seconds = quantityCommand.toUnit(Units.SECOND);
                     if (seconds != null) {
                         mediaPosition = seconds.longValue();
                     }
@@ -353,9 +350,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
             // Volume commands
             if (channelId.equals(CHANNEL_VOLUME)) {
                 Integer volume = null;
-                if (command instanceof PercentType) {
-                    PercentType value = (PercentType) command;
-                    volume = value.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    volume = percentCommand.intValue();
                 } else if (command == OnOffType.OFF) {
                     volume = 0;
                 } else if (command == OnOffType.ON) {
@@ -393,8 +389,7 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
 
             // shuffle command
             if (channelId.equals(CHANNEL_SHUFFLE)) {
-                if (command instanceof OnOffType) {
-                    OnOffType value = (OnOffType) command;
+                if (command instanceof OnOffType value) {
 
                     connection.command(device, "{\"type\":\"ShuffleCommand\",\"shuffle\":\""
                             + (value == OnOffType.ON ? "true" : "false") + "\"}");
@@ -429,8 +424,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
             // bluetooth commands
             if (channelId.equals(CHANNEL_BLUETOOTH_MAC)) {
                 needBluetoothRefresh = true;
-                if (command instanceof StringType) {
-                    String address = ((StringType) command).toFullString();
+                if (command instanceof StringType stringCommand) {
+                    String address = stringCommand.toFullString();
                     if (!address.isEmpty()) {
                         waitForUpdate = 4000;
                     }
@@ -566,9 +561,8 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
                 }
             }
             if (channelId.equals(CHANNEL_TEXT_TO_SPEECH_VOLUME)) {
-                if (command instanceof PercentType) {
-                    PercentType value = (PercentType) command;
-                    textToSpeechVolume = value.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    textToSpeechVolume = percentCommand.intValue();
                 } else if (command == OnOffType.OFF) {
                     textToSpeechVolume = 0;
                 } else if (command == OnOffType.ON) {
@@ -680,8 +674,7 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
         if (command instanceof RefreshType) {
             this.lastKnownEqualizer = null;
         }
-        if (command instanceof DecimalType) {
-            DecimalType value = (DecimalType) command;
+        if (command instanceof DecimalType decimalCommand) {
             if (this.lastKnownEqualizer == null) {
                 updateEqualizerState();
             }
@@ -689,13 +682,13 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
             if (lastKnownEqualizer != null) {
                 JsonEqualizer newEqualizerSetting = lastKnownEqualizer.createClone();
                 if (channelId.equals(CHANNEL_EQUALIZER_BASS)) {
-                    newEqualizerSetting.bass = value.intValue();
+                    newEqualizerSetting.bass = decimalCommand.intValue();
                 }
                 if (channelId.equals(CHANNEL_EQUALIZER_MIDRANGE)) {
-                    newEqualizerSetting.mid = value.intValue();
+                    newEqualizerSetting.mid = decimalCommand.intValue();
                 }
                 if (channelId.equals(CHANNEL_EQUALIZER_TREBLE)) {
-                    newEqualizerSetting.treble = value.intValue();
+                    newEqualizerSetting.treble = decimalCommand.intValue();
                 }
                 try {
                     connection.setEqualizer(device, newEqualizerSetting);
index 756661aa7db507122e50ac378dfbc7288eb8f8b1..d37f4de7669c48d35d0864751674f319a22d29b3 100644 (file)
@@ -191,8 +191,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
         boolean stateFound = false;
         Map<String, List<JsonObject>> mapInterfaceToStates = new HashMap<>();
         SmartHomeDevice firstDevice = null;
-        for (SmartHomeDevice shd : getSupportedSmartHomeDevices(smartHomeBaseDevice, allDevices)) {
-            String applianceId = shd.applianceId;
+        for (SmartHomeDevice smartHomeDevice : getSupportedSmartHomeDevices(smartHomeBaseDevice, allDevices)) {
+            String applianceId = smartHomeDevice.applianceId;
             if (applianceId == null) {
                 continue;
             }
@@ -210,7 +210,7 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
                 }
             }
             if (firstDevice == null) {
-                firstDevice = shd;
+                firstDevice = smartHomeDevice;
             }
             for (JsonElement stateElement : states) {
                 String stateJson = stateElement.getAsString();
@@ -240,9 +240,9 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
                 }
             }
 
-            if (result.needSingleUpdate && smartHomeBaseDevice instanceof SmartHomeDevice && accountHandler != null) {
-                SmartHomeDevice shd = (SmartHomeDevice) smartHomeBaseDevice;
-                accountHandler.forceDelayedSmartHomeStateUpdate(shd.findId());
+            if (result.needSingleUpdate && smartHomeBaseDevice instanceof SmartHomeDevice smartHomeDevice
+                    && accountHandler != null) {
+                accountHandler.forceDelayedSmartHomeStateUpdate(smartHomeDevice.findId());
             }
         }
 
@@ -257,8 +257,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
         Bridge bridge = getBridge();
         if (bridge != null) {
             BridgeHandler bridgeHandler = bridge.getHandler();
-            if (bridgeHandler instanceof AccountHandler) {
-                return (AccountHandler) bridgeHandler;
+            if (bridgeHandler instanceof AccountHandler accountHandler) {
+                return accountHandler;
             }
         }
 
@@ -297,17 +297,17 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
                 if (handlerBase == null || !handlerBase.hasChannel(channelId)) {
                     continue;
                 }
-                for (SmartHomeDevice shd : devices) {
-                    String entityId = shd.entityId;
+                for (SmartHomeDevice smartHomeDevice : devices) {
+                    String entityId = smartHomeDevice.entityId;
                     if (entityId == null) {
                         continue;
                     }
                     accountHandler.forceDelayedSmartHomeStateUpdate(getId()); // block updates
-                    if (handlerBase.handleCommand(connection, shd, entityId, shd.getCapabilities(), channelUID.getId(),
-                            command)) {
+                    if (handlerBase.handleCommand(connection, smartHomeDevice, entityId,
+                            smartHomeDevice.getCapabilities(), channelUID.getId(), command)) {
                         accountHandler.forceDelayedSmartHomeStateUpdate(getId()); // force update again to restart
                         // update timer
-                        logger.debug("Command {} sent to {}", command, shd.findId());
+                        logger.debug("Command {} sent to {}", command, smartHomeDevice.findId());
                     }
                 }
             }
@@ -318,9 +318,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
 
     private static void getCapabilities(Map<String, List<SmartHomeCapability>> result, AccountHandler accountHandler,
             SmartHomeBaseDevice device) {
-        if (device instanceof SmartHomeDevice) {
-            SmartHomeDevice shd = (SmartHomeDevice) device;
-            for (SmartHomeCapability capability : shd.getCapabilities()) {
+        if (device instanceof SmartHomeDevice smartHomeDevice) {
+            for (SmartHomeCapability capability : smartHomeDevice.getCapabilities()) {
                 String interfaceName = capability.interfaceName;
                 if (interfaceName != null) {
                     Objects.requireNonNull(result.computeIfAbsent(interfaceName, name -> new ArrayList<>()))
@@ -329,9 +328,9 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
             }
         }
         if (device instanceof SmartHomeGroup) {
-            for (SmartHomeDevice shd : getSupportedSmartHomeDevices(device,
+            for (SmartHomeDevice smartHomeDevice : getSupportedSmartHomeDevices(device,
                     accountHandler.getLastKnownSmartHomeDevices())) {
-                getCapabilities(result, accountHandler, shd);
+                getCapabilities(result, accountHandler, smartHomeDevice);
             }
         }
     }
@@ -342,29 +341,28 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
             return Collections.emptySet();
         }
         Set<SmartHomeDevice> result = new HashSet<>();
-        if (baseDevice instanceof SmartHomeDevice) {
-            SmartHomeDevice shd = (SmartHomeDevice) baseDevice;
-            if (shd.getCapabilities().stream().map(capability -> capability.interfaceName)
+        if (baseDevice instanceof SmartHomeDevice smartHomeDevice) {
+            if (smartHomeDevice.getCapabilities().stream().map(capability -> capability.interfaceName)
                     .anyMatch(SUPPORTED_INTERFACES::contains)) {
-                result.add(shd);
+                result.add(smartHomeDevice);
             }
         } else {
-            SmartHomeGroup shg = (SmartHomeGroup) baseDevice;
+            SmartHomeGroup smartHomeGroup = (SmartHomeGroup) baseDevice;
             for (SmartHomeBaseDevice device : allDevices) {
-                if (device instanceof SmartHomeDevice) {
-                    SmartHomeDevice shd = (SmartHomeDevice) device;
-                    JsonSmartHomeTags.JsonSmartHomeTag tags = shd.tags;
+                if (device instanceof SmartHomeDevice smartHomeDevice) {
+                    JsonSmartHomeTags.JsonSmartHomeTag tags = smartHomeDevice.tags;
                     if (tags != null) {
                         JsonSmartHomeGroupIdentity.SmartHomeGroupIdentity tagNameToValueSetMap = tags.tagNameToValueSetMap;
-                        JsonSmartHomeGroupIdentifiers.SmartHomeGroupIdentifier applianceGroupIdentifier = shg.applianceGroupIdentifier;
+                        JsonSmartHomeGroupIdentifiers.SmartHomeGroupIdentifier applianceGroupIdentifier = smartHomeGroup.applianceGroupIdentifier;
                         if (tagNameToValueSetMap != null) {
                             List<String> groupIdentity = Objects.requireNonNullElse(tagNameToValueSetMap.groupIdentity,
                                     List.of());
                             if (applianceGroupIdentifier != null && applianceGroupIdentifier.value != null
                                     && groupIdentity.contains(applianceGroupIdentifier.value)) {
-                                if (shd.getCapabilities().stream().map(capability -> capability.interfaceName)
+                                if (smartHomeDevice.getCapabilities().stream()
+                                        .map(capability -> capability.interfaceName)
                                         .anyMatch(SUPPORTED_INTERFACES::contains)) {
-                                    result.add(shd);
+                                    result.add(smartHomeDevice);
                                 }
                             }
                         }
index 07d1bee09a736b5286ee8335ea330e6e3b57c41c..098da95b4dd722bda299f2f3e1f33077a7d6fd17 100644 (file)
@@ -55,11 +55,10 @@ public class DynamicStateDescriptionSmartHome implements DynamicStateDescription
             return null;
         }
         ThingHandler handler = thing.getHandler();
-        if (!(handler instanceof SmartHomeDeviceHandler)) {
-            return null;
+        if (handler instanceof SmartHomeDeviceHandler smartHomeHandler) {
+            return smartHomeHandler;
         }
-        SmartHomeDeviceHandler smartHomeHandler = (SmartHomeDeviceHandler) handler;
-        return smartHomeHandler;
+        return null;
     }
 
     @Override
index 08f31998a67c85cd0c0e2019c824b0288616ed61..16a46e454ecc36a12de736d4fc8f2a14303f5bb7 100644 (file)
@@ -263,11 +263,10 @@ public class AmbientWeatherEventListener {
     private void handleError(String event, Object... args) {
         String reason = "Unknown";
         if (args.length > 0) {
-            if (args[0] instanceof String) {
-                reason = (String) args[0];
-            } else if (args[0] instanceof Exception) {
-                reason = String.format("Exception=%s Message=%s", args[0].getClass(),
-                        ((Exception) args[0]).getMessage());
+            if (args[0] instanceof String stringArg) {
+                reason = stringArg;
+            } else if (args[0] instanceof Exception exception) {
+                reason = String.format("Exception=%s Message=%s", args[0].getClass(), exception.getMessage());
             }
         }
         logger.debug("Listener: Received socket event: {}, Reason: {}", event, reason);
index 4f3849ec4f1ed99ac4a1e3b2b6a8831f1e5e67f7..d0ffccd651dbc29fc4a333e34b00d9201cd02990 100644 (file)
@@ -39,7 +39,7 @@ public enum StreamCommand {
 
   @Override
   public String toString() {
-    return String.valueOf(value);
+    return value;
   }
 
   public static StreamCommand fromValue(String value) {
index 732381272ad875711ba1748f05c62bc37cf33815..6c5f863a365cab2dfaa1d61716f601ecfab12a86 100644 (file)
@@ -109,8 +109,8 @@ public class AmpliPiGroupHandler extends BaseThingHandler implements AmpliPiStat
                 }
                 break;
             case AmpliPiBindingConstants.CHANNEL_VOLUME:
-                if (command instanceof PercentType) {
-                    update.setVolDelta(AmpliPiUtils.percentTypeToVolume((PercentType) command));
+                if (command instanceof PercentType percentCommand) {
+                    update.setVolDelta(AmpliPiUtils.percentTypeToVolume(percentCommand));
                 } else if (command instanceof IncreaseDecreaseType) {
                     if (groupState != null) {
                         if (IncreaseDecreaseType.INCREASE.equals(command)) {
@@ -125,14 +125,13 @@ public class AmpliPiGroupHandler extends BaseThingHandler implements AmpliPiStat
                 }
                 break;
             case AmpliPiBindingConstants.CHANNEL_SOURCE:
-                if (command instanceof DecimalType) {
-                    update.setSourceId(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    update.setSourceId(decimalCommand.intValue());
                 }
                 break;
         }
         if (bridgeHandler != null) {
             String url = bridgeHandler.getUrl() + "/api/groups/" + getId(thing);
-            ;
             StringContentProvider contentProvider = new StringContentProvider(gson.toJson(update));
             try {
                 ContentResponse response = httpClient.newRequest(url).method(HttpMethod.PATCH)
index 8064bed113dcf3d12aef7814c87f6021e3bd2734..f5236a766906ff030a98abac9131a36d426431ea 100644 (file)
@@ -99,12 +99,11 @@ public class AmpliPiHandler extends BaseBridgeHandler {
         if (CHANNEL_PRESET.equals(channelUID.getId())) {
             if (command instanceof RefreshType) {
                 updateState(channelUID, UnDefType.NULL);
-            } else if (command instanceof DecimalType) {
-                DecimalType preset = (DecimalType) command;
+            } else if (command instanceof DecimalType decimalCommand) {
                 try {
                     ContentResponse response = this.httpClient
-                            .newRequest(url + "/api/presets/" + preset.intValue() + "/load").method(HttpMethod.POST)
-                            .timeout(REQUEST_TIMEOUT, TimeUnit.MILLISECONDS).send();
+                            .newRequest(url + "/api/presets/" + decimalCommand.intValue() + "/load")
+                            .method(HttpMethod.POST).timeout(REQUEST_TIMEOUT, TimeUnit.MILLISECONDS).send();
                     if (response.getStatus() != HttpStatus.OK_200) {
                         logger.error("AmpliPi API returned HTTP status {}.", response.getStatus());
                         logger.debug("Content: {}", response.getContentAsString());
@@ -115,11 +114,10 @@ public class AmpliPiHandler extends BaseBridgeHandler {
                 }
             }
         } else if (channelUID.getId().startsWith(CHANNEL_INPUT)) {
-            if (command instanceof StringType) {
-                StringType input = (StringType) command;
+            if (command instanceof StringType stringCommand) {
                 int source = Integer.valueOf(channelUID.getId().substring(CHANNEL_INPUT.length())) - 1;
                 SourceUpdate update = new SourceUpdate();
-                update.setInput(input.toString());
+                update.setInput(stringCommand.toString());
                 try {
                     StringContentProvider contentProvider = new StringContentProvider(gson.toJson(update));
                     ContentResponse response = this.httpClient.newRequest(url + "/api/sources/" + source)
index 78ed933bc97abe0d1a9ba26bcb3c28b506301a0b..1cba6138edf4b607cb9c2f54e05fb2699b974dbf 100644 (file)
@@ -109,8 +109,8 @@ public class AmpliPiZoneHandler extends BaseThingHandler implements AmpliPiStatu
                 }
                 break;
             case AmpliPiBindingConstants.CHANNEL_VOLUME:
-                if (command instanceof PercentType) {
-                    update.setVol(AmpliPiUtils.percentTypeToVolume((PercentType) command));
+                if (command instanceof PercentType percentCommand) {
+                    update.setVol(AmpliPiUtils.percentTypeToVolume(percentCommand));
                 } else if (command instanceof IncreaseDecreaseType) {
                     if (zoneState != null) {
                         if (IncreaseDecreaseType.INCREASE.equals(command)) {
@@ -125,8 +125,8 @@ public class AmpliPiZoneHandler extends BaseThingHandler implements AmpliPiStatu
                 }
                 break;
             case AmpliPiBindingConstants.CHANNEL_SOURCE:
-                if (command instanceof DecimalType) {
-                    update.setSourceId(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    update.setSourceId(decimalCommand.intValue());
                 }
                 break;
         }
index 0edd7d91284b281205c894f10046a21bcb5fb3cd..b17396604016a6359ead018fd43d41eb619e9a95 100644 (file)
@@ -65,7 +65,7 @@ public class InputStateOptionProvider extends BaseDynamicStateDescriptionProvide
     }
 
     private @Nullable String getLabel(Stream stream) {
-        if (stream.getType().equals("internetradio")) {
+        if ("internetradio".equals(stream.getType())) {
             return stream.getName();
         } else {
             return stream.getType().substring(0, 1).toUpperCase() + stream.getType().substring(1);
index 9131a3f8a7ab84a5cc7a36c0dd454fd8bb278927..6dff237e1de276f4d632967742dbf4d2d59f2262 100644 (file)
@@ -54,10 +54,9 @@ public class AmpliPiMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant
     public @Nullable DiscoveryResult createResult(ServiceInfo service) {
         ThingUID uid = getThingUID(service);
         if (uid != null) {
-            DiscoveryResult result = DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Controller")
+            return DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Controller")
                     .withProperty(AmpliPiBindingConstants.CFG_PARAM_HOSTNAME, getIpAddress(service).getHostAddress())
                     .withRepresentationProperty(AmpliPiBindingConstants.CFG_PARAM_HOSTNAME).build();
-            return result;
         } else {
             return null;
         }
@@ -68,7 +67,7 @@ public class AmpliPiMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant
         if (service.getName().equals(AMPLIPI_API)) {
             InetAddress ip = getIpAddress(service);
             if (ip != null) {
-                String id = ip.toString().substring(1).replaceAll("\\.", "");
+                String id = ip.toString().substring(1).replace(".", "");
                 return new ThingUID(AmpliPiBindingConstants.THING_TYPE_CONTROLLER, id);
             }
         }
index a35897f9a0a5038e1f50a68eea2425f0a3e8ee02..8765072b5241454ea936939fddfec5e0bccb1337 100644 (file)
@@ -246,13 +246,13 @@ public class AndroidDebugBridgeDevice {
             AndroidDebugBridgeDeviceReadException, TimeoutException, ExecutionException {
         if (isAtLeastVersion(12)) {
             String devicesResp = runAdbShell("getprop", "debug.tracing.screen_state");
-            return devicesResp.replace("\n", "").equals("2");
+            return "2".equals(devicesResp.replace("\n", ""));
         }
         String devicesResp = runAdbShell("dumpsys", "power", "|", "grep", "'Display Power'");
         if (devicesResp.contains("=")) {
             try {
                 var state = devicesResp.split("=")[1].trim();
-                return state.equals("ON");
+                return "ON".equals(state);
             } catch (NumberFormatException e) {
                 logger.debug("Unable to parse device screen state: {}", e.getMessage());
             }
index be66cb3093731415bbabd4dc0835f29604aea7d4..a4ff9e13d4e7440a6ede702df5c2f9f3042e9869 100644 (file)
@@ -161,7 +161,7 @@ public class AndroidDebugBridgeDiscoveryService extends AbstractDiscoveryService
             String brand, String macAddress) {
         String friendlyName = String.format("%s (%s)", model, ip);
         thingDiscovered(
-                DiscoveryResultBuilder.create(new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replaceAll(":", ""))) //
+                DiscoveryResultBuilder.create(new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replace(":", ""))) //
                         .withProperties(Map.of( //
                                 PARAMETER_IP, ip, //
                                 PARAMETER_PORT, port, //
index 9a252504ec40e504c42795180e23854de3fc09c9..6b7a9d97a1854ce903179c7d499f5f452d8a174c 100644 (file)
@@ -104,7 +104,7 @@ public class AndroidTVMDNSDiscoveryParticipant implements MDNSDiscoveryParticipa
     public @Nullable ThingUID getThingUID(ServiceInfo service) {
         String macAddress = service.getPropertyString(MDNS_PROPERTY_MAC_ADDRESS);
         if (macAddress != null && !macAddress.isBlank()) {
-            return new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replaceAll(":", "").toLowerCase());
+            return new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replace(":", "").toLowerCase());
         }
         return null;
     }
index a0c21c3d016175c7f7cc37ac64973080ce107c7c..8d768dd06759bda6aef20a742621eccfa22c0030 100644 (file)
@@ -104,7 +104,7 @@ public class FireTVStickMDNSDiscoveryParticipant implements MDNSDiscoveryPartici
     public @Nullable ThingUID getThingUID(ServiceInfo service) {
         String macAddress = service.getPropertyString(MDNS_PROPERTY_MAC_ADDRESS);
         if (macAddress != null && !macAddress.isBlank()) {
-            return new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replaceAll(":", "").toLowerCase());
+            return new ThingUID(THING_TYPE_ANDROID_DEVICE, macAddress.replace(":", "").toLowerCase());
         }
         return null;
     }
index 50876df94f6b3b79b8773ca73e05f33360b124f8..6ccf993e0e333fb13344398da892bfa8a2b7e42c 100644 (file)
@@ -135,8 +135,8 @@ public class AnelStateUpdaterTest implements IAnelTestStatus, IAnelConstants {
 
     private void assertTemperature(@Nullable State state, double value) {
         assertThat(state, isA(QuantityType.class));
-        if (state instanceof QuantityType<?>) {
-            assertThat(((QuantityType<?>) state).doubleValue(), closeTo(value, 0.0001d));
+        if (state instanceof QuantityType<?> temperature) {
+            assertThat(temperature.doubleValue(), closeTo(value, 0.0001d));
         }
     }
 }
index 1c7a9e60ce694c4a26c0c9fc8e7cf42c84b84e3e..727dd7056c61ecb7780d3708e0dfbd2cfd99f531 100644 (file)
@@ -144,7 +144,7 @@ public class AnelUdpConnectorTest {
 
         // toggle state of switch 1
         final String auth = AnelAuthentication.getUserPasswordString(USER, PASSWORD, AuthMethod.of(status));
-        final String command = "Sw_" + (switch1state ? "off" : "on") + String.valueOf(switchNr) + auth;
+        final String command = "Sw_" + (switch1state ? "off" : "on") + switchNr + auth;
         final String status2 = sendAndReceiveSingle(command);
 
         // assert new state of switch 1
index 8daef5081fa5e6ba6954d1e781600f296e046091..c91b70ff4e98ad8034e0c11e146976f092e27e86 100644 (file)
@@ -22,26 +22,40 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 @NonNullByDefault
 public interface IAnelTestStatus {
 
-    String STATUS_INVALID_NAME = "NET-PwrCtrl:NET-CONTROL    :192.168.6.63:255.255.255.0:192.168.6.1:0.4.163.21.4.71:"
-            + "Nr. 1,0:Nr. 2,1:Nr: 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,0:Nr. 8,0:248:80:NET-PWRCTRL_04.6:H:xor:";
-    String STATUS_HUT_V61_POW = "NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:"
-            + "Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:"
-            + "IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:"
-            + "p:225.9:0.0004:50.056:0.04:0.00:0.0:1.0000:xor:";
-    String STATUS_HUT_V61_SENSOR = "NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:"
-            + "Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:"
-            + "IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:"
-            + "n:s:20.61:40.7:7.0:xor:";
-    String STATUS_HUT_V61_POW_SENSOR = "NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:"
-            + "Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:"
-            + "IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:"
-            + "p:225.9:0.0004:50.056:0.04:0.00:0.0:1.0000:s:20.61:40.7:7.0:xor";
-    String STATUS_HUT_V5 = "NET-PwrCtrl:ANEL1          :192.168.0.244:255.255.255.0:192.168.0.1:0.5.163.14.7.91:"
-            + "hoch,0:links hoch,0:runter,0:rechts run,0:runter,0:hoch,0:links runt,0:rechts hoc,0:0:80:"
-            + "WHN_UP,1,1:LI_DOWN,1,1:RE_DOWN,1,1:LI_UP,1,1:RE_UP,1,1:DOWN,1,1:DOWN,1,1:UP,1,1:27.3°C:NET-PWRCTRL_05.0";
-    String STATUS_HUT_V65 = "NET-PwrCtrl:NET-CONTROL    :192.168.0.64:255.255.255.0:192.168.6.1:0.5.163.17.9.116:"
-            + "Nr.1,0:Nr.2,1:Nr.3,0:Nr.4,1:Nr.5,0:Nr.6,1:Nr.7,0:Nr.8,1:248:80:"
-            + "IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,1,0:IO-6,1,0:IO-7,1,0:IO-8,1,0:27.0�C:NET-PWRCTRL_06.5:h:n:xor:";
-    String STATUS_HOME_V46 = "NET-PwrCtrl:NET-CONTROL    :192.168.0.63:255.255.255.0:192.168.6.1:0.5.163.21.4.71:"
-            + "Nr. 1,1:Nr. 2,0:Nr. 3,1:Nr. 4,0:Nr. 5,1:Nr. 6,0:Nr. 7,1:Nr. 8,0:248:80:NET-PWRCTRL_04.6:H:xor:";
+    String STATUS_INVALID_NAME = """
+            NET-PwrCtrl:NET-CONTROL    :192.168.6.63:255.255.255.0:192.168.6.1:0.4.163.21.4.71:\
+            Nr. 1,0:Nr. 2,1:Nr: 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,0:Nr. 8,0:248:80:NET-PWRCTRL_04.6:H:xor:\
+            """;
+    String STATUS_HUT_V61_POW = """
+            NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:\
+            Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:\
+            IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:\
+            p:225.9:0.0004:50.056:0.04:0.00:0.0:1.0000:xor:\
+            """;
+    String STATUS_HUT_V61_SENSOR = """
+            NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:\
+            Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:\
+            IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:\
+            n:s:20.61:40.7:7.0:xor:\
+            """;
+    String STATUS_HUT_V61_POW_SENSOR = """
+            NET-PwrCtrl:NET-CONTROL :192.168.178.148:255.255.255.0:192.168.178.1:0.4.163.10.9.107:\
+            Nr. 1,1:Nr. 2,1:Nr. 3,1:Nr. 4,0:Nr. 5,0:Nr. 6,0:Nr. 7,1:Nr. 8,1:0:80:\
+            IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,0,0:IO-6,0,0:IO-7,0,0:IO-8,0,0:27.7°C:NET-PWRCTRL_06.1:h:\
+            p:225.9:0.0004:50.056:0.04:0.00:0.0:1.0000:s:20.61:40.7:7.0:xor\
+            """;
+    String STATUS_HUT_V5 = """
+            NET-PwrCtrl:ANEL1          :192.168.0.244:255.255.255.0:192.168.0.1:0.5.163.14.7.91:\
+            hoch,0:links hoch,0:runter,0:rechts run,0:runter,0:hoch,0:links runt,0:rechts hoc,0:0:80:\
+            WHN_UP,1,1:LI_DOWN,1,1:RE_DOWN,1,1:LI_UP,1,1:RE_UP,1,1:DOWN,1,1:DOWN,1,1:UP,1,1:27.3°C:NET-PWRCTRL_05.0\
+            """;
+    String STATUS_HUT_V65 = """
+            NET-PwrCtrl:NET-CONTROL    :192.168.0.64:255.255.255.0:192.168.6.1:0.5.163.17.9.116:\
+            Nr.1,0:Nr.2,1:Nr.3,0:Nr.4,1:Nr.5,0:Nr.6,1:Nr.7,0:Nr.8,1:248:80:\
+            IO-1,0,0:IO-2,0,0:IO-3,0,0:IO-4,0,0:IO-5,1,0:IO-6,1,0:IO-7,1,0:IO-8,1,0:27.0�C:NET-PWRCTRL_06.5:h:n:xor:\
+            """;
+    String STATUS_HOME_V46 = """
+            NET-PwrCtrl:NET-CONTROL    :192.168.0.63:255.255.255.0:192.168.6.1:0.5.163.21.4.71:\
+            Nr. 1,1:Nr. 2,0:Nr. 3,1:Nr. 4,0:Nr. 5,1:Nr. 6,0:Nr. 7,1:Nr. 8,0:248:80:NET-PWRCTRL_04.6:H:xor:\
+            """;
 }
index 2e7448c93b0c0ea1196f32f4b3bcd16736f07dab..dc987e50e2037f5822f455854a82cf5324bc0c4e 100644 (file)
@@ -116,7 +116,7 @@ public class AnthemHandler extends BaseThingHandler {
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
-        logger.trace("Command {} received for channel {}", command, channelUID.getId().toString());
+        logger.trace("Command {} received for channel {}", command, channelUID.getId());
         String groupId = channelUID.getGroupId();
         if (groupId == null) {
             return;
@@ -166,8 +166,8 @@ public class AnthemHandler extends BaseThingHandler {
                 }
                 break;
             case CHANNEL_VOLUME_DB:
-                if (command instanceof DecimalType) {
-                    sendCommand(AnthemCommand.volume(zone, ((DecimalType) command).intValue()));
+                if (command instanceof DecimalType decimalCommand) {
+                    sendCommand(AnthemCommand.volume(zone, decimalCommand.intValue()));
                 }
                 break;
             case CHANNEL_MUTE:
@@ -180,8 +180,8 @@ public class AnthemHandler extends BaseThingHandler {
                 }
                 break;
             case CHANNEL_ACTIVE_INPUT:
-                if (command instanceof DecimalType) {
-                    sendCommand(AnthemCommand.activeInput(zone, ((DecimalType) command).intValue()));
+                if (command instanceof DecimalType decimalCommand) {
+                    sendCommand(AnthemCommand.activeInput(zone, decimalCommand.intValue()));
                 }
                 break;
             default:
index ed6b007ab132ab16f9035989ea850021120f3d60..c4af735d7bce59bd8db421a15f9f4830998fe73a 100644 (file)
@@ -52,8 +52,8 @@ public class AstroActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof AstroThingHandler) {
-            this.handler = (AstroThingHandler) handler;
+        if (handler instanceof AstroThingHandler thingHandler) {
+            this.handler = thingHandler;
         }
     }
 
@@ -115,10 +115,9 @@ public class AstroActions implements ThingActions {
         try {
             AstroThingHandler theHandler = this.handler;
             if (theHandler != null) {
-                if (theHandler instanceof SunHandler) {
-                    SunHandler handler = (SunHandler) theHandler;
+                if (theHandler instanceof SunHandler sunHandler) {
                     SunPhaseName phase = SunPhaseName.valueOf(phaseName.toUpperCase());
-                    return handler.getEventTime(phase, date != null ? date : ZonedDateTime.now(),
+                    return sunHandler.getEventTime(phase, date != null ? date : ZonedDateTime.now(),
                             moment == null || AstroBindingConstants.EVENT_START.equalsIgnoreCase(moment));
                 } else {
                     logger.info("Astro Action service ThingHandler is not a SunHandler!");
index f6c5b00f4be87e3ee421a1ac960d2a182bb9f1ce..ad0a06fedab76c740dc68988474218712c8de215 100644 (file)
@@ -490,8 +490,7 @@ public class MoonCalc {
         double m1 = 134.9634114 + 477198.8676313 * t + .008997 * t * t + t * t * t / 69699 - t * t * t * t / 14712000;
         double f = 93.27209929999999 + 483202.0175273 * t - .0034029 * t * t - t * t * t / 3526000
                 + t * t * t * t / 863310000;
-        double sr = 385000.56 + getCoefficient(d, m, m1, f) / 1000;
-        return sr;
+        return 385000.56 + getCoefficient(d, m, m1, f) / 1000;
     }
 
     private double[] calcMoon(double t) {
@@ -540,7 +539,7 @@ public class MoonCalc {
     private double SINALT(double moonJd, int hour, double lambda, double cphi, double sphi) {
         double jdo = moonJd + hour / 24.0;
         double t = (jdo - 51544.5) / 36525.0;
-        double decra[] = calcMoon(t);
+        double[] decra = calcMoon(t);
         double tau = 15.0 * (LMST(jdo, lambda) - decra[1]);
         return sphi * SN(decra[0]) + cphi * CS(decra[0]) * CS(tau);
     }
@@ -688,12 +687,12 @@ public class MoonCalc {
         double moonLon = mod2Pi(n2 + Math.atan2(Math.sin(l3 - n2) * Math.cos(i), Math.cos(l3 - n2)));
         double moonLat = Math.asin(Math.sin(l3 - n2) * Math.sin(i));
 
-        double raDec[] = ecl2Equ(moonLat, moonLon, julianDate);
+        double[] raDec = ecl2Equ(moonLat, moonLon, julianDate);
 
         double distance = (1 - 0.00301401) / (1 + 0.054900 * Math.cos(mMoon2 + ec)) * 384401;
 
-        double raDecTopo[] = geoEqu2TopoEqu(raDec, distance, lat, lmst);
-        double azAlt[] = equ2AzAlt(raDecTopo[0], raDecTopo[1], lat, lmst);
+        double[] raDecTopo = geoEqu2TopoEqu(raDec, distance, lat, lmst);
+        double[] azAlt = equ2AzAlt(raDecTopo[0], raDecTopo[1], lat, lmst);
 
         Position position = moon.getPosition();
         position.setAzimuth(azAlt[0] * SunCalc.RAD2DEG);
index 767bf11125eadb357a0f7f25ebd4f564b724e01f..718e7339f826323283e36f2eb8a9b1a607f32707 100644 (file)
@@ -22,7 +22,6 @@ import java.time.ZonedDateTime;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -366,6 +365,6 @@ public abstract class AstroThingHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(AstroActions.class);
+        return List.of(AstroActions.class);
     }
 }
index 19d47153a41cebc1ea01b1a120531619260063f7..051f8886bd9d6cd7d21971079182fef05c3ac0a9 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.astro.internal.job;
 
-import static java.util.Collections.singletonList;
 import static java.util.stream.Collectors.toList;
 import static org.openhab.binding.astro.internal.AstroBindingConstants.*;
 import static org.openhab.binding.astro.internal.util.DateTimeUtils.*;
@@ -72,7 +71,7 @@ public interface Job extends SchedulerRunnable, Runnable {
      */
     static void scheduleEvent(String thingUID, AstroThingHandler astroHandler, Calendar eventAt, String event,
             String channelId, boolean configAlreadyApplied) {
-        scheduleEvent(thingUID, astroHandler, eventAt, singletonList(event), channelId, configAlreadyApplied);
+        scheduleEvent(thingUID, astroHandler, eventAt, List.of(event), channelId, configAlreadyApplied);
     }
 
     /**
index 78336bde5d7ef9509a66014eb11a6209bb26fe61..096772b27b6669a7539eacb7fda9debf293a13f6 100644 (file)
@@ -53,9 +53,8 @@ public final class SunPhaseJob extends AbstractJob {
             Channel phaseNameChannel = astroHandler.getThing().getChannel(CHANNEL_ID_SUN_PHASE_NAME);
             if (phaseNameChannel != null) {
                 Planet planet = astroHandler.getPlanet();
-                if (planet != null && planet instanceof Sun) {
-                    final Sun typedSun = (Sun) planet;
-                    typedSun.getPhase().setName(sunPhaseName);
+                if (planet instanceof Sun theSun) {
+                    theSun.getPhase().setName(sunPhaseName);
                     astroHandler.publishChannelIfLinked(phaseNameChannel.getUID());
                 }
             } else {
index 8b7c9946977caaa09b6a74ea7b0dc677ca883149..78c6130d859d3a3ced044ef1e3b7f3a197ba83bc 100644 (file)
@@ -23,5 +23,5 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 public enum EclipseKind {
     PARTIAL,
     TOTAL,
-    RING;
+    RING
 }
index c5b8302ac1c7edd2dca11343ea1718a248dc1534..b63826d57dc0216e1d045243525c17ca3f301a3a 100644 (file)
@@ -22,5 +22,5 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 @NonNullByDefault
 public enum EclipseType {
     SUN,
-    MOON;
+    MOON
 }
index 7cccf4269ce0f796e7f9ed14c4d1c294b6ce9454..05b962f88c512098ca7a99b89081b66d97bb9ac0 100644 (file)
@@ -57,10 +57,9 @@ public class PropertyUtils {
         Object value = getPropertyValue(channelUID, instance);
         if (value == null) {
             return UnDefType.UNDEF;
-        } else if (value instanceof State) {
-            return (State) value;
-        } else if (value instanceof Calendar) {
-            Calendar cal = (Calendar) value;
+        } else if (value instanceof State state) {
+            return state;
+        } else if (value instanceof Calendar cal) {
             GregorianCalendar gregorianCal = (GregorianCalendar) DateTimeUtils.applyConfig(cal, config);
             cal.setTimeZone(TimeZone.getTimeZone(zoneId));
             ZonedDateTime zoned = gregorianCal.toZonedDateTime().withFixedOffsetZone();
index 585de5350ba80533b9bacdc0ef827f54eb71aea0..739f4dbb65388e2d7ba039f0993c502a625039f3 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.atlona.internal;
 
 import static org.openhab.binding.atlona.internal.AtlonaBindingConstants.*;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -69,7 +68,7 @@ public class AtlonaHandlerFactory extends BaseThingHandlerFactory {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
         if (thingTypeUID.equals(THING_TYPE_PRO3_44M)) {
-            return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Collections.singleton(5), true));
+            return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Set.of(5), true));
         }
 
         if (thingTypeUID.equals(THING_TYPE_PRO3_66M)) {
index e7f5d6e645c6199ef8b12ca6845e01819cb228ee..d7ff334247c36d87c67f805328c76b4496271620 100644 (file)
@@ -197,17 +197,17 @@ public class AtlonaDiscovery extends AbstractDiscoveryService {
                 String name = msg.substring(0, idx);
 
                 if ("Host".equalsIgnoreCase(name)) {
-                    host = msg.substring(idx + 1).trim().replaceAll("\"", "");
+                    host = msg.substring(idx + 1).trim().replace("\"", "");
                     int sep = host.indexOf('_');
                     if (sep >= 0) {
                         host = host.substring(sep + 1);
                     }
                 } else if ("Model".equalsIgnoreCase(name)) {
-                    model = msg.substring(idx + 1).trim().replaceAll("\"", "");
+                    model = msg.substring(idx + 1).trim().replace("\"", "");
                 } else if ("Manufacturer".equalsIgnoreCase(name)) {
-                    manufacturer = msg.substring(idx + 1).trim().replaceAll("\"", "");
+                    manufacturer = msg.substring(idx + 1).trim().replace("\"", "");
                 } else if ("From".equalsIgnoreCase(name)) {
-                    from = msg.substring(idx + 1).trim().replaceAll("\"", "");
+                    from = msg.substring(idx + 1).trim().replace("\"", "");
                     int sep = from.indexOf(':');
                     if (sep >= 0) {
                         from = from.substring(0, sep);
index 36324b02678e5823ac0e91f8478733749ff8e15c..1dea1c8a85069e788983c41d279fb3ad61e1a5d5 100644 (file)
@@ -349,23 +349,23 @@ public class SocketChannelSession implements SocketSession {
                     final Object response = responses.poll(1, TimeUnit.SECONDS);
 
                     if (response != null) {
-                        if (response instanceof String) {
+                        if (response instanceof String stringResponse) {
                             try {
                                 logger.debug("Dispatching response: {}", response);
                                 final SocketSessionListener[] listeners = SocketChannelSession.this.listeners
                                         .toArray(new SocketSessionListener[0]);
                                 for (SocketSessionListener listener : listeners) {
-                                    listener.responseReceived((String) response);
+                                    listener.responseReceived(stringResponse);
                                 }
                             } catch (Exception e) {
                                 logger.warn("Exception occurred processing the response '{}': ", response, e);
                             }
-                        } else if (response instanceof Exception) {
+                        } else if (response instanceof Exception exceptionResponse) {
                             logger.debug("Dispatching exception: {}", response);
                             final SocketSessionListener[] listeners = SocketChannelSession.this.listeners
                                     .toArray(new SocketSessionListener[0]);
                             for (SocketSessionListener listener : listeners) {
-                                listener.responseException((Exception) response);
+                                listener.responseException(exceptionResponse);
                             }
                         } else {
                             logger.warn("Unknown response class: {}", response);
index ffbeb04f0cfcf0975349862b508995af0431afbf..8dcc8b5ba34386ec44beeb06de6f163a77ed9456 100644 (file)
@@ -133,8 +133,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
         if ((m = GROUP_PRIMARY_PATTERN.matcher(group)).matches()) {
             switch (id) {
                 case AtlonaPro3Constants.CHANNEL_POWER:
-                    if (command instanceof OnOffType) {
-                        final boolean makeOn = ((OnOffType) command) == OnOffType.ON;
+                    if (command instanceof OnOffType onOffCommand) {
+                        final boolean makeOn = onOffCommand == OnOffType.ON;
                         atlonaHandler.setPower(makeOn);
                     } else {
                         logger.debug("Received a POWER channel command with a non OnOffType: {}", command);
@@ -143,8 +143,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
                     break;
 
                 case AtlonaPro3Constants.CHANNEL_PANELLOCK:
-                    if (command instanceof OnOffType) {
-                        final boolean makeOn = ((OnOffType) command) == OnOffType.ON;
+                    if (command instanceof OnOffType onOffCommand) {
+                        final boolean makeOn = onOffCommand == OnOffType.ON;
                         atlonaHandler.setPanelLock(makeOn);
                     } else {
                         logger.debug("Received a PANELLOCK channel command with a non OnOffType: {}", command);
@@ -152,8 +152,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
                     break;
 
                 case AtlonaPro3Constants.CHANNEL_IRENABLE:
-                    if (command instanceof OnOffType) {
-                        final boolean makeOn = ((OnOffType) command) == OnOffType.ON;
+                    if (command instanceof OnOffType onOffCommand) {
+                        final boolean makeOn = onOffCommand == OnOffType.ON;
                         atlonaHandler.setIrOn(makeOn);
                     } else {
                         logger.debug("Received an IRLOCK channel command with a non OnOffType: {}", command);
@@ -232,8 +232,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
 
                     switch (id) {
                         case AtlonaPro3Constants.CHANNEL_PORTOUTPUT:
-                            if (command instanceof DecimalType) {
-                                final int inpNbr = ((DecimalType) command).intValue();
+                            if (command instanceof DecimalType decimalCommand) {
+                                final int inpNbr = decimalCommand.intValue();
                                 atlonaHandler.setPortSwitch(inpNbr, portNbr);
                             } else {
                                 logger.debug("Received a PORTOUTPUT channel command with a non DecimalType: {}",
@@ -243,8 +243,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
                             break;
 
                         case AtlonaPro3Constants.CHANNEL_PORTPOWER:
-                            if (command instanceof OnOffType) {
-                                final boolean makeOn = ((OnOffType) command) == OnOffType.ON;
+                            if (command instanceof OnOffType onOffCommand) {
+                                final boolean makeOn = onOffCommand == OnOffType.ON;
                                 atlonaHandler.setPortPower(portNbr, makeOn);
                             } else {
                                 logger.debug("Received a PORTPOWER channel command with a non OnOffType: {}", command);
@@ -265,8 +265,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
 
                     switch (id) {
                         case AtlonaPro3Constants.CHANNEL_PORTMIRROR:
-                            if (command instanceof DecimalType) {
-                                final int outPortNbr = ((DecimalType) command).intValue();
+                            if (command instanceof DecimalType decimalCommand) {
+                                final int outPortNbr = decimalCommand.intValue();
                                 if (outPortNbr <= 0) {
                                     atlonaHandler.removePortMirror(hdmiPortNbr);
                                 } else {
@@ -285,8 +285,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
                                             .getCallback();
                                     final State state = callback.getState(AtlonaPro3Constants.CHANNEL_PORTMIRROR);
                                     int outPortNbr = 1;
-                                    if (state != null && state instanceof DecimalType) {
-                                        outPortNbr = ((DecimalType) state).intValue();
+                                    if (state instanceof DecimalType decimalCommand) {
+                                        outPortNbr = decimalCommand.intValue();
                                     }
                                     atlonaHandler.setPortMirror(hdmiPortNbr, outPortNbr);
                                 } else {
@@ -313,8 +313,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
 
                     switch (id) {
                         case AtlonaPro3Constants.CHANNEL_VOLUME_MUTE:
-                            if (command instanceof OnOffType) {
-                                atlonaHandler.setVolumeMute(portNbr, ((OnOffType) command) == OnOffType.ON);
+                            if (command instanceof OnOffType onOffCommand) {
+                                atlonaHandler.setVolumeMute(portNbr, onOffCommand == OnOffType.ON);
                             } else {
                                 logger.debug("Received a VOLUME MUTE channel command with a non OnOffType: {}",
                                         command);
@@ -322,8 +322,8 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
 
                             break;
                         case AtlonaPro3Constants.CHANNEL_VOLUME:
-                            if (command instanceof DecimalType) {
-                                final int level = ((DecimalType) command).intValue();
+                            if (command instanceof DecimalType decimalCommand) {
+                                final int level = decimalCommand.intValue();
                                 atlonaHandler.setVolume(portNbr, level);
                             } else {
                                 logger.debug("Received a VOLUME channel command with a non DecimalType: {}", command);
index c8182ed4519b272e3da4f0f5245b4366371b4e58..dda1a52b8a7bac03c7aa9c55d63e9e1876a5e7fc 100644 (file)
@@ -1253,10 +1253,10 @@ class AtlonaPro3PortocolHandler {
          */
         String getResponse() throws Exception {
             final Object lastResponse = responses.poll(5, TimeUnit.SECONDS);
-            if (lastResponse instanceof String) {
-                return (String) lastResponse;
-            } else if (lastResponse instanceof Exception) {
-                throw (Exception) lastResponse;
+            if (lastResponse instanceof String stringResponse) {
+                return stringResponse;
+            } else if (lastResponse instanceof Exception exceptionResponse) {
+                throw exceptionResponse;
             } else if (lastResponse == null) {
                 throw new Exception("Didn't receive response in time");
             } else {
index 624c3623df45d68f56476506b5bfa688c707d8b0..f05f46b8b352733fd35b24100c64635adb36c4be 100644 (file)
@@ -86,7 +86,7 @@ public class AutelisDiscoveryParticipant implements UpnpDiscoveryParticipant {
                     device.getDetails().getModelDetails().getModelNumber());
             if (device.getDetails().getManufacturerDetails().getManufacturer().toLowerCase().startsWith(MANUFACTURER)) {
                 logger.debug("Autelis Pool Control Found at {}", device.getDetails().getBaseURL());
-                String id = device.getIdentity().getUdn().getIdentifierString().replaceAll(":", "").toUpperCase();
+                String id = device.getIdentity().getUdn().getIdentifierString().replace(":", "").toUpperCase();
                 if (device.getDetails().getModelDetails().getModelNumber().toLowerCase().startsWith(MODEL_PENTAIR)) {
                     return new ThingUID(AutelisBindingConstants.PENTAIR_THING_TYPE_UID, id);
                 }
index 414c2847eda899bfe8b74e15120bfdfa1ce208ff..c964e473a8b349c8d11306f014230b6cb17699db 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.automower.internal.bridge;
 
 import static org.openhab.binding.automower.internal.AutomowerBindingConstants.THING_TYPE_BRIDGE;
 
-import java.util.Collections;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
@@ -49,7 +48,7 @@ public class AutomowerBridgeHandler extends BaseBridgeHandler {
 
     private static final String HUSQVARNA_API_TOKEN_URL = "https://api.authentication.husqvarnagroup.dev/v1/oauth2/token";
 
-    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 long DEFAULT_POLLING_INTERVAL_S = TimeUnit.HOURS.toSeconds(1);
 
     private final OAuthFactory oAuthFactory;
index 9842d29f337d1eae1ac036e4843f8659050b07da..4f3c13d13282a11273c7e94e7dc2effded0838f5 100644 (file)
@@ -14,10 +14,10 @@ package org.openhab.binding.automower.internal.discovery;
 
 import static org.openhab.binding.automower.internal.AutomowerBindingConstants.THING_TYPE_AUTOMOWER;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.automower.internal.AutomowerBindingConstants;
@@ -42,7 +42,7 @@ public class AutomowerDiscoveryService extends AbstractDiscoveryService {
     private final AutomowerBridgeHandler bridgeHandler;
 
     public AutomowerDiscoveryService(AutomowerBridgeHandler bridgeHandler) {
-        super(Collections.singleton(THING_TYPE_AUTOMOWER), 10, false);
+        super(Set.of(THING_TYPE_AUTOMOWER), 10, false);
         this.bridgeHandler = bridgeHandler;
     }
 
index e38c3273369b224b452ba970063430e333821ffa..2c8f32f2cf996f4505bfb0800961d22d5ef96d84 100644 (file)
@@ -18,7 +18,6 @@ import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -73,7 +72,7 @@ import com.google.gson.Gson;
  */
 @NonNullByDefault
 public class AutomowerHandler extends BaseThingHandler {
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_AUTOMOWER);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_AUTOMOWER);
     private static final String NO_ID = "NO_ID";
     private static final long DEFAULT_COMMAND_DURATION_MIN = 60;
     private static final long DEFAULT_POLLING_INTERVAL_S = TimeUnit.MINUTES.toSeconds(10);
@@ -120,8 +119,8 @@ public class AutomowerHandler extends BaseThingHandler {
     }
 
     private Optional<Integer> getCommandValue(Type type) {
-        if (type instanceof DecimalType) {
-            return Optional.of(((DecimalType) type).intValue());
+        if (type instanceof DecimalType command) {
+            return Optional.of(command.intValue());
         }
         return Optional.empty();
     }
@@ -132,7 +131,7 @@ public class AutomowerHandler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(AutomowerActions.class);
+        return Set.of(AutomowerActions.class);
     }
 
     @Override
@@ -163,8 +162,7 @@ public class AutomowerHandler extends BaseThingHandler {
         Bridge bridge = getBridge();
         if (bridge != null) {
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof AutomowerBridgeHandler) {
-                AutomowerBridgeHandler bridgeHandler = (AutomowerBridgeHandler) handler;
+            if (handler instanceof AutomowerBridgeHandler bridgeHandler) {
                 return bridgeHandler.getAutomowerBridge();
             }
         }
index f1b8020b854931229056722b5ebed1d4f3178eb8..9d62c5746522325666530d9179c5da12c2445777 100644 (file)
@@ -87,8 +87,8 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@NonNullByDefault({}) ThingHandler handler) {
-        if (handler instanceof AVMFritzBaseBridgeHandler) {
-            bridgeHandler = (AVMFritzBaseBridgeHandler) handler;
+        if (handler instanceof AVMFritzBaseBridgeHandler baseBridgeHandler) {
+            bridgeHandler = baseBridgeHandler;
         }
     }
 
@@ -128,9 +128,9 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
             properties.put(PRODUCT_NAME, device.getProductName());
             properties.put(PROPERTY_SERIAL_NUMBER, device.getIdentifier());
             properties.put(PROPERTY_FIRMWARE_VERSION, device.getFirmwareVersion());
-            if (device instanceof GroupModel && ((GroupModel) device).getGroupinfo() != null) {
-                properties.put(PROPERTY_MASTER, ((GroupModel) device).getGroupinfo().getMasterdeviceid());
-                properties.put(PROPERTY_MEMBERS, ((GroupModel) device).getGroupinfo().getMembers());
+            if (device instanceof GroupModel model && model.getGroupinfo() != null) {
+                properties.put(PROPERTY_MASTER, model.getGroupinfo().getMasterdeviceid());
+                properties.put(PROPERTY_MEMBERS, model.getGroupinfo().getMembers());
             }
 
             DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
index 82e27925a2b39e23406422634afa0887d605085c..56aaaef5739fdedfe53113ebda77cf17fe9cf135 100644 (file)
@@ -17,9 +17,9 @@ import static org.openhab.binding.avmfritz.internal.dto.DeviceModel.ETSUnitInfoM
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -172,21 +172,21 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof FritzAhaStatusListener) {
-            registerStatusListener((FritzAhaStatusListener) childHandler);
+        if (childHandler instanceof FritzAhaStatusListener listener) {
+            registerStatusListener(listener);
         }
     }
 
     @Override
     public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof FritzAhaStatusListener) {
-            unregisterStatusListener((FritzAhaStatusListener) childHandler);
+        if (childHandler instanceof FritzAhaStatusListener listener) {
+            unregisterStatusListener(listener);
         }
     }
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(AVMFritzDiscoveryService.class);
+        return Set.of(AVMFritzDiscoveryService.class);
     }
 
     public boolean registerStatusListener(FritzAhaStatusListener listener) {
@@ -327,7 +327,7 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
             } else if (device.isSwitchableOutlet()) {
                 return GROUP_SWITCH;
             }
-        } else if (device instanceof DeviceModel && device.isHANFUNUnit()) {
+        } else if (device instanceof DeviceModel deviceModel && device.isHANFUNUnit()) {
             if (device.isHANFUNBlinds()) {
                 return DEVICE_HAN_FUN_BLINDS;
             } else if (device.isColorLight()) {
@@ -335,8 +335,7 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
             } else if (device.isDimmableLight()) {
                 return DEVICE_HAN_FUN_DIMMABLE_BULB;
             }
-            List<String> interfaces = Arrays
-                    .asList(((DeviceModel) device).getEtsiunitinfo().getInterfaces().split(","));
+            List<String> interfaces = Arrays.asList(deviceModel.getEtsiunitinfo().getInterfaces().split(","));
             if (interfaces.contains(HAN_FUN_INTERFACE_ALERT)) {
                 return DEVICE_HAN_FUN_CONTACT;
             } else if (interfaces.contains(HAN_FUN_INTERFACE_SIMPLE_BUTTON)) {
index 81baa1da726e53abd74ba38f15a0d12bc8b61c97..38666b54d8caf2ccfd24c33ab54b4efb4244e6f2 100644 (file)
@@ -187,8 +187,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
             if (device.isHeatingThermostat()) {
                 updateHeatingThermostat(device.getHkr());
             }
-            if (device instanceof DeviceModel) {
-                DeviceModel deviceModel = (DeviceModel) device;
+            if (device instanceof DeviceModel deviceModel) {
                 if (deviceModel.isTemperatureSensor()) {
                     updateTemperatureSensor(deviceModel.getTemperature());
                 }
@@ -497,13 +496,12 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
             case CHANNEL_COLOR:
             case CHANNEL_BRIGHTNESS:
                 BigDecimal brightness = null;
-                if (command instanceof HSBType) {
-                    HSBType hsbType = (HSBType) command;
-                    brightness = hsbType.getBrightness().toBigDecimal();
-                    fritzBox.setUnmappedHueAndSaturation(ain, hsbType.getHue().intValue(),
-                            ColorControlModel.fromPercent(hsbType.getSaturation()), 0);
-                } else if (command instanceof PercentType) {
-                    brightness = ((PercentType) command).toBigDecimal();
+                if (command instanceof HSBType hsbCommand) {
+                    brightness = hsbCommand.getBrightness().toBigDecimal();
+                    fritzBox.setUnmappedHueAndSaturation(ain, hsbCommand.getHue().intValue(),
+                            ColorControlModel.fromPercent(hsbCommand.getSaturation()), 0);
+                } else if (command instanceof PercentType brightnessPercent) {
+                    brightness = brightnessPercent.toBigDecimal();
                 } else if (command instanceof OnOffType) {
                     fritzBox.setSwitch(ain, OnOffType.ON.equals(command));
                 } else if (command instanceof IncreaseDecreaseType) {
@@ -525,8 +523,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                 break;
             case CHANNEL_COLORTEMPERATURE:
                 BigDecimal colorTemperaturePct = null;
-                if (command instanceof PercentType) {
-                    colorTemperaturePct = ((PercentType) command).toBigDecimal();
+                if (command instanceof PercentType percentCommand) {
+                    colorTemperaturePct = percentCommand.toBigDecimal();
                 }
                 if (colorTemperaturePct != null) {
                     int pct = colorTemperaturePct.intValue();
@@ -540,13 +538,13 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                 break;
             case CHANNEL_COLORTEMPERATURE_ABS:
                 BigDecimal colorTemperature = null;
-                if (command instanceof QuantityType) {
-                    QuantityType<?> convertedCommand = ((QuantityType<?>) command).toInvertibleUnit(Units.KELVIN);
+                if (command instanceof QuantityType quantityCommand) {
+                    QuantityType<?> convertedCommand = quantityCommand.toInvertibleUnit(Units.KELVIN);
                     if (convertedCommand != null) {
                         colorTemperature = convertedCommand.toBigDecimal();
                     }
-                } else if (command instanceof DecimalType) {
-                    colorTemperature = ((DecimalType) command).toBigDecimal();
+                } else if (command instanceof DecimalType decimalCommand) {
+                    colorTemperature = decimalCommand.toBigDecimal();
                 }
                 if (colorTemperature != null) {
                     fritzBox.setColorTemperature(ain, colorTemperature.intValue(), 0);
@@ -554,9 +552,9 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                 break;
             case CHANNEL_SETTEMP:
                 BigDecimal temperature = null;
-                if (command instanceof DecimalType) {
-                    temperature = normalizeCelsius(((DecimalType) command).toBigDecimal());
-                } else if (command instanceof QuantityType) {
+                if (command instanceof DecimalType decimalCommand) {
+                    temperature = normalizeCelsius(decimalCommand.toBigDecimal());
+                } else if (command instanceof QuantityType quantityCommand) {
                     @SuppressWarnings("unchecked")
                     QuantityType<Temperature> convertedCommand = ((QuantityType<Temperature>) command)
                             .toUnit(SIUnits.CELSIUS);
@@ -564,7 +562,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                         temperature = normalizeCelsius(convertedCommand.toBigDecimal());
                     } else {
                         logger.warn("Unable to convert unit from '{}' to '{}'. Skipping command.",
-                                ((QuantityType<?>) command).getUnit(), SIUnits.CELSIUS);
+                                quantityCommand.getUnit(), SIUnits.CELSIUS);
                     }
                 } else if (command instanceof IncreaseDecreaseType) {
                     temperature = currentDevice.getHkr().getTsoll();
@@ -615,22 +613,20 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                 }
                 break;
             case CHANNEL_ROLLERSHUTTER:
-                if (command instanceof StopMoveType) {
-                    StopMoveType rollershutterCommand = (StopMoveType) command;
+                if (command instanceof StopMoveType rollershutterCommand) {
                     if (StopMoveType.STOP.equals(rollershutterCommand)) {
                         fritzBox.setBlind(ain, BlindCommand.STOP);
                     } else {
                         logger.debug("Received unknown rollershutter StopMove command MOVE");
                     }
-                } else if (command instanceof UpDownType) {
-                    UpDownType rollershutterCommand = (UpDownType) command;
+                } else if (command instanceof UpDownType rollershutterCommand) {
                     if (UpDownType.UP.equals(rollershutterCommand)) {
                         fritzBox.setBlind(ain, BlindCommand.OPEN);
                     } else {
                         fritzBox.setBlind(ain, BlindCommand.CLOSE);
                     }
-                } else if (command instanceof PercentType) {
-                    BigDecimal levelPercentage = ((PercentType) command).toBigDecimal();
+                } else if (command instanceof PercentType percentCommand) {
+                    BigDecimal levelPercentage = percentCommand.toBigDecimal();
                     fritzBox.setLevelPercentage(ain, levelPercentage);
                 } else {
                     logger.debug("Received unknown rollershutter command type '{}'", command.toString());
@@ -686,8 +682,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
         Bridge bridge = getBridge();
         if (bridge != null) {
             BridgeHandler handler = bridge.getHandler();
-            if (handler instanceof AVMFritzBaseBridgeHandler) {
-                return ((AVMFritzBaseBridgeHandler) handler).getWebInterface();
+            if (handler instanceof AVMFritzBaseBridgeHandler bridgeHandler) {
+                return bridgeHandler.getWebInterface();
             }
         }
         return null;
@@ -700,8 +696,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
         Bridge bridge = getBridge();
         if (bridge != null) {
             BridgeHandler handler = bridge.getHandler();
-            if (handler instanceof AVMFritzBaseBridgeHandler) {
-                ((AVMFritzBaseBridgeHandler) handler).handleRefreshCommand();
+            if (handler instanceof AVMFritzBaseBridgeHandler bridgeHandler) {
+                bridgeHandler.handleRefreshCommand();
             }
         }
     }
index 678411b525aaa51739ac0e7740a7919a8a82f73b..1b2d5f6f31e7256c39193a248e5a958a075e323f 100644 (file)
@@ -78,8 +78,7 @@ public class AVMFritzButtonHandler extends DeviceHandler {
         if (thing.getUID().equals(thingUID)) {
             super.onDeviceUpdated(thingUID, device);
 
-            if (device instanceof DeviceModel) {
-                DeviceModel deviceModel = (DeviceModel) device;
+            if (device instanceof DeviceModel deviceModel) {
                 if (deviceModel.isHANFUNButton()) {
                     updateHANFUNButton(deviceModel.getButtons());
                 }
index 62715d834f24c94cc2c254f7bfbf33d002c18b2c..9a9ac2af05c0626287c609cf8b603db8f331af03 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.avmfritz.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.avmfritz.internal.actions.AVMFritzHeatingActions;
@@ -30,7 +30,7 @@ public interface AVMFritzHeatingActionsHandler extends ThingHandler {
 
     @Override
     default Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(AVMFritzHeatingActions.class);
+        return Set.of(AVMFritzHeatingActions.class);
     }
 
     /**
index bbb77dd6a72b8ec27125e7119e7d84c5829984e5..84abfe35ab40fe601d34c8305acc9e8f748bcb1e 100644 (file)
@@ -35,8 +35,7 @@ public class GroupHandler extends AVMFritzBaseThingHandler {
 
     @Override
     protected void updateProperties(AVMFritzBaseModel device, Map<String, String> editProperties) {
-        if (device instanceof GroupModel) {
-            GroupModel groupModel = (GroupModel) device;
+        if (device instanceof GroupModel groupModel) {
             if (groupModel.getGroupinfo() != null) {
                 editProperties.put(PROPERTY_MASTER, groupModel.getGroupinfo().getMasterdeviceid());
                 editProperties.put(PROPERTY_MEMBERS, groupModel.getGroupinfo().getMembers());
index 1ab4db6a2e79d319146806c70d906a858ff920af..254be38b9223afb2a4d4f0002c8cc3a4b1bc00d0 100644 (file)
@@ -45,72 +45,74 @@ public class AVMFritzDeviceListModelTest {
     public void setUp() throws JAXBException, XMLStreamException {
         //@formatter:off
         final String xml =
-                "<devicelist version=\"1\">"
-                    + "<group identifier=\"F0:A3:7F-900\" id=\"20000\" functionbitmask=\"6784\" fwversion=\"1.0\" manufacturer=\"AVM\" productname=\"\"><present>1</present><name>Schlafzimmer</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><groupinfo><masterdeviceid>17</masterdeviceid><members>17,18</members></groupinfo></group>"
-                    + "<group identifier=\"F0:A3:7F-901\" id=\"20001\" functionbitmask=\"4160\" fwversion=\"1.0\" manufacturer=\"AVM\" productname=\"\"><present>1</present><name>Schlafzimmer</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr><groupinfo><masterdeviceid>0</masterdeviceid><members>20,21,22</members></groupinfo></group>"
-                    + "<device identifier=\"08761 0000434\" id=\"17\" functionbitmask=\"35712\" fwversion=\"03.83\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 200\"><present>1</present><name>FRITZ!DECT 200 #1</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>"
-                    + "<device identifier=\"08761 0000438\" id=\"18\" functionbitmask=\"35712\" fwversion=\"03.83\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 210\"><present>1</present><name>FRITZ!DECT 210 #8</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>"
-                    + "<device identifier=\"08761 0000437\" id=\"20\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 300\"><present>0</present><name>FRITZ!DECT 300 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
-                    + "<device identifier=\"08761 0000436\" id=\"21\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 301\"><present>0</present><name>FRITZ!DECT 301 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
-                    + "<device identifier=\"08761 0000435\" id=\"22\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"Comet DECT\"><present>0</present><name>Comet DECT #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
-                    + "<device identifier=\"5C:49:79:F0:A3:84\" id=\"30\" functionbitmask=\"640\" fwversion=\"06.92\" manufacturer=\"AVM\" productname=\"FRITZ!Powerline 546E\"><present>1</present><name>FRITZ!Powerline 546E #1</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>1</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter></device>"
-                    + "<device identifier=\"08761 0000439\" id=\"40\" functionbitmask=\"1280\" fwversion=\"03.86\" manufacturer=\"AVM\" productname=\"FRITZ!DECT Repeater 100\"><present>1</present><name>FRITZ!DECT Repeater 100 #5</name><temperature><celsius>230</celsius><offset>0</offset></temperature></device>"
-                    + "<device identifier=\"11934 0059978-1\" id=\"2000\" functionbitmask=\"8208\" fwversion=\"0.0\" manufacturer=\"0x0feb\" productname=\"HAN-FUN\"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>514</unittype><interfaces>256</interfaces></etsiunitinfo><alert><state>1</state></alert></device>"
-                    + "<device identifier=\"11934 0059979-1\" id=\"2001\" functionbitmask=\"8200\" fwversion=\"0.0\" manufacturer=\"0x0feb\" productname=\"HAN-FUN\"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>412</etsideviceid><unittype>273</unittype><interfaces>772</interfaces></etsiunitinfo><button><lastpressedtimestamp>1529590797</lastpressedtimestamp></button></device>"
-                    + "<device identifier=\"13096 0007307\" id=\"29\" functionbitmask=\"32\" fwversion=\"04.90\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 400\"><present>1</present><name>FRITZ!DECT 400 #14</name><battery>100</battery><batterylow>0</batterylow><button identifier=\"13096 0007307-0\" id=\"5000\"><name>FRITZ!DECT 400 #14: kurz</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007307-9\" id=\"5001\"><name>FRITZ!DECT 400 #14: lang</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>"
-                    + "<device identifier=\"13096 0007308\" id=\"30\" functionbitmask=\"1048864\" fwversion=\"05.10\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 440\"><present>1</present><name>FRITZ!DECT 440 #15</name><temperature><celsius>230</celsius><offset>0</offset></temperature><humidity><rel_humidity>43</rel_humidity></humidity><battery>100</battery><batterylow>0</batterylow><button identifier=\"13096 0007308-1\" id=\"5000\"><name>FRITZ!DECT 440 #15: Oben rechts</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007308-3\" id=\"5001\"><name>FRITZ!DECT 440 #15: Unten rechts</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button><button identifier=\"13096 0007308-5\" id=\"5002\"><name>FRITZ!DECT 440 #15: Unten links</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007308-7\" id=\"5003\"><name>FRITZ!DECT 440 #15: Oben links</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>"
-                    + "<device identifier=\"14276 0503450-1\" id=\"2000\" functionbitmask=\"335888\" fwversion=\"0.0\" manufacturer=\"0x37c4\" productname=\"Rollotron 1213\"><present>1</present><txbusy>0</txbusy><name>Rollotron 1213 #1</name><blind><endpositionsset>1</endpositionsset><mode>manuell</mode></blind><levelcontrol><level>26</level><levelpercentage>10</levelpercentage></levelcontrol><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>281</unittype><interfaces>256,513,516,517</interfaces></etsiunitinfo><alert><state>0</state><lastalertchgtimestamp></lastalertchgtimestamp></alert></device>"
-                    + "<device identifier=\"11324 0824499-1\" id=\"2002\" functionbitmask=\"40960\" fwversion=\"0.0\" manufacturer=\"0x2c3c\" productname=\"HAN-FUN\">\n"
-                    + "    <present>1</present>\n"
-                    + "    <txbusy>0</txbusy>\n"
-                    + "    <name>Steckdose innen</name>\n"
-                    + "    <simpleonoff>\n"
-                    + "        <state>0</state>\n"
-                    + "    </simpleonoff>\n"
-                    + "    <etsiunitinfo>\n"
-                    + "        <etsideviceid>408</etsideviceid>\n"
-                    + "        <unittype>263</unittype>\n"
-                    + "        <interfaces>512,768</interfaces>\n"
-                    + "    </etsiunitinfo>\n"
-                    + "</device>"
-                    + "<device identifier=\"11324 0584796-1\" id=\"2001\" functionbitmask=\"40960\" fwversion=\"0.0\" manufacturer=\"0x2c3c\" productname=\"HAN-FUN\">\n"
-                    + "    <present>1</present>\n"
-                    + "    <txbusy>0</txbusy>\n"
-                    + "    <name>Steckdose außen</name>\n"
-                    + "    <simpleonoff>\n"
-                    + "        <state>0</state>\n"
-                    + "    </simpleonoff>\n"
-                    + "    <etsiunitinfo>\n"
-                    + "        <etsideviceid>407</etsideviceid>\n"
-                    + "        <unittype>262</unittype>\n"
-                    + "        <interfaces>512</interfaces>\n"
-                    + "    </etsiunitinfo>\n"
-                    + "</device>"
-                    + "<device identifier=\"12701 0027533-1\" id=\"2002\" functionbitmask=\"237572\" fwversion=\"0.0\" manufacturer=\"0x319d\" productname=\"HAN-FUN\">\n"
-                    + "    <present>0</present>\n"
-                    + "    <txbusy>0</txbusy>\n"
-                    + "    <name>SmartHome LED-Lampe #1</name>\n"
-                    + "    <simpleonoff>\n"
-                    + "        <state>0</state>\n"
-                    + "    </simpleonoff>\n"
-                    + "    <levelcontrol>\n"
-                    + "       <level>26</level>\n"
-                    + "       <levelpercentage>10</levelpercentage>\n"
-                    + "    </levelcontrol>\n"
-                    + "    <colorcontrol supported_modes=\"0\" current_mode=\"\" fullcolorsupport=\"0\" mapped=\"0\">\n"
-                    + "        <hue>254</hue>\n"
-                    + "        <saturation>100</saturation>\n"
-                    + "        <unmapped_hue></unmapped_hue>\n"
-                    + "        <unmapped_saturation></unmapped_saturation>\n"
-                    + "        <temperature>2700</temperature>\n"
-                    + "    </colorcontrol>\n"
-                    + "    <etsiunitinfo>\n"
-                    + "        <etsideviceid>407</etsideviceid>\n"
-                    + "        <unittype>278</unittype>\n"
-                    + "        <interfaces>512,514,513</interfaces>\n"
-                    + "    </etsiunitinfo>\n"
-                    + "</device>" +
-                "</devicelist>";
+                """
+                <devicelist version="1">\
+                <group identifier="F0:A3:7F-900" id="20000" functionbitmask="6784" fwversion="1.0" manufacturer="AVM" productname=""><present>1</present><name>Schlafzimmer</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><groupinfo><masterdeviceid>17</masterdeviceid><members>17,18</members></groupinfo></group>\
+                <group identifier="F0:A3:7F-901" id="20001" functionbitmask="4160" fwversion="1.0" manufacturer="AVM" productname=""><present>1</present><name>Schlafzimmer</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr><groupinfo><masterdeviceid>0</masterdeviceid><members>20,21,22</members></groupinfo></group>\
+                <device identifier="08761 0000434" id="17" functionbitmask="35712" fwversion="03.83" manufacturer="AVM" productname="FRITZ!DECT 200"><present>1</present><name>FRITZ!DECT 200 #1</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>\
+                <device identifier="08761 0000438" id="18" functionbitmask="35712" fwversion="03.83" manufacturer="AVM" productname="FRITZ!DECT 210"><present>1</present><name>FRITZ!DECT 210 #8</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>\
+                <device identifier="08761 0000437" id="20" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="FRITZ!DECT 300"><present>0</present><name>FRITZ!DECT 300 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
+                <device identifier="08761 0000436" id="21" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="FRITZ!DECT 301"><present>0</present><name>FRITZ!DECT 301 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
+                <device identifier="08761 0000435" id="22" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="Comet DECT"><present>0</present><name>Comet DECT #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
+                <device identifier="5C:49:79:F0:A3:84" id="30" functionbitmask="640" fwversion="06.92" manufacturer="AVM" productname="FRITZ!Powerline 546E"><present>1</present><name>FRITZ!Powerline 546E #1</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>1</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter></device>\
+                <device identifier="08761 0000439" id="40" functionbitmask="1280" fwversion="03.86" manufacturer="AVM" productname="FRITZ!DECT Repeater 100"><present>1</present><name>FRITZ!DECT Repeater 100 #5</name><temperature><celsius>230</celsius><offset>0</offset></temperature></device>\
+                <device identifier="11934 0059978-1" id="2000" functionbitmask="8208" fwversion="0.0" manufacturer="0x0feb" productname="HAN-FUN"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>514</unittype><interfaces>256</interfaces></etsiunitinfo><alert><state>1</state></alert></device>\
+                <device identifier="11934 0059979-1" id="2001" functionbitmask="8200" fwversion="0.0" manufacturer="0x0feb" productname="HAN-FUN"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>412</etsideviceid><unittype>273</unittype><interfaces>772</interfaces></etsiunitinfo><button><lastpressedtimestamp>1529590797</lastpressedtimestamp></button></device>\
+                <device identifier="13096 0007307" id="29" functionbitmask="32" fwversion="04.90" manufacturer="AVM" productname="FRITZ!DECT 400"><present>1</present><name>FRITZ!DECT 400 #14</name><battery>100</battery><batterylow>0</batterylow><button identifier="13096 0007307-0" id="5000"><name>FRITZ!DECT 400 #14: kurz</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007307-9" id="5001"><name>FRITZ!DECT 400 #14: lang</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>\
+                <device identifier="13096 0007308" id="30" functionbitmask="1048864" fwversion="05.10" manufacturer="AVM" productname="FRITZ!DECT 440"><present>1</present><name>FRITZ!DECT 440 #15</name><temperature><celsius>230</celsius><offset>0</offset></temperature><humidity><rel_humidity>43</rel_humidity></humidity><battery>100</battery><batterylow>0</batterylow><button identifier="13096 0007308-1" id="5000"><name>FRITZ!DECT 440 #15: Oben rechts</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007308-3" id="5001"><name>FRITZ!DECT 440 #15: Unten rechts</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button><button identifier="13096 0007308-5" id="5002"><name>FRITZ!DECT 440 #15: Unten links</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007308-7" id="5003"><name>FRITZ!DECT 440 #15: Oben links</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>\
+                <device identifier="14276 0503450-1" id="2000" functionbitmask="335888" fwversion="0.0" manufacturer="0x37c4" productname="Rollotron 1213"><present>1</present><txbusy>0</txbusy><name>Rollotron 1213 #1</name><blind><endpositionsset>1</endpositionsset><mode>manuell</mode></blind><levelcontrol><level>26</level><levelpercentage>10</levelpercentage></levelcontrol><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>281</unittype><interfaces>256,513,516,517</interfaces></etsiunitinfo><alert><state>0</state><lastalertchgtimestamp></lastalertchgtimestamp></alert></device>\
+                <device identifier="11324 0824499-1" id="2002" functionbitmask="40960" fwversion="0.0" manufacturer="0x2c3c" productname="HAN-FUN">
+                    <present>1</present>
+                    <txbusy>0</txbusy>
+                    <name>Steckdose innen</name>
+                    <simpleonoff>
+                        <state>0</state>
+                    </simpleonoff>
+                    <etsiunitinfo>
+                        <etsideviceid>408</etsideviceid>
+                        <unittype>263</unittype>
+                        <interfaces>512,768</interfaces>
+                    </etsiunitinfo>
+                </device>\
+                <device identifier="11324 0584796-1" id="2001" functionbitmask="40960" fwversion="0.0" manufacturer="0x2c3c" productname="HAN-FUN">
+                    <present>1</present>
+                    <txbusy>0</txbusy>
+                    <name>Steckdose außen</name>
+                    <simpleonoff>
+                        <state>0</state>
+                    </simpleonoff>
+                    <etsiunitinfo>
+                        <etsideviceid>407</etsideviceid>
+                        <unittype>262</unittype>
+                        <interfaces>512</interfaces>
+                    </etsiunitinfo>
+                </device>\
+                <device identifier="12701 0027533-1" id="2002" functionbitmask="237572" fwversion="0.0" manufacturer="0x319d" productname="HAN-FUN">
+                    <present>0</present>
+                    <txbusy>0</txbusy>
+                    <name>SmartHome LED-Lampe #1</name>
+                    <simpleonoff>
+                        <state>0</state>
+                    </simpleonoff>
+                    <levelcontrol>
+                       <level>26</level>
+                       <levelpercentage>10</levelpercentage>
+                    </levelcontrol>
+                    <colorcontrol supported_modes="0" current_mode="" fullcolorsupport="0" mapped="0">
+                        <hue>254</hue>
+                        <saturation>100</saturation>
+                        <unmapped_hue></unmapped_hue>
+                        <unmapped_saturation></unmapped_saturation>
+                        <temperature>2700</temperature>
+                    </colorcontrol>
+                    <etsiunitinfo>
+                        <etsideviceid>407</etsideviceid>
+                        <unittype>278</unittype>
+                        <interfaces>512,514,513</interfaces>
+                    </etsiunitinfo>
+                </device>\
+                </devicelist>\
+                """;
         //@formatter:on
         XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
         Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();
index a8d0252e3b4a6d9af9ad21d4ed25a2fa1f0cd759..d6d23363c6b2db1d3f4ab5f3a211295411af2409 100644 (file)
@@ -44,10 +44,12 @@ public class AVMFritzTemplateListModelTest {
     public void setUp() throws JAXBException, XMLStreamException {
         //@formatter:off
         String xml =
-                "<templatelist version=\"1\">" +
-                    "<template identifier=\"tmpXXXXX-39DC738C5\" id=\"30103\" functionbitmask=\"6784\" applymask=\"64\"><name>Test template #1</name><devices><device identifier=\"YY:5D:AA-900\" /><device identifier=\"XX:5D:AA-900\" /></devices><applymask><relay_automatic /></applymask></template>" +
-                    "<template identifier=\"tmpXXXXX-39722FC0F\" id=\"30003\" functionbitmask=\"6784\" applymask=\"64\"><name>Test template #2</name><devices><device identifier=\"YY:5D:AA-900\" /></devices><applymask><relay_automatic /></applymask></template>" +
-                "</templatelist>";
+                """
+                <templatelist version="1">\
+                <template identifier="tmpXXXXX-39DC738C5" id="30103" functionbitmask="6784" applymask="64"><name>Test template #1</name><devices><device identifier="YY:5D:AA-900" /><device identifier="XX:5D:AA-900" /></devices><applymask><relay_automatic /></applymask></template>\
+                <template identifier="tmpXXXXX-39722FC0F" id="30003" functionbitmask="6784" applymask="64"><name>Test template #2</name><devices><device identifier="YY:5D:AA-900" /></devices><applymask><relay_automatic /></applymask></template>\
+                </templatelist>\
+                """;
         //@formatter:on
         XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
         Unmarshaller u = JAXBUtils.JAXBCONTEXT_TEMPLATES.createUnmarshaller();
index 083919b9227d0fdd9b72a159c9a4d91314e0f2b2..ebc3937cb007e6b95d4ecbc4e6e8121532615c05 100644 (file)
@@ -27,6 +27,7 @@ public class AwattarBestpriceConfiguration {
     public int length;
     public boolean consecutive;
 
+    @Override
     public String toString() {
         return String.format("{ s: %d, d: %d, l: %d, c: %b )", rangeStart, rangeDuration, length, consecutive);
     }
index 65a4c706d9e4080ab63b016cb3514a5fedd3982a..49cb3eb28e5c9846ccf319e4faae47af76e6ea61 100644 (file)
@@ -66,11 +66,13 @@ public class AwattarConsecutiveBestPriceResult extends AwattarBestPriceResult {
         return priceSum;
     }
 
+    @Override
     public String toString() {
         return String.format("{%s, %s, %.2f}", formatDate(getStart(), zoneId), formatDate(getEnd(), zoneId),
                 priceSum / length);
     }
 
+    @Override
     public String getHours() {
         return hours;
     }
index 7db7fddd114d37f49a67bf20f6d915b5d0a23755..ecffe143139cdfcace334902ef47b7d382b6eb92 100644 (file)
@@ -52,6 +52,7 @@ public class AwattarNonConsecutiveBestPriceResult extends AwattarBestPriceResult
         return members.stream().anyMatch(x -> x.contains(Instant.now().toEpochMilli()));
     }
 
+    @Override
     public String toString() {
         return String.format("NonConsecutiveBestpriceResult with %s", members.toString());
     }
@@ -67,6 +68,7 @@ public class AwattarNonConsecutiveBestPriceResult extends AwattarBestPriceResult
         }
     }
 
+    @Override
     public String getHours() {
         boolean second = false;
         sort();
index 9d3609a04e8c47582bea639b007698d5883fa83e..635d1cac14e869ba604e8a72af0717bd4e0e05f1 100644 (file)
@@ -50,6 +50,7 @@ public class AwattarPrice implements Comparable<AwattarPrice> {
         return price;
     }
 
+    @Override
     public String toString() {
         return String.format("(%1$tF %1$tR - %2$tR: %3$.3f)", startTimestamp, endTimestamp, getPrice());
     }
index b1b09ed6ba82ab980dbf5a654268d7d0f940c1f1..4ba5bf1ad8171a81d0e5e7b2b45fccc1492f26d2 100644 (file)
@@ -40,9 +40,7 @@ public class AwattarUtil {
         int offset = min % mod;
         offset = offset == 0 ? mod : offset;
         dt = dt.plusMinutes(offset);
-        long result = dt.toInstant().toEpochMilli() - now;
-
-        return result;
+        return dt.toInstant().toEpochMilli() - now;
     }
 
     public static ZonedDateTime getCalendarForHour(int hour, ZoneId zone) {
index 92d1f9e0aaffafb0b2c01cde9daef7c22bb52454..81d22bf28dc0b2e550aa24522690c8be98104a83 100644 (file)
@@ -97,6 +97,7 @@ public class AwattarPriceHandler extends BaseThingHandler {
         updateStatus(ThingStatus.UNKNOWN);
     }
 
+    @Override
     public void dispose() {
         ScheduledFuture<?> localRefresher = thingRefresher;
         if (localRefresher != null) {
index 1430b34109897f6e24401bfad4852762176f3b53..3b6dc9e1974b11bef12c3fb8f389f50aacc278a6 100644 (file)
@@ -187,8 +187,8 @@ public class BigAssFanHandler extends BaseThingHandler {
         logger.debug("Handling fan speed command for {}: {}", thing.getUID(), command);
 
         // <mac;FAN;SPD;SET;0..7>
-        if (command instanceof PercentType) {
-            sendCommand(macAddress, ";FAN;SPD;SET;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
+        if (command instanceof PercentType percentCommand) {
+            sendCommand(macAddress, ";FAN;SPD;SET;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
         }
     }
 
@@ -238,52 +238,48 @@ public class BigAssFanHandler extends BaseThingHandler {
     private void handleFanLearnSpeedMin(Command command) {
         logger.debug("Handling fan learn speed minimum command {}", command);
         // <mac;FAN;SPD;SET;MIN;0..7>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send min speed set command
-            sendCommand(macAddress,
-                    ";LEARN;MINSPEED;SET;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
-            fanStateMap.put(CHANNEL_FAN_LEARN_MINSPEED, (PercentType) command);
+            sendCommand(macAddress, ";LEARN;MINSPEED;SET;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
+            fanStateMap.put(CHANNEL_FAN_LEARN_MINSPEED, percentCommand);
             // Don't let max be less than min
-            adjustMaxSpeed((PercentType) command, CHANNEL_FAN_LEARN_MAXSPEED, ";LEARN;MAXSPEED;");
+            adjustMaxSpeed(percentCommand, CHANNEL_FAN_LEARN_MAXSPEED, ";LEARN;MAXSPEED;");
         }
     }
 
     private void handleFanLearnSpeedMax(Command command) {
         logger.debug("Handling fan learn speed maximum command {}", command);
         // <mac;FAN;SPD;SET;MAX;0..7>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send max speed set command
-            sendCommand(macAddress,
-                    ";LEARN;MAXSPEED;SET;;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
-            fanStateMap.put(CHANNEL_FAN_LEARN_MAXSPEED, (PercentType) command);
+            sendCommand(macAddress, ";LEARN;MAXSPEED;SET;;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
+            fanStateMap.put(CHANNEL_FAN_LEARN_MAXSPEED, percentCommand);
             // Don't let min be greater than max
-            adjustMinSpeed((PercentType) command, CHANNEL_FAN_LEARN_MINSPEED, ";LEARN;MINSPEED;");
+            adjustMinSpeed(percentCommand, CHANNEL_FAN_LEARN_MINSPEED, ";LEARN;MINSPEED;");
         }
     }
 
     private void handleFanSpeedMin(Command command) {
         logger.debug("Handling fan speed minimum command {}", command);
         // <mac;FAN;SPD;SET;MIN;0..7>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send min speed set command
-            sendCommand(macAddress,
-                    ";FAN;SPD;SET;MIN;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
-            fanStateMap.put(CHANNEL_FAN_SPEED_MIN, (PercentType) command);
+            sendCommand(macAddress, ";FAN;SPD;SET;MIN;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
+            fanStateMap.put(CHANNEL_FAN_SPEED_MIN, percentCommand);
             // Don't let max be less than min
-            adjustMaxSpeed((PercentType) command, CHANNEL_FAN_SPEED_MAX, ";FAN;SPD;SET;MAX;");
+            adjustMaxSpeed(percentCommand, CHANNEL_FAN_SPEED_MAX, ";FAN;SPD;SET;MAX;");
         }
     }
 
     private void handleFanSpeedMax(Command command) {
         logger.debug("Handling fan speed maximum command {}", command);
         // <mac;FAN;SPD;SET;MAX;0..7>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send max speed set command
-            sendCommand(macAddress,
-                    ";FAN;SPD;SET;MAX;".concat(BigAssFanConverter.percentToSpeed((PercentType) command)));
-            fanStateMap.put(CHANNEL_FAN_SPEED_MAX, (PercentType) command);
+            sendCommand(macAddress, ";FAN;SPD;SET;MAX;".concat(BigAssFanConverter.percentToSpeed(percentCommand)));
+            fanStateMap.put(CHANNEL_FAN_SPEED_MAX, percentCommand);
             // Don't let min be greater than max
-            adjustMinSpeed((PercentType) command, CHANNEL_FAN_SPEED_MIN, ";FAN;SPD;SET;MIN;");
+            adjustMinSpeed(percentCommand, CHANNEL_FAN_SPEED_MIN, ";FAN;SPD;SET;MIN;");
         }
     }
 
@@ -364,9 +360,8 @@ public class BigAssFanHandler extends BaseThingHandler {
 
         logger.debug("Handling light level command {}", command);
         // <mac;LIGHT;LEVEL;SET;0..16>
-        if (command instanceof PercentType) {
-            sendCommand(macAddress,
-                    ";LIGHT;LEVEL;SET;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
+        if (command instanceof PercentType percentCommand) {
+            sendCommand(macAddress, ";LIGHT;LEVEL;SET;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
         }
     }
 
@@ -378,9 +373,9 @@ public class BigAssFanHandler extends BaseThingHandler {
 
         logger.debug("Handling light hue command {}", command);
         // <mac;LIGHT;COLOR;TEMP;SET;2200..5000>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             sendCommand(macAddress,
-                    ";LIGHT;COLOR;TEMP;VALUE;SET;".concat(BigAssFanConverter.percentToHue((PercentType) command)));
+                    ";LIGHT;COLOR;TEMP;VALUE;SET;".concat(BigAssFanConverter.percentToHue(percentCommand)));
         }
     }
 
@@ -426,12 +421,11 @@ public class BigAssFanHandler extends BaseThingHandler {
 
         logger.debug("Handling light level minimum command {}", command);
         // <mac;LIGHT;LEVEL;MIN;0-16>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send min light level set command
-            sendCommand(macAddress,
-                    ";LIGHT;LEVEL;MIN;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
+            sendCommand(macAddress, ";LIGHT;LEVEL;MIN;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
             // Don't let max be less than min
-            adjustMaxLevel((PercentType) command);
+            adjustMaxLevel(percentCommand);
         }
     }
 
@@ -443,12 +437,11 @@ public class BigAssFanHandler extends BaseThingHandler {
 
         logger.debug("Handling light level maximum command {}", command);
         // <mac;LIGHT;LEVEL;MAX;0-16>
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             // Send max light level set command
-            sendCommand(macAddress,
-                    ";LIGHT;LEVEL;MAX;".concat(BigAssFanConverter.percentToLevel((PercentType) command)));
+            sendCommand(macAddress, ";LIGHT;LEVEL;MAX;".concat(BigAssFanConverter.percentToLevel(percentCommand)));
             // Don't let min be greater than max
-            adjustMinLevel((PercentType) command);
+            adjustMinLevel(percentCommand);
         }
     }
 
index bbedbc8669c1c5ac8546ef6fa5dd791437f4ca23..450bd788599359b270d484fe21028594e09b60b7 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.am43.internal;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -42,7 +41,7 @@ public class AM43DiscoveryParticipant implements BluetoothDiscoveryParticipant {
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(AM43BindingConstants.THING_TYPE_AM43);
+        return Set.of(AM43BindingConstants.THING_TYPE_AM43);
     }
 
     @Override
index 1bdcc7db64a3baf2f5b75a516979f0094d424676..c6bf4f42e0ecb979fee0a044e6b1e3e612bd59ec 100644 (file)
@@ -235,27 +235,28 @@ public class AM43Handler extends ConnectedBluetoothHandler implements ResponseLi
         }
         switch (channelUID.getId()) {
             case AM43BindingConstants.CHANNEL_ID_POSITION:
-                if (command instanceof PercentType) {
+                if (command instanceof PercentType percentCommand) {
                     MotorSettings settings = motorSettings;
                     if (settings == null) {
                         logger.warn("Cannot set position before settings have been received.");
                         return;
                     }
                     if (!settings.isTopLimitSet() || !settings.isBottomLimitSet()) {
-                        logger.warn("Cannot set position of blinds. Top or bottom limits have not been set. "
-                                + "Please configure manually.");
+                        logger.warn("""
+                                Cannot set position of blinds. Top or bottom limits have not been set. \
+                                Please configure manually.\
+                                """);
                         return;
                     }
-                    PercentType percent = (PercentType) command;
-                    int value = percent.intValue();
+                    int value = percentCommand.intValue();
                     if (getAM43Config().invertPosition) {
                         value = 100 - value;
                     }
                     submitCommand(new SetPositionCommand(value));
                     return;
                 }
-                if (command instanceof StopMoveType) {
-                    switch ((StopMoveType) command) {
+                if (command instanceof StopMoveType stopMoveCommand) {
+                    switch (stopMoveCommand) {
                         case STOP:
                             submitCommand(new ControlCommand(ControlAction.STOP));
                             return;
@@ -264,8 +265,8 @@ public class AM43Handler extends ConnectedBluetoothHandler implements ResponseLi
                             return;
                     }
                 }
-                if (command instanceof UpDownType) {
-                    switch ((UpDownType) command) {
+                if (command instanceof UpDownType upDownCommand) {
+                    switch (upDownCommand) {
                         case UP:
                             submitCommand(new ControlCommand(ControlAction.OPEN));
                             return;
@@ -276,11 +277,10 @@ public class AM43Handler extends ConnectedBluetoothHandler implements ResponseLi
                 }
                 return;
             case AM43BindingConstants.CHANNEL_ID_SPEED:
-                if (command instanceof DecimalType) {
+                if (command instanceof DecimalType decimalCommand) {
                     MotorSettings settings = motorSettings;
                     if (settings != null) {
-                        DecimalType speedType = (DecimalType) command;
-                        settings.setSpeed(speedType.intValue());
+                        settings.setSpeed(decimalCommand.intValue());
                         submitCommand(new SetSettingsCommand(settings));
                     } else {
                         logger.warn("Cannot set Speed before setting have been received");
index 4907716139790ad503056f032c656c6304141df4..29ed381c5688d00f7cd1e5f5d5f2e667bf8ba8de 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.am43.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -33,8 +32,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.am43")
 public class AM43HandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(AM43BindingConstants.THING_TYPE_AM43);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(AM43BindingConstants.THING_TYPE_AM43);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index e520daf1be697f3cca600633ed55ab93291ee2be..8a3937638e90c5c7d0f9de3a82840fc3219178d7 100644 (file)
@@ -35,6 +35,7 @@ public class BlueGigaBluetoothCharacteristic extends BluetoothCharacteristic {
         super(null, handle);
     }
 
+    @Override
     public void setProperties(int properties) {
         this.properties = properties;
     }
index 7938f3802ce6e8dd7e3600700310de75c9ac7cee..0aa8377b0f72f6e22df592d7f6b793706f141716 100644 (file)
@@ -356,33 +356,33 @@ public class BlueGigaBluetoothDevice extends BaseBluetoothDevice implements Blue
 
     @Override
     public void bluegigaEventReceived(BlueGigaResponse event) {
-        if (event instanceof BlueGigaScanResponseEvent) {
-            handleScanEvent((BlueGigaScanResponseEvent) event);
+        if (event instanceof BlueGigaScanResponseEvent responseEvent) {
+            handleScanEvent(responseEvent);
         }
 
-        else if (event instanceof BlueGigaGroupFoundEvent) {
-            handleGroupFoundEvent((BlueGigaGroupFoundEvent) event);
+        else if (event instanceof BlueGigaGroupFoundEvent foundEvent) {
+            handleGroupFoundEvent(foundEvent);
         }
 
-        else if (event instanceof BlueGigaFindInformationFoundEvent) {
+        else if (event instanceof BlueGigaFindInformationFoundEvent foundEvent) {
             // A Characteristic has been discovered
-            handleFindInformationFoundEvent((BlueGigaFindInformationFoundEvent) event);
+            handleFindInformationFoundEvent(foundEvent);
         }
 
-        else if (event instanceof BlueGigaProcedureCompletedEvent) {
-            handleProcedureCompletedEvent((BlueGigaProcedureCompletedEvent) event);
+        else if (event instanceof BlueGigaProcedureCompletedEvent completedEvent) {
+            handleProcedureCompletedEvent(completedEvent);
         }
 
-        else if (event instanceof BlueGigaConnectionStatusEvent) {
-            handleConnectionStatusEvent((BlueGigaConnectionStatusEvent) event);
+        else if (event instanceof BlueGigaConnectionStatusEvent statusEvent) {
+            handleConnectionStatusEvent(statusEvent);
         }
 
-        else if (event instanceof BlueGigaDisconnectedEvent) {
-            handleDisconnectedEvent((BlueGigaDisconnectedEvent) event);
+        else if (event instanceof BlueGigaDisconnectedEvent disconnectedEvent) {
+            handleDisconnectedEvent(disconnectedEvent);
         }
 
-        else if (event instanceof BlueGigaAttributeValueEvent) {
-            handleAttributeValueEvent((BlueGigaAttributeValueEvent) event);
+        else if (event instanceof BlueGigaAttributeValueEvent valueEvent) {
+            handleAttributeValueEvent(valueEvent);
         }
     }
 
index 8443d9d2a9d597ba549cd0e60c2673a95e1debfa..27e244ae99ee6b91587400ec96b8e1c840e6354b 100644 (file)
@@ -779,9 +779,8 @@ public class BlueGigaBridgeHandler extends AbstractBluetoothBridgeHandler<BlueGi
 
     @Override
     public void bluegigaEventReceived(@Nullable BlueGigaResponse event) {
-        if (event instanceof BlueGigaScanResponseEvent) {
+        if (event instanceof BlueGigaScanResponseEvent scanEvent) {
             if (initComplete) {
-                BlueGigaScanResponseEvent scanEvent = (BlueGigaScanResponseEvent) event;
 
                 // We use the scan event to add any devices we hear to the devices list
                 // The device gets created, and then manages itself for discovery etc.
@@ -795,13 +794,11 @@ public class BlueGigaBridgeHandler extends AbstractBluetoothBridgeHandler<BlueGi
             return;
         }
 
-        if (event instanceof BlueGigaConnectionStatusEvent) {
-            BlueGigaConnectionStatusEvent connectionEvent = (BlueGigaConnectionStatusEvent) event;
+        if (event instanceof BlueGigaConnectionStatusEvent connectionEvent) {
             connections.put(connectionEvent.getConnection(), new BluetoothAddress(connectionEvent.getAddress()));
         }
 
-        if (event instanceof BlueGigaDisconnectedEvent) {
-            BlueGigaDisconnectedEvent disconnectedEvent = (BlueGigaDisconnectedEvent) event;
+        if (event instanceof BlueGigaDisconnectedEvent disconnectedEvent) {
             connections.remove(disconnectedEvent.getConnection());
         }
     }
index 30137926637418d6a178d1a3e8db66652279c58e..33ba00493961da7b07053b96ecd83d344ac1ccbe 100644 (file)
@@ -35,11 +35,11 @@ public class BlueGigaConfiguration extends BaseBluetoothBridgeHandlerConfigurati
 
     @Override
     public String toString() {
-        return String.format(
-                "[discovery=%b, port=%s, passiveScanIdleTime=%d, passiveScanInterval=%d, passiveScanWindow=%d"
-                        + ", activeScanInterval=%d, activeScanWindow=%d, connIntervalMin=%d, connIntervalMax=%d"
-                        + ", connLatency=%d, connTimeout=%d]",
-                backgroundDiscovery, port, passiveScanIdleTime, passiveScanInterval, passiveScanWindow,
+        return String.format("""
+                [discovery=%b, port=%s, passiveScanIdleTime=%d, passiveScanInterval=%d, passiveScanWindow=%d\
+                , activeScanInterval=%d, activeScanWindow=%d, connIntervalMin=%d, connIntervalMax=%d\
+                , connLatency=%d, connTimeout=%d]\
+                """, backgroundDiscovery, port, passiveScanIdleTime, passiveScanInterval, passiveScanWindow,
                 activeScanInterval, activeScanWindow, connIntervalMin, connIntervalMax, connLatency, connTimeout);
     }
 }
index 23952c36e277dd21261602b926239704bbcd219e..2f3ec5395c7264c7e9ab9a034c288e9fb03a3913 100644 (file)
@@ -194,8 +194,7 @@ class BlueGigaResponsePackets {
 
         try {
             ctor = bleClass.getConstructor(int[].class);
-            BlueGigaResponse bleFrame = (BlueGigaResponse) ctor.newInstance(data);
-            return bleFrame;
+            return (BlueGigaResponse) ctor.newInstance(data);
         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
                 | IllegalArgumentException | InvocationTargetException e) {
             logger.debug("Error instantiating BLE class", e);
index 35fc8e3e1ddbe91157f5ff2400499dd568a36785..160d18f2f6bccc2da7c65a6d87a2cdec25486e9d 100644 (file)
@@ -260,8 +260,10 @@ public class BlueGigaSerialHandler {
 
     private void checkIfAlive() {
         if (!isAlive()) {
-            throw new IllegalStateException("Bluegiga handler is dead. Most likely because of IO errors. "
-                    + "Re-initialization of the BlueGigaSerialHandler is required.");
+            throw new IllegalStateException("""
+                    Bluegiga handler is dead. Most likely because of IO errors. \
+                    Re-initialization of the BlueGigaSerialHandler is required.\
+                    """);
         }
     }
 
index ef4204d0c3e49b6a5dbb9ef4a5237e4f059a9be1..b62e68da9db3b11e2840d69ccff4facd2c93c54a 100644 (file)
@@ -154,7 +154,7 @@ public class BlueGigaTransactionManager implements BlueGigaSerialEventListener {
     private void sendNextTransactionIfNoOngoing() {
         synchronized (this) {
             logger.trace("Send next transaction if no ongoing");
-            if (!ongoingTransactionId.isPresent()) {
+            if (ongoingTransactionId.isEmpty()) {
                 sendNextFrame();
             }
         }
@@ -243,9 +243,8 @@ public class BlueGigaTransactionManager implements BlueGigaSerialEventListener {
 
                 logger.trace("Expected frame: {}, received frame: {}", expected.getSimpleName(), bleResponse);
 
-                if (bleCommand instanceof BlueGigaDeviceCommand && bleResponse instanceof BlueGigaDeviceResponse) {
-                    BlueGigaDeviceCommand devCommand = (BlueGigaDeviceCommand) bleCommand;
-                    BlueGigaDeviceResponse devResponse = (BlueGigaDeviceResponse) bleResponse;
+                if (bleCommand instanceof BlueGigaDeviceCommand devCommand
+                        && bleResponse instanceof BlueGigaDeviceResponse devResponse) {
 
                     logger.trace("Expected connection id: {}, received connection id: {}", devCommand.getConnection(),
                             devResponse.getConnection());
index 256982b6a81bcbb92655d7b3adeed271da14b219..773886e80be6eb84bb708cb66852fff70592d177 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.bluegiga.internal.factory;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
@@ -48,8 +47,8 @@ import org.osgi.service.component.annotations.Reference;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.bluegiga")
 public class BlueGigaHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(BlueGigaAdapterConstants.THING_TYPE_BLUEGIGA);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(BlueGigaAdapterConstants.THING_TYPE_BLUEGIGA);
 
     private final Map<ThingUID, ServiceRegistration<?>> serviceRegs = new HashMap<>();
 
@@ -90,8 +89,8 @@ public class BlueGigaHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected synchronized void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof BluetoothAdapter) {
-            UID uid = ((BluetoothAdapter) thingHandler).getUID();
+        if (thingHandler instanceof BluetoothAdapter bluetoothAdapter) {
+            UID uid = bluetoothAdapter.getUID();
             ServiceRegistration<?> serviceReg = this.serviceRegs.remove(uid);
             if (serviceReg != null) {
                 serviceReg.unregister();
index 32889928e24451a3bc535aeddee869eae1cebfcd..6903f2d5a63c14291de8e94310e0a191e4b7f8d1 100644 (file)
@@ -194,8 +194,7 @@ public class BlueZBridgeHandler extends AbstractBluetoothBridgeHandler<BlueZBlue
     @Override
     protected BlueZBluetoothDevice createDevice(BluetoothAddress address) {
         logger.debug("createDevice {}", address);
-        BlueZBluetoothDevice device = new BlueZBluetoothDevice(this, address);
-        return device;
+        return new BlueZBluetoothDevice(this, address);
     }
 
     @Override
index 684e8ed5481df7dd471ab5bb5e77870b627b6189..243bc570e05318692e3cb0dd5c1656bd52893c64 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.bluetooth.bluez.internal;
 
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -51,7 +51,7 @@ public class BlueZDiscoveryService extends AbstractDiscoveryService {
 
     @Activate
     public BlueZDiscoveryService(@Reference DeviceManagerFactory deviceManagerFactory) {
-        super(Collections.singleton(BlueZAdapterConstants.THING_TYPE_BLUEZ), 1, true);
+        super(Set.of(BlueZAdapterConstants.THING_TYPE_BLUEZ), 1, true);
         this.deviceManagerFactory = deviceManagerFactory;
     }
 
index 1828ac10e0769da04a6992a15c7d6ba07ee7787a..d87614d3a5a2ddd66476dd3ac618c186bd67afb5 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.bluez.internal;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
@@ -45,8 +44,7 @@ import org.osgi.service.component.annotations.Reference;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.bluetooth.bluez")
 public class BlueZHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(BlueZAdapterConstants.THING_TYPE_BLUEZ);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(BlueZAdapterConstants.THING_TYPE_BLUEZ);
 
     private final Map<ThingUID, ServiceRegistration<?>> serviceRegs = new HashMap<>();
 
@@ -82,8 +80,8 @@ public class BlueZHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected synchronized void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof BluetoothAdapter) {
-            UID uid = ((BluetoothAdapter) thingHandler).getUID();
+        if (thingHandler instanceof BluetoothAdapter bluetoothAdapter) {
+            UID uid = bluetoothAdapter.getUID();
             ServiceRegistration<?> serviceReg = this.serviceRegs.remove(uid);
             if (serviceReg != null) {
                 serviceReg.unregister();
index 35c1c2a68fe950ed957d3024226b8da82016881f..a8844f0bba992890f3eaf540e4d6edb86a0cf95f 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.blukii.internal;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -42,7 +41,7 @@ public class BlukiiDiscoveryParticipant implements BluetoothDiscoveryParticipant
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(BlukiiBindingConstants.THING_TYPE_BEACON);
+        return Set.of(BlukiiBindingConstants.THING_TYPE_BEACON);
     }
 
     @Override
index e3bd9790fce78e0646b4d19cdf80d3dd71e9f840..5eed6b011f920b53ef696a62d0f133581446f4f9 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.blukii.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -35,8 +34,8 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.blukii")
 public class BlukiiHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(BlukiiBindingConstants.THING_TYPE_BEACON);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(BlukiiBindingConstants.THING_TYPE_BEACON);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 47a61b34a66a0b4ca7eea618d4f940d9eafbeaac..4f80d140db30dd10ee7570f62e20c6c87cc608e7 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.bluetooth.daikinmadoka.internal;
 
 import static org.openhab.binding.bluetooth.daikinmadoka.DaikinMadokaBindingConstants.THING_TYPE_BRC1H;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -39,7 +38,7 @@ import org.slf4j.LoggerFactory;
 @Component(configurationPid = "binding.bluetooth.daikinmadoka", service = ThingHandlerFactory.class)
 public class DaikinMadokaHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_BRC1H);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_BRC1H);
 
     private final Logger logger = LoggerFactory.getLogger(DaikinMadokaHandlerFactory.class);
 
index 7eb0d26996d349432c2574bdff623e8f19bfdcb8..de627b34935b0ed15aa68e3145fb9d341f06eb24 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.enoceanble.internal;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,7 @@ public class EnoceanBleDiscoveryParticipant implements BluetoothDiscoveryPartici
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(EnoceanBleBindingConstants.THING_TYPE_PTM215B);
+        return Set.of(EnoceanBleBindingConstants.THING_TYPE_PTM215B);
     }
 
     @Override
index 292c836463a38238508abe9e1a16ad681ea93420..dcbf0dd161e8556d1b6046d1e5faaa111e76ce0e 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.enoceanble.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -33,8 +32,8 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.enoceanble")
 public class EnoceanBleHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(EnoceanBleBindingConstants.THING_TYPE_PTM215B);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(EnoceanBleBindingConstants.THING_TYPE_PTM215B);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index e3743123abbed31cc7a5e9934baec634f7a5a3e0..e6f176670d2d32c2931937ec14de7a250f3d5024 100644 (file)
@@ -108,7 +108,7 @@ public class CharacteristicChannelTypeProvider implements ChannelTypeProvider {
         if (channelID.charAt(30) != '-') {
             return false;
         }
-        return !(channelID.charAt(67) != '-');
+        return channelID.charAt(67) == '-';
     }
 
     public ChannelTypeUID registerChannelType(String characteristicUUID, boolean advanced, boolean readOnly,
index a42bdfe01adae6fe980a8d7f5d1e16d0efca292c..abde93890fb5ab046a9a4b2653c2c6d93b707405 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.roaming.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public class RoamingBindingConstants {
     public static final ThingTypeUID THING_TYPE_ROAMING = new ThingTypeUID(BluetoothBindingConstants.BINDING_ID,
             "roaming");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_ROAMING);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_ROAMING);
 
     public static final String CONFIGURATION_GROUP_ADAPTER_UIDS = "groupUIDs";
 }
index 50b3fd5a17b88d5edb6ae0cc6063da1f8c0e2897..e0122ac082be7cb06b82bcfe73e4034f5a4d8655 100644 (file)
@@ -136,7 +136,7 @@ public class RoamingBridgeHandler extends BaseBridgeHandler implements RoamingBl
             return false;
         }
         Object discovery = getConfig().get(BluetoothBindingConstants.CONFIGURATION_DISCOVERY);
-        return !(discovery != null && discovery.toString().equalsIgnoreCase("false"));
+        return !(discovery != null && "false".equalsIgnoreCase(discovery.toString()));
     }
 
     @Override
index c49693f62c0f52d1fef8da16e9a855932cf39e83..2681ed1aefe88e2f019e88de924f4a0123f387d8 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.bluetooth.BluetoothAdapter;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
@@ -69,8 +68,8 @@ public class RoamingHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected synchronized void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof RoamingBluetoothAdapter) {
-            UID uid = ((BluetoothAdapter) thingHandler).getUID();
+        if (thingHandler instanceof RoamingBluetoothAdapter bluetoothAdapter) {
+            UID uid = bluetoothAdapter.getUID();
             ServiceRegistration<?> serviceReg = this.serviceRegs.remove(uid);
             if (serviceReg != null) {
                 serviceReg.unregister();
index 8532714fcb9c64925bb1e76e3ffc04ba65e12219..15d1ab5e444ee75aa379389b1afc04969e6df833 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.ruuvitag.internal;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -43,7 +42,7 @@ public class RuuviTagDiscoveryParticipant implements BluetoothDiscoveryParticipa
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(RuuviTagBindingConstants.THING_TYPE_BEACON);
+        return Set.of(RuuviTagBindingConstants.THING_TYPE_BEACON);
     }
 
     @Override
index bfaae59f7d24cfc16d26e123a909deb4289c1756..46acaaa7c958985e84892b4e90c0ec02620c09af 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.bluetooth.ruuvitag.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -33,8 +32,8 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.ruuvitag")
 public class RuuviTagHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .singleton(RuuviTagBindingConstants.THING_TYPE_BEACON);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set
+            .of(RuuviTagBindingConstants.THING_TYPE_BEACON);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 4ca5dc45566e84ea0612484d455d4189bacf156c..6bd553448f6c0d34348a27bc12ca55e7c7330ff3 100644 (file)
@@ -80,8 +80,8 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler {
 
         Object idleDisconnectDelayRaw = getConfig().get(BluetoothBindingConstants.CONFIGURATION_IDLE_DISCONNECT_DELAY);
         idleDisconnectDelay = 1000;
-        if (idleDisconnectDelayRaw instanceof Number) {
-            idleDisconnectDelay = ((Number) idleDisconnectDelayRaw).intValue();
+        if (idleDisconnectDelayRaw instanceof Number numberCommand) {
+            idleDisconnectDelay = numberCommand.intValue();
         }
 
         // Start the recurrent job if the device is always connected
@@ -202,11 +202,11 @@ public class ConnectedBluetoothHandler extends BeaconBluetoothHandler {
             return CompletableFuture.failedFuture(new IllegalStateException("connectionTaskExecutor is shut down"));
         }
         // we use a RetryFuture because it supports running Callable instances
-        return RetryFuture.callWithRetry(() -> {
-            // we block for completion here so that we keep the lock on the connectionTaskExecutor active.
-            return callable.apply(connectAndGetCharacteristic(serviceUUID, characteristicUUID)).get();
-        }, connectionTaskExecutor)// we make this completion async so that operations chained off the returned future
-                                  // will not run on the connectionTaskExecutor
+        return RetryFuture.callWithRetry(() ->
+        // we block for completion here so that we keep the lock on the connectionTaskExecutor active.
+        callable.apply(connectAndGetCharacteristic(serviceUUID, characteristicUUID)).get(), connectionTaskExecutor)
+                // we make this completion async so that operations chained off the returned future
+                // will not run on the connectionTaskExecutor
                 .whenCompleteAsync((r, th) -> {
                     // we us a while loop here in case the exceptions get nested
                     while (th instanceof CompletionException || th instanceof ExecutionException) {
index 7058bb3860f41a9843496eac10dd96e74a9756d3..18e3703676c50a021c419c2604256c9145e49ad5 100644 (file)
@@ -94,8 +94,7 @@ public class RetryFuture<T> extends HeritableFuture<T> {
                 if (th instanceof CompletionException) {
                     th = th.getCause();
                 }
-                if (th instanceof RetryException) {
-                    RetryException e = (RetryException) th;
+                if (th instanceof RetryException e) {
                     setParentFuture(() -> {
                         if (!isDone()) {
                             return scheduler.schedule(this, e.delay, e.unit);
index 9b362883cb6eaa1ebeeeebe4b2b6c312fa3e59a7..aae70b1e8595cc1e32ba87160ab56db9b5b05d39 100644 (file)
@@ -539,7 +539,7 @@ public class BluetoothDiscoveryServiceTest {
 
         @Override
         public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-            return Collections.singleton(typeUID);
+            return Set.of(typeUID);
         }
 
         @Override
index 31587472819b9f1afa1422838c98a38d591bd686..0eb0b5297e2fa0f29c5b44bdb59374d01dde1c1a 100644 (file)
@@ -64,8 +64,7 @@ public class BondHomeHandlerFactory extends BaseThingHandlerFactory {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
         if (THING_TYPE_BOND_BRIDGE.equals(thingTypeUID)) {
-            final BondBridgeHandler handler = new BondBridgeHandler((Bridge) thing, httpClientFactory);
-            return handler;
+            return new BondBridgeHandler((Bridge) thing, httpClientFactory);
         } else if (SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
             return new BondDeviceHandler(thing);
         }
index 0fcf8256bb5c03cb7b003aa99bfcbf16feec44da..97b9ec8880ee6e7fe59bb3f88ac4918f07f546fc 100644 (file)
@@ -219,7 +219,7 @@ public class BondHttpApi {
                         bridgeHandler.getBridgeToken());
                 ContentResponse response;
                 response = request.send();
-                String encoding = response.getEncoding() != null ? response.getEncoding().replaceAll("\"", "").trim()
+                String encoding = response.getEncoding() != null ? response.getEncoding().replace("\"", "").trim()
                         : StandardCharsets.UTF_8.name();
                 try {
                     httpResponse = new String(response.getContent(), encoding);
index 6d3ce30c6ef70d6fe0963adcfef468a455e3ae36..c32697ef3b9a7c3b058e5022a248ba7f5ed71c59 100644 (file)
@@ -58,9 +58,7 @@ public class BondDiscoveryService extends AbstractDiscoveryService implements Th
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof BondBridgeHandler) {
-            @Nullable
-            BondBridgeHandler localHandler = (BondBridgeHandler) handler;
+        if (handler instanceof BondBridgeHandler localHandler) {
             bridgeHandler = localHandler;
             localHandler.setDiscoveryService(this);
             api = localHandler.getBridgeAPI();
index 7c28cf3412ddfc8738cd219e97352708556ee6d3..ed779d454ed65c483991c96527e99a0b97748ef1 100644 (file)
@@ -170,8 +170,7 @@ public class BondBridgeHandler extends BaseBridgeHandler {
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
         super.childHandlerInitialized(childHandler, childThing);
-        if (childHandler instanceof BondDeviceHandler) {
-            BondDeviceHandler handler = (BondDeviceHandler) childHandler;
+        if (childHandler instanceof BondDeviceHandler handler) {
             synchronized (handlers) {
                 // Start the BPUP update service after the first child device is added
                 startUDPListenerJob();
@@ -184,8 +183,7 @@ public class BondBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof BondDeviceHandler) {
-            BondDeviceHandler handler = (BondDeviceHandler) childHandler;
+        if (childHandler instanceof BondDeviceHandler handler) {
             synchronized (handlers) {
                 handlers.remove(handler);
                 if (handlers.isEmpty()) {
@@ -210,7 +208,7 @@ public class BondBridgeHandler extends BaseBridgeHandler {
         String deviceId = null;
         String topicType = null;
         if (topic != null) {
-            String parts[] = topic.split("/");
+            String[] parts = topic.split("/");
             deviceId = parts[1];
             topicType = parts[2];
         }
@@ -332,7 +330,7 @@ public class BondBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(BondDiscoveryService.class);
+        return Set.of(BondDiscoveryService.class);
     }
 
     public void setDiscoveryService(BondDiscoveryService discoveryService) {
index 89c7571b81e1b4ffd276e48abb91d453b5010052..d0846decbfb6f638ad28b61e7f00e9384e659e06 100644 (file)
@@ -156,9 +156,9 @@ public class BondDeviceHandler extends BaseThingHandler {
 
             case CHANNEL_FAN_SPEED:
                 logger.trace("Fan speed command");
-                if (command instanceof PercentType) {
+                if (command instanceof PercentType percentCommand) {
                     if (devInfo.actions.contains(BondDeviceAction.SET_FP_FAN)) {
-                        value = ((PercentType) command).intValue();
+                        value = percentCommand.intValue();
                         if (value == 0) {
                             action = BondDeviceAction.TURN_FP_FAN_OFF;
                             value = null;
@@ -169,7 +169,7 @@ public class BondDeviceHandler extends BaseThingHandler {
                         BondDeviceProperties devProperties = this.deviceProperties;
                         if (devProperties != null) {
                             int maxSpeed = devProperties.maxSpeed;
-                            value = (int) Math.ceil(((PercentType) command).intValue() * maxSpeed / 100);
+                            value = (int) Math.ceil(percentCommand.intValue() * maxSpeed / 100);
                         } else {
                             value = 1;
                         }
@@ -182,11 +182,10 @@ public class BondDeviceHandler extends BaseThingHandler {
                     }
                     logger.trace("Fan speed command with speed set as {}", value);
                     api.executeDeviceAction(deviceId, action, value);
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     logger.trace("Fan increase/decrease speed command");
                     api.executeDeviceAction(deviceId,
-                            ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE
-                                    ? BondDeviceAction.INCREASE_SPEED
+                            (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE ? BondDeviceAction.INCREASE_SPEED
                                     : BondDeviceAction.DECREASE_SPEED),
                             null);
                 } else if (command instanceof OnOffType) {
@@ -206,8 +205,8 @@ public class BondDeviceHandler extends BaseThingHandler {
                 break;
 
             case CHANNEL_RAW_FAN_SPEED:
-                if (command instanceof DecimalType) {
-                    value = ((DecimalType) command).intValue();
+                if (command instanceof DecimalType decimalCommand) {
+                    value = decimalCommand.intValue();
                     BondDeviceProperties devProperties = this.deviceProperties;
                     if (devProperties != null) {
                         if (value < 1) {
@@ -246,7 +245,7 @@ public class BondDeviceHandler extends BaseThingHandler {
                 logger.trace("Fan direction command {}", command.toString());
                 if (command instanceof StringType) {
                     api.executeDeviceAction(deviceId, BondDeviceAction.SET_DIRECTION,
-                            command.toString().equals("winter") ? -1 : 1);
+                            "winter".equals(command.toString()) ? -1 : 1);
                 }
                 break;
 
@@ -258,9 +257,8 @@ public class BondDeviceHandler extends BaseThingHandler {
                 break;
 
             case CHANNEL_LIGHT_BRIGHTNESS:
-                if (command instanceof PercentType) {
-                    PercentType pctCommand = (PercentType) command;
-                    value = pctCommand.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    value = percentCommand.intValue();
                     if (value == 0) {
                         action = BondDeviceAction.TURN_LIGHT_OFF;
                         value = null;
@@ -269,10 +267,10 @@ public class BondDeviceHandler extends BaseThingHandler {
                     }
                     logger.trace("Fan light brightness command with value of {}", value);
                     api.executeDeviceAction(deviceId, action, value);
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     logger.trace("Fan light brightness increase/decrease command {}", command);
                     api.executeDeviceAction(deviceId,
-                            ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE
+                            (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE
                                     ? BondDeviceAction.INCREASE_BRIGHTNESS
                                     : BondDeviceAction.DECREASE_BRIGHTNESS),
                             null);
@@ -301,9 +299,8 @@ public class BondDeviceHandler extends BaseThingHandler {
 
             case CHANNEL_UP_LIGHT_BRIGHTNESS:
                 enableUpLight();
-                if (command instanceof PercentType) {
-                    PercentType pctCommand = (PercentType) command;
-                    value = pctCommand.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    value = percentCommand.intValue();
                     if (value == 0) {
                         action = BondDeviceAction.TURN_LIGHT_OFF;
                         value = null;
@@ -312,10 +309,10 @@ public class BondDeviceHandler extends BaseThingHandler {
                     }
                     logger.trace("Fan up light brightness command with value of {}", value);
                     api.executeDeviceAction(deviceId, action, value);
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     logger.trace("Fan uplight brightness increase/decrease command {}", command);
                     api.executeDeviceAction(deviceId,
-                            ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE
+                            (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE
                                     ? BondDeviceAction.INCREASE_UP_LIGHT_BRIGHTNESS
                                     : BondDeviceAction.DECREASE_UP_LIGHT_BRIGHTNESS),
                             null);
@@ -344,9 +341,8 @@ public class BondDeviceHandler extends BaseThingHandler {
 
             case CHANNEL_DOWN_LIGHT_BRIGHTNESS:
                 enableDownLight();
-                if (command instanceof PercentType) {
-                    PercentType pctCommand = (PercentType) command;
-                    value = pctCommand.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    value = percentCommand.intValue();
                     if (value == 0) {
                         action = BondDeviceAction.TURN_LIGHT_OFF;
                         value = null;
@@ -355,10 +351,10 @@ public class BondDeviceHandler extends BaseThingHandler {
                     }
                     logger.trace("Fan down light brightness command with value of {}", value);
                     api.executeDeviceAction(deviceId, action, value);
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     logger.trace("Fan down light brightness increase/decrease command");
                     api.executeDeviceAction(deviceId,
-                            ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE
+                            (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE
                                     ? BondDeviceAction.INCREASE_DOWN_LIGHT_BRIGHTNESS
                                     : BondDeviceAction.DECREASE_DOWN_LIGHT_BRIGHTNESS),
                             null);
@@ -373,9 +369,8 @@ public class BondDeviceHandler extends BaseThingHandler {
                 break;
 
             case CHANNEL_FLAME:
-                if (command instanceof PercentType) {
-                    PercentType pctCommand = (PercentType) command;
-                    value = pctCommand.intValue();
+                if (command instanceof PercentType percentCommand) {
+                    value = percentCommand.intValue();
                     if (value == 0) {
                         action = BondDeviceAction.TURN_OFF;
                         value = null;
@@ -384,11 +379,10 @@ public class BondDeviceHandler extends BaseThingHandler {
                     }
                     logger.trace("Fireplace flame command with value of {}", value);
                     api.executeDeviceAction(deviceId, action, value);
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     logger.trace("Fireplace flame increase/decrease command");
                     api.executeDeviceAction(deviceId,
-                            ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE
-                                    ? BondDeviceAction.INCREASE_FLAME
+                            (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE ? BondDeviceAction.INCREASE_FLAME
                                     : BondDeviceAction.DECREASE_FLAME),
                             null);
                 } else if (command instanceof OnOffType) {
@@ -540,7 +534,7 @@ public class BondDeviceHandler extends BaseThingHandler {
         updateProperty(thingProperties, PROPERTIES_TEMPLATE_NAME, devInfo.template);
         thingProperties.put(PROPERTIES_MAX_SPEED, String.valueOf(devProperties.maxSpeed));
         thingProperties.put(PROPERTIES_TRUST_STATE, String.valueOf(devProperties.trustState));
-        thingProperties.put(PROPERTIES_ADDRESS, String.valueOf(devProperties.addr));
+        thingProperties.put(PROPERTIES_ADDRESS, devProperties.addr);
         thingProperties.put(PROPERTIES_RF_FREQUENCY, String.valueOf(devProperties.freq));
         logger.trace("Saving properties for {} ({})", config.deviceId, this.getThing().getLabel());
         updateProperties(thingProperties);
index 0482e3e1ee60914923ebc84d9dd29354333ca392..06d70191833914005fa9675a4a7d4ee852ef43df 100644 (file)
@@ -47,6 +47,7 @@ public class AuthorizationController implements AuthorizationProvider {
         this.oAuthClientService = oAuthClientService;
     }
 
+    @Override
     public String getAuthorizationHeader() throws IndegoAuthenticationException {
         final AccessTokenResponse accessTokenResponse;
         try {
index 22c734d7427294630723dbd58bffbeb2e2b7130e..2cf326001dbba06b7ac5de10a1f644de02c87b64 100644 (file)
@@ -158,8 +158,8 @@ public class IndegoController {
             throw new IndegoException(e);
         } catch (ExecutionException e) {
             Throwable cause = e.getCause();
-            if (cause != null && cause instanceof HttpResponseException) {
-                Response response = ((HttpResponseException) cause).getResponse();
+            if (cause != null && cause instanceof HttpResponseException httpResponseException) {
+                Response response = httpResponseException.getResponse();
                 if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
                     /*
                      * The service may respond with HTTP code 401 without any "WWW-Authenticate"
@@ -218,8 +218,8 @@ public class IndegoController {
             throw new IndegoException(e);
         } catch (ExecutionException e) {
             Throwable cause = e.getCause();
-            if (cause != null && cause instanceof HttpResponseException) {
-                Response response = ((HttpResponseException) cause).getResponse();
+            if (cause != null && cause instanceof HttpResponseException httpResponseException) {
+                Response response = httpResponseException.getResponse();
                 if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
                     /*
                      * When contextId is not valid, the service will respond with HTTP code 401 without
@@ -316,8 +316,8 @@ public class IndegoController {
             throw new IndegoException(e);
         } catch (ExecutionException e) {
             Throwable cause = e.getCause();
-            if (cause != null && cause instanceof HttpResponseException) {
-                Response response = ((HttpResponseException) cause).getResponse();
+            if (cause != null && cause instanceof HttpResponseException httpResponseException) {
+                Response response = httpResponseException.getResponse();
                 if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
                     /*
                      * When contextId is not valid, the service will respond with HTTP code 401 without
index 72bff9f463cb73ff745297f53aa51a18ed92e5bc..18afdf0e401c17c3463d9612d31451c2a3d199fd 100644 (file)
@@ -141,9 +141,7 @@ public class IndegoDeviceController extends IndegoController {
      * @throws IndegoException if any communication or parsing error occurred
      */
     public DeviceCalendarResponse getCalendar() throws IndegoAuthenticationException, IndegoException {
-        DeviceCalendarResponse calendar = getRequest(SERIAL_NUMBER_SUBPATH + serialNumber + "/calendar",
-                DeviceCalendarResponse.class);
-        return calendar;
+        return getRequest(SERIAL_NUMBER_SUBPATH + serialNumber + "/calendar", DeviceCalendarResponse.class);
     }
 
     /**
index cb8624915a491d7fa3095a75fec6d12417265bcb..0329c0dfd89fcfe0201b85695da13066e5421035 100644 (file)
@@ -130,10 +130,12 @@ public class BoschAccountHandler extends BaseBridgeHandler implements Authorizat
         }
     }
 
+    @Override
     public void onSuccessfulAuthorization() {
         updateStatus(ThingStatus.ONLINE);
     }
 
+    @Override
     public void onFailedAuthorization(Throwable throwable) {
         logger.debug("Authorization failure", throwable);
         if (throwable instanceof IndegoAuthenticationException) {
@@ -144,6 +146,7 @@ public class BoschAccountHandler extends BaseBridgeHandler implements Authorizat
         }
     }
 
+    @Override
     public void onAuthorizationFlowCompleted() {
         // Ignore
     }
index 9cf3fdd9e509b5dacee911ebeefc5076dc187332..e7f2b9768a3dd9b296b70ed5f90b58b6ef8a3642 100644 (file)
@@ -161,14 +161,17 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
         }
     }
 
+    @Override
     public void onSuccessfulAuthorization() {
         // Ignore
     }
 
+    @Override
     public void onFailedAuthorization(Throwable throwable) {
         // Ignore
     }
 
+    @Override
     public void onAuthorizationFlowCompleted() {
         // Trigger immediate state refresh upon authorization success.
         rescheduleStatePoll(0, stateInactiveRefreshIntervalSeconds, true);
@@ -226,8 +229,8 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
                 handleRefreshCommand(channelUID.getId());
                 return;
             }
-            if (command instanceof DecimalType && channelUID.getId().equals(STATE)) {
-                sendCommand(((DecimalType) command).intValue());
+            if (command instanceof DecimalType decimalCommand && channelUID.getId().equals(STATE)) {
+                sendCommand(decimalCommand.intValue());
             }
         } catch (IndegoAuthenticationException e) {
             // Ignore, will be handled by bridge
index 926c450637a787ca6d126c904995f1f2e85f20c5..54e14d749d33510b5631ca48d413705116bc1c2c 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -106,7 +107,7 @@ public class BridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ThingDiscoveryService.class);
+        return Set.of(ThingDiscoveryService.class);
     }
 
     @Override
index af55dc1824365d59b0fad1540510dd3c0d8174a7..79a2a7a76f68fe06d8895168060ff2ba8fc0171b 100644 (file)
@@ -65,8 +65,8 @@ public final class ClimateControlHandler extends BoschSHCDeviceHandler {
         super.handleCommand(channelUID, command);
         switch (channelUID.getId()) {
             case CHANNEL_SETPOINT_TEMPERATURE:
-                if (command instanceof QuantityType<?>) {
-                    updateSetpointTemperature((QuantityType<?>) command);
+                if (command instanceof QuantityType<?> temperature) {
+                    updateSetpointTemperature(temperature);
                 }
                 break;
         }
index d8b61aea192e0048f15e46b464ec52de4268e49b..8941c8db18e152781ecb2eb27107799f3ba45255 100644 (file)
@@ -122,18 +122,18 @@ public class IntrusionDetectionHandler extends BoschSHCHandler {
 
         switch (channelUID.getId()) {
             case CHANNEL_ARM_ACTION:
-                if (command instanceof StringType) {
-                    armIntrusionDetectionSystem((StringType) command);
+                if (command instanceof StringType stringCommand) {
+                    armIntrusionDetectionSystem(stringCommand);
                 }
                 break;
             case CHANNEL_DISARM_ACTION:
-                if (command instanceof OnOffType) {
-                    disarmIntrusionDetectionSystem((OnOffType) command);
+                if (command instanceof OnOffType onOffCommand) {
+                    disarmIntrusionDetectionSystem(onOffCommand);
                 }
                 break;
             case CHANNEL_MUTE_ACTION:
-                if (command instanceof OnOffType) {
-                    muteIntrusionDetectionSystem((OnOffType) command);
+                if (command instanceof OnOffType onOffCommand) {
+                    muteIntrusionDetectionSystem(onOffCommand);
                 }
                 break;
         }
index c0f7828b0598f2889a7ec3c4104d64c7bed43538..49942f88c48205b0de8ca8b88792c27208f283c8 100644 (file)
@@ -34,15 +34,13 @@ public class SmokeDetectorCheckService extends BoschSHCService<SmokeDetectorChec
 
     @Override
     public SmokeDetectorCheckServiceState handleCommand(Command command) throws BoschSHCException {
-        if (command instanceof StringType) {
-            var stringCommand = (StringType) command;
+        if (command instanceof StringType stringCommand) {
             var state = new SmokeDetectorCheckServiceState();
             state.value = SmokeDetectorCheckState.from(stringCommand.toString());
             return state;
         }
 
-        if (command instanceof PlayPauseType) {
-            var playPauseCommand = (PlayPauseType) command;
+        if (command instanceof PlayPauseType playPauseCommand) {
             if (playPauseCommand.equals(PlayPauseType.PLAY)) {
                 var state = new SmokeDetectorCheckServiceState();
                 state.value = SmokeDetectorCheckState.SMOKE_TEST_REQUESTED;
index 6e85cefdf6bcd8e0ddacfff14aefe1d52c16b2ca..69247421d260d9d394502ed621622e4cc3e3ee38 100644 (file)
@@ -57,12 +57,22 @@ public abstract class AbstractBatteryPoweredDeviceHandlerTest<T extends Abstract
 
     @Test
     public void testProcessUpdateBatteryLevelLowBattery() {
-        JsonElement deviceServiceData = JsonParser.parseString("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\",\n"
-                + "    \"faults\":{ \n" + "        \"entries\":[\n" + "          {\n"
-                + "            \"type\":\"LOW_BATTERY\",\n" + "            \"category\":\"WARNING\"\n" + "          }\n"
-                + "        ]\n" + "    }\n" + "}");
+        JsonElement deviceServiceData = JsonParser.parseString("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361",
+                    "faults":{
+                        "entries":[
+                          {
+                            "type":"LOW_BATTERY",
+                            "category":"WARNING"
+                          }
+                        ]
+                    }
+                }\
+                """);
         getFixture().processUpdate("BatteryLevel", deviceServiceData);
         verify(getCallback()).stateUpdated(getChannelUID(BoschSHCBindingConstants.CHANNEL_BATTERY_LEVEL),
                 new DecimalType(10));
@@ -71,12 +81,22 @@ public abstract class AbstractBatteryPoweredDeviceHandlerTest<T extends Abstract
 
     @Test
     public void testProcessUpdateBatteryLevelCriticalLow() {
-        JsonElement deviceServiceData = JsonParser.parseString("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\",\n"
-                + "    \"faults\":{ \n" + "        \"entries\":[\n" + "          {\n"
-                + "            \"type\":\"CRITICAL_LOW\",\n" + "            \"category\":\"WARNING\"\n"
-                + "          }\n" + "        ]\n" + "    }\n" + "}");
+        JsonElement deviceServiceData = JsonParser.parseString("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361",
+                    "faults":{
+                        "entries":[
+                          {
+                            "type":"CRITICAL_LOW",
+                            "category":"WARNING"
+                          }
+                        ]
+                    }
+                }\
+                """);
         getFixture().processUpdate("BatteryLevel", deviceServiceData);
         verify(getCallback()).stateUpdated(getChannelUID(BoschSHCBindingConstants.CHANNEL_BATTERY_LEVEL),
                 new DecimalType(1));
@@ -85,12 +105,22 @@ public abstract class AbstractBatteryPoweredDeviceHandlerTest<T extends Abstract
 
     @Test
     public void testProcessUpdateBatteryLevelCriticallyLowBattery() {
-        JsonElement deviceServiceData = JsonParser.parseString("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\",\n"
-                + "    \"faults\":{ \n" + "        \"entries\":[\n" + "          {\n"
-                + "            \"type\":\"CRITICALLY_LOW_BATTERY\",\n" + "            \"category\":\"WARNING\"\n"
-                + "          }\n" + "        ]\n" + "    }\n" + "}");
+        JsonElement deviceServiceData = JsonParser.parseString("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361",
+                    "faults":{
+                        "entries":[
+                          {
+                            "type":"CRITICALLY_LOW_BATTERY",
+                            "category":"WARNING"
+                          }
+                        ]
+                    }
+                }\
+                """);
         getFixture().processUpdate("BatteryLevel", deviceServiceData);
         verify(getCallback()).stateUpdated(getChannelUID(BoschSHCBindingConstants.CHANNEL_BATTERY_LEVEL),
                 new DecimalType(1));
@@ -99,9 +129,13 @@ public abstract class AbstractBatteryPoweredDeviceHandlerTest<T extends Abstract
 
     @Test
     public void testProcessUpdateBatteryLevelOK() {
-        JsonElement deviceServiceData = JsonParser.parseString("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\" }");
+        JsonElement deviceServiceData = JsonParser.parseString("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361" }\
+                """);
         getFixture().processUpdate("BatteryLevel", deviceServiceData);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_BATTERY_LEVEL),
@@ -112,12 +146,22 @@ public abstract class AbstractBatteryPoweredDeviceHandlerTest<T extends Abstract
 
     @Test
     public void testProcessUpdateBatteryLevelNotAvailable() {
-        JsonElement deviceServiceData = JsonParser.parseString("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\",\n"
-                + "    \"faults\":{ \n" + "        \"entries\":[\n" + "          {\n"
-                + "            \"type\":\"NOT_AVAILABLE\",\n" + "            \"category\":\"WARNING\"\n"
-                + "          }\n" + "        ]\n" + "    }\n" + "}");
+        JsonElement deviceServiceData = JsonParser.parseString("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361",
+                    "faults":{
+                        "entries":[
+                          {
+                            "type":"NOT_AVAILABLE",
+                            "category":"WARNING"
+                          }
+                        ]
+                    }
+                }\
+                """);
         getFixture().processUpdate("BatteryLevel", deviceServiceData);
         verify(getCallback()).stateUpdated(getChannelUID(BoschSHCBindingConstants.CHANNEL_BATTERY_LEVEL),
                 UnDefType.UNDEF);
index 6ec8f4b40dce7604669b100da2a9822d51443038..1aac73d1317d6fba170c017cd1a66f68ddeabae1 100644 (file)
@@ -103,8 +103,13 @@ public abstract class AbstractPowerSwitchHandlerTest<T extends AbstractPowerSwit
 
     @Test
     public void testUpdateChannelPowerMeterServiceState() {
-        JsonElement jsonObject = JsonParser.parseString("{\n" + "  \"@type\": \"powerMeterState\",\n"
-                + "  \"powerConsumption\": \"23\",\n" + "  \"energyConsumption\": 42\n" + "}");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                  "@type": "powerMeterState",
+                  "powerConsumption": "23",
+                  "energyConsumption": 42
+                }\
+                """);
         getFixture().processUpdate("PowerMeter", jsonObject);
 
         verify(getCallback()).stateUpdated(eq(getChannelUID(BoschSHCBindingConstants.CHANNEL_POWER_CONSUMPTION)),
index 5461b7eed8a2b64ab7d3a5620c2c2aeeb65da66b..390651f554af058179e5797baefc79f1201cc109 100644 (file)
@@ -114,7 +114,7 @@ class BoschHttpClientTest {
         // mock a logger using reflection to avoid NPEs during logger calls
         Logger mockedLogger = mock(Logger.class);
         List<Field> fields = ReflectionSupport.findFields(BoschHttpClient.class,
-                f -> f.getName().equalsIgnoreCase("logger"), HierarchyTraversalMode.TOP_DOWN);
+                f -> "logger".equalsIgnoreCase(f.getName()), HierarchyTraversalMode.TOP_DOWN);
         Field field = fields.iterator().next();
         field.setAccessible(true);
         field.set(mockedHttpClient, mockedLogger);
@@ -137,7 +137,7 @@ class BoschHttpClientTest {
         // mock a logger using reflection to avoid NPEs during logger calls
         Logger mockedLogger = mock(Logger.class);
         List<Field> fields = ReflectionSupport.findFields(BoschHttpClient.class,
-                f -> f.getName().equalsIgnoreCase("logger"), HierarchyTraversalMode.TOP_DOWN);
+                f -> "logger".equalsIgnoreCase(f.getName()), HierarchyTraversalMode.TOP_DOWN);
         Field field = fields.iterator().next();
         field.setAccessible(true);
         field.set(mockedHttpClient, mockedLogger);
@@ -210,9 +210,7 @@ class BoschHttpClientTest {
                 "{\"@type\": \"JsonRestExceptionResponseEntity\", \"errorCode\": \"500\", \"statusCode\": \"500\"}");
 
         BoschSHCException e = assertThrows(BoschSHCException.class, () -> httpClient.sendRequest(request, Device.class,
-                Device::isValid, (Integer statusCode, String content) -> {
-                    return new BoschSHCException("test exception");
-                }));
+                Device::isValid, (Integer statusCode, String content) -> new BoschSHCException("test exception")));
         assertEquals("test exception", e.getMessage());
     }
 
@@ -240,9 +238,7 @@ class BoschHttpClientTest {
         when(response.getContentAsString()).thenReturn(
                 "{\"@type\": \"JsonRestExceptionResponseEntity\", \"errorCode\": \"500\", \"statusCode\": \"500\"}");
         ExecutionException e = assertThrows(ExecutionException.class,
-                () -> httpClient.sendRequest(request, SubscribeResult.class, sr -> {
-                    return false;
-                }, null));
+                () -> httpClient.sendRequest(request, SubscribeResult.class, sr -> false, null));
         String actualMessage = e.getMessage();
         assertTrue(actualMessage.contains(
                 "Received invalid content for type org.openhab.binding.boschshc.internal.devices.bridge.dto.SubscribeResult:"));
@@ -257,9 +253,7 @@ class BoschHttpClientTest {
         when(response.getStatus()).thenReturn(200);
         when(response.getContentAsString()).thenReturn("{\"@type\": \"JsonRestExceptionResponseEntity}");
         ExecutionException e = assertThrows(ExecutionException.class,
-                () -> httpClient.sendRequest(request, SubscribeResult.class, sr -> {
-                    return false;
-                }, null));
+                () -> httpClient.sendRequest(request, SubscribeResult.class, sr -> false, null));
         assertEquals(
                 "Received invalid content in response, expected type org.openhab.binding.boschshc.internal.devices.bridge.dto.SubscribeResult: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 44 path $.@type",
                 e.getMessage());
index a6be12174ecba3f9c392b4cd7ac64bcecea9b3c9..bd71f83b376fcd6585023da984037e4fe8a3f8cb 100644 (file)
@@ -159,14 +159,21 @@ class BridgeHandlerTest {
         Request devicesRequest = mock(Request.class);
         ContentResponse devicesResponse = mock(ContentResponse.class);
         when(devicesResponse.getStatus()).thenReturn(200);
-        when(devicesResponse.getContentAsString()).thenReturn("[{\"@type\":\"device\",\r\n"
-                + " \"rootDeviceId\":\"64-da-a0-02-14-9b\",\r\n"
-                + " \"id\":\"hdm:HomeMaticIP:3014F711A00004953859F31B\",\r\n"
-                + " \"deviceServiceIds\":[\"PowerMeter\",\"PowerSwitch\",\"PowerSwitchProgram\",\"Routing\"],\r\n"
-                + " \"manufacturer\":\"BOSCH\",\r\n" + " \"roomId\":\"hz_3\",\r\n" + " \"deviceModel\":\"PSM\",\r\n"
-                + " \"serial\":\"3014F711A00004953859F31B\",\r\n" + " \"profile\":\"GENERIC\",\r\n"
-                + " \"name\":\"Coffee Machine\",\r\n" + " \"status\":\"AVAILABLE\",\r\n" + " \"childDeviceIds\":[]\r\n"
-                + " }]");
+        when(devicesResponse.getContentAsString()).thenReturn("""
+                [{"@type":"device",
+                 "rootDeviceId":"64-da-a0-02-14-9b",
+                 "id":"hdm:HomeMaticIP:3014F711A00004953859F31B",
+                 "deviceServiceIds":["PowerMeter","PowerSwitch","PowerSwitchProgram","Routing"],
+                 "manufacturer":"BOSCH",
+                 "roomId":"hz_3",
+                 "deviceModel":"PSM",
+                 "serial":"3014F711A00004953859F31B",
+                 "profile":"GENERIC",
+                 "name":"Coffee Machine",
+                 "status":"AVAILABLE",
+                 "childDeviceIds":[]
+                 }]\
+                """);
         when(devicesRequest.send()).thenReturn(devicesResponse);
         when(httpClient.createRequest(contains("/devices"), same(HttpMethod.GET))).thenReturn(devicesRequest);
 
@@ -175,7 +182,7 @@ class BridgeHandlerTest {
 
         Request longPollRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/longPoll")))).thenReturn(longPollRequest);
+                argThat((JsonRpcRequest r) -> "RE/longPoll".equals(r.method)))).thenReturn(longPollRequest);
 
         fixture.initialAccess(httpClient);
         verify(thingHandlerCallback).statusUpdated(any(),
@@ -190,18 +197,37 @@ class BridgeHandlerTest {
         when(request.header(anyString(), anyString())).thenReturn(request);
         ContentResponse response = mock(ContentResponse.class);
         when(response.getStatus()).thenReturn(200);
-        when(response.getContentAsString()).thenReturn("{\r\n" + "     \"@type\": \"systemState\",\r\n"
-                + "     \"systemAvailability\": {\r\n" + "         \"@type\": \"systemAvailabilityState\",\r\n"
-                + "         \"available\": true,\r\n" + "         \"deleted\": false\r\n" + "     },\r\n"
-                + "     \"armingState\": {\r\n" + "         \"@type\": \"armingState\",\r\n"
-                + "         \"state\": \"SYSTEM_DISARMED\",\r\n" + "         \"deleted\": false\r\n" + "     },\r\n"
-                + "     \"alarmState\": {\r\n" + "         \"@type\": \"alarmState\",\r\n"
-                + "         \"value\": \"ALARM_OFF\",\r\n" + "         \"incidents\": [],\r\n"
-                + "         \"deleted\": false\r\n" + "     },\r\n" + "     \"activeConfigurationProfile\": {\r\n"
-                + "         \"@type\": \"activeConfigurationProfile\",\r\n" + "         \"deleted\": false\r\n"
-                + "     },\r\n" + "     \"securityGapState\": {\r\n" + "         \"@type\": \"securityGapState\",\r\n"
-                + "         \"securityGaps\": [],\r\n" + "         \"deleted\": false\r\n" + "     },\r\n"
-                + "     \"deleted\": false\r\n" + " }");
+        when(response.getContentAsString()).thenReturn("""
+                {
+                     "@type": "systemState",
+                     "systemAvailability": {
+                         "@type": "systemAvailabilityState",
+                         "available": true,
+                         "deleted": false
+                     },
+                     "armingState": {
+                         "@type": "armingState",
+                         "state": "SYSTEM_DISARMED",
+                         "deleted": false
+                     },
+                     "alarmState": {
+                         "@type": "alarmState",
+                         "value": "ALARM_OFF",
+                         "incidents": [],
+                         "deleted": false
+                     },
+                     "activeConfigurationProfile": {
+                         "@type": "activeConfigurationProfile",
+                         "deleted": false
+                     },
+                     "securityGapState": {
+                         "@type": "securityGapState",
+                         "securityGaps": [],
+                         "deleted": false
+                     },
+                     "deleted": false
+                 }\
+                """);
         when(request.send()).thenReturn(response);
         when(httpClient.createRequest(anyString(), same(HttpMethod.GET))).thenReturn(request);
 
@@ -302,12 +328,22 @@ class BridgeHandlerTest {
         when(request.header(anyString(), anyString())).thenReturn(request);
         ContentResponse response = mock(ContentResponse.class);
         when(response.getStatus()).thenReturn(200);
-        when(response.getContentAsString()).thenReturn("{ \n" + "    \"@type\":\"DeviceServiceData\",\n"
-                + "    \"path\":\"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel\",\n"
-                + "    \"id\":\"BatteryLevel\",\n" + "    \"deviceId\":\"hdm:ZigBee:000d6f0004b93361\",\n"
-                + "    \"faults\":{ \n" + "        \"entries\":[\n" + "          {\n"
-                + "            \"type\":\"LOW_BATTERY\",\n" + "            \"category\":\"WARNING\"\n" + "          }\n"
-                + "        ]\n" + "    }\n" + "}");
+        when(response.getContentAsString()).thenReturn("""
+                {
+                    "@type":"DeviceServiceData",
+                    "path":"/devices/hdm:ZigBee:000d6f0004b93361/services/BatteryLevel",
+                    "id":"BatteryLevel",
+                    "deviceId":"hdm:ZigBee:000d6f0004b93361",
+                    "faults":{\s
+                        "entries":[
+                          {
+                            "type":"LOW_BATTERY",
+                            "category":"WARNING"
+                          }
+                        ]
+                    }
+                }\
+                """);
         when(request.send()).thenReturn(response);
         when(httpClient.createRequest(anyString(), same(HttpMethod.GET))).thenReturn(request);
 
index b6c2dc837a3a7e36f4029a563ad77bdda63a95ff..33035a95b08afae9885c6d659946bfb9de573498 100644 (file)
@@ -210,13 +210,13 @@ class LongPollingTest {
 
         Request subscribeRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/subscribe")))).thenReturn(subscribeRequest);
+                argThat((JsonRpcRequest r) -> "RE/subscribe".equals(r.method)))).thenReturn(subscribeRequest);
         SubscribeResult subscribeResult = new SubscribeResult();
         when(httpClient.sendRequest(any(), same(SubscribeResult.class), any(), any())).thenReturn(subscribeResult);
 
         Request longPollRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/longPoll")))).thenReturn(longPollRequest);
+                argThat((JsonRpcRequest r) -> "RE/longPoll".equals(r.method)))).thenReturn(longPollRequest);
 
         fixture.start(httpClient);
 
@@ -268,7 +268,7 @@ class LongPollingTest {
 
         Request longPollRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/longPoll")))).thenReturn(longPollRequest);
+                argThat((JsonRpcRequest r) -> "RE/longPoll".equals(r.method)))).thenReturn(longPollRequest);
 
         fixture.start(httpClient);
 
@@ -296,13 +296,13 @@ class LongPollingTest {
 
         Request subscribeRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/subscribe")))).thenReturn(subscribeRequest);
+                argThat((JsonRpcRequest r) -> "RE/subscribe".equals(r.method)))).thenReturn(subscribeRequest);
         SubscribeResult subscribeResult = new SubscribeResult();
         when(httpClient.sendRequest(any(), same(SubscribeResult.class), any(), any())).thenReturn(subscribeResult);
 
         Request longPollRequest = mock(Request.class);
         when(httpClient.createRequest(anyString(), same(HttpMethod.POST),
-                argThat((JsonRpcRequest r) -> r.method.equals("RE/longPoll")))).thenReturn(longPollRequest);
+                argThat((JsonRpcRequest r) -> "RE/longPoll".equals(r.method)))).thenReturn(longPollRequest);
 
         fixture.start(httpClient);
 
index c8ced460d79aec55baba04aa267a8e2eea310282..05911dd539ec062c7613afdae28188eda6559a16 100644 (file)
@@ -78,8 +78,12 @@ class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Climat
 
     @Test
     void testUpdateChannelsTemperatureLevelService() {
-        JsonElement jsonObject = JsonParser.parseString(
-                "{\n" + "   \"@type\": \"temperatureLevelState\",\n" + "   \"temperature\": 21.5\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "temperatureLevelState",
+                   "temperature": 21.5
+                 }\
+                """);
         getFixture().processUpdate("TemperatureLevel", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
@@ -88,8 +92,12 @@ class ClimateControlHandlerTest extends AbstractBoschSHCDeviceHandlerTest<Climat
 
     @Test
     void testUpdateChannelsRoomClimateControlService() {
-        JsonElement jsonObject = JsonParser.parseString(
-                "{\n" + "   \"@type\": \"climateControlState\",\n" + "   \"setpointTemperature\": 21.5\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "climateControlState",
+                   "setpointTemperature": 21.5
+                 }\
+                """);
         getFixture().processUpdate("RoomClimateControl", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_SETPOINT_TEMPERATURE),
index 3b97c5ac1364ab16263aec612f8d4485c135dec9..5f69b925ebf5af34bfa0e4c929919260f416f447 100644 (file)
@@ -80,18 +80,37 @@ class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<Intrusio
 
     @Test
     void testUpdateChannelsIntrusionDetectionSystemState() {
-        JsonElement jsonObject = JsonParser.parseString("{\n" + "     \"@type\": \"systemState\",\n"
-                + "     \"systemAvailability\": {\n" + "         \"@type\": \"systemAvailabilityState\",\n"
-                + "         \"available\": true,\n" + "         \"deleted\": false\n" + "     },\n"
-                + "     \"armingState\": {\n" + "         \"@type\": \"armingState\",\n"
-                + "         \"state\": \"SYSTEM_DISARMED\",\n" + "         \"deleted\": false\n" + "     },\n"
-                + "     \"alarmState\": {\n" + "         \"@type\": \"alarmState\",\n"
-                + "         \"value\": \"ALARM_OFF\",\n" + "         \"incidents\": [],\n"
-                + "         \"deleted\": false\n" + "     },\n" + "     \"activeConfigurationProfile\": {\n"
-                + "         \"@type\": \"activeConfigurationProfile\",\n" + "         \"deleted\": false\n"
-                + "     },\n" + "     \"securityGapState\": {\n" + "         \"@type\": \"securityGapState\",\n"
-                + "         \"securityGaps\": [],\n" + "         \"deleted\": false\n" + "     },\n"
-                + "     \"deleted\": false\n" + " }\n");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                     "@type": "systemState",
+                     "systemAvailability": {
+                         "@type": "systemAvailabilityState",
+                         "available": true,
+                         "deleted": false
+                     },
+                     "armingState": {
+                         "@type": "armingState",
+                         "state": "SYSTEM_DISARMED",
+                         "deleted": false
+                     },
+                     "alarmState": {
+                         "@type": "alarmState",
+                         "value": "ALARM_OFF",
+                         "incidents": [],
+                         "deleted": false
+                     },
+                     "activeConfigurationProfile": {
+                         "@type": "activeConfigurationProfile",
+                         "deleted": false
+                     },
+                     "securityGapState": {
+                         "@type": "securityGapState",
+                         "securityGaps": [],
+                         "deleted": false
+                     },
+                     "deleted": false
+                 }
+                """);
         getFixture().processUpdate(BoschSHCBindingConstants.SERVICE_INTRUSION_DETECTION, jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_SYSTEM_AVAILABILITY),
@@ -109,15 +128,35 @@ class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<Intrusio
 
     @Test
     void testUpdateChannelsIntrusionDetectionControlState() {
-        JsonElement jsonObject = JsonParser.parseString("{\n" + "   \"@type\": \"intrusionDetectionControlState\",\n"
-                + "   \"activeProfile\": \"0\",\n" + "   \"alarmActivationDelayTime\": 30,\n" + "   \"actuators\": [\n"
-                + "     {\n" + "       \"readonly\": false,\n" + "       \"active\": true,\n"
-                + "       \"id\": \"intrusion:video\"\n" + "     },\n" + "     {\n" + "       \"readonly\": false,\n"
-                + "       \"active\": false,\n" + "       \"id\": \"intrusion:siren\"\n" + "     }\n" + "   ],\n"
-                + "   \"remainingTimeUntilArmed\": 29559,\n" + "   \"armActivationDelayTime\": 30,\n"
-                + "   \"triggers\": [\n" + "     {\n" + "       \"readonly\": false,\n" + "       \"active\": true,\n"
-                + "       \"id\": \"hdm:ZigBee:000d6f0012f02378\"\n" + "     }\n" + "   ],\n"
-                + "   \"value\": \"SYSTEM_ARMING\"\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "intrusionDetectionControlState",
+                   "activeProfile": "0",
+                   "alarmActivationDelayTime": 30,
+                   "actuators": [
+                     {
+                       "readonly": false,
+                       "active": true,
+                       "id": "intrusion:video"
+                     },
+                     {
+                       "readonly": false,
+                       "active": false,
+                       "id": "intrusion:siren"
+                     }
+                   ],
+                   "remainingTimeUntilArmed": 29559,
+                   "armActivationDelayTime": 30,
+                   "triggers": [
+                     {
+                       "readonly": false,
+                       "active": true,
+                       "id": "hdm:ZigBee:000d6f0012f02378"
+                     }
+                   ],
+                   "value": "SYSTEM_ARMING"
+                 }\
+                """);
         getFixture().processUpdate("IntrusionDetectionControl", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_ARMING_STATE),
@@ -126,11 +165,22 @@ class IntrusionDetectionHandlerTest extends AbstractBoschSHCHandlerTest<Intrusio
 
     @Test
     void testUpdateChannelsSurveillanceAlarmState() {
-        JsonElement jsonObject = JsonParser.parseString("{\n" + "   \"@type\": \"surveillanceAlarmState\",\n"
-                + "   \"incidents\": [\n" + "     {\n" + "       \"triggerName\": \"Motion Detector\",\n"
-                + "       \"locationId\": \"hz_5\",\n" + "       \"location\": \"Living Room\",\n"
-                + "       \"id\": \"hdm:ZigBee:000d6f0012f02342\",\n" + "       \"time\": 1652615755336,\n"
-                + "       \"type\": \"INTRUSION\"\n" + "     }\n" + "   ],\n" + "   \"value\": \"ALARM_ON\"\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "surveillanceAlarmState",
+                   "incidents": [
+                     {
+                       "triggerName": "Motion Detector",
+                       "locationId": "hz_5",
+                       "location": "Living Room",
+                       "id": "hdm:ZigBee:000d6f0012f02342",
+                       "time": 1652615755336,
+                       "type": "INTRUSION"
+                     }
+                   ],
+                   "value": "ALARM_ON"
+                 }\
+                """);
         getFixture().processUpdate("SurveillanceAlarm", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_ALARM_STATE),
index 0e89f266fb188d459eadfe7027c0074f7f65889d..2f90424a219dc5a539fa54358a54a13ea0ac928d 100644 (file)
@@ -51,8 +51,12 @@ class MotionDetectorHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<
 
     @Test
     void testUpdateChannelsLatestMotionService() {
-        JsonElement jsonObject = JsonParser.parseString("{\n" + "   \"@type\": \"latestMotionState\",\n"
-                + "   \"latestMotionDetected\": \"2020-04-03T19:02:19.054Z\"\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "latestMotionState",
+                   "latestMotionDetected": "2020-04-03T19:02:19.054Z"
+                 }\
+                """);
         getFixture().processUpdate("LatestMotion", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_LATEST_MOTION),
index 45dde9f0fe38cda9f044adcdbe394e14d79c4043..515b07ebf9d81177d3b7635df8c86e403fee08a4 100644 (file)
@@ -132,9 +132,15 @@ class SmartBulbHandlerTest extends AbstractBoschSHCDeviceHandlerTest<SmartBulbHa
 
     @Test
     void testUpdateChannelHSBColorActuatorState() {
-        JsonElement jsonObject = JsonParser.parseString("{\"colorTemperatureRange\": {\n" + "        \"minCt\": 153,\n"
-                + "        \"maxCt\": 526\n" + "    },\n" + "    \"@type\": \"colorState\",\n"
-                + "    \"gamut\": \"LEDVANCE_GAMUT_A\",\n" + "    \"rgb\": -12427}");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {"colorTemperatureRange": {
+                        "minCt": 153,
+                        "maxCt": 526
+                    },
+                    "@type": "colorState",
+                    "gamut": "LEDVANCE_GAMUT_A",
+                    "rgb": -12427}\
+                """);
         getFixture().processUpdate("HSBColorActuator", jsonObject);
         verify(getCallback()).stateUpdated(new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_COLOR),
                 HSBType.fromRGB(255, 207, 117));
index 2430b9ea1b56efb3a3748c2a279ba1c35c35353b..35a21e546b82e4339da47031d17cad24abe31f29 100644 (file)
@@ -121,8 +121,12 @@ class ThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<Ther
 
     @Test
     void testUpdateChannelsTemperatureLevelService() {
-        JsonElement jsonObject = JsonParser.parseString(
-                "{\n" + "   \"@type\": \"temperatureLevelState\",\n" + "   \"temperature\": 21.5\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "temperatureLevelState",
+                   "temperature": 21.5
+                 }\
+                """);
         getFixture().processUpdate("TemperatureLevel", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
index 5af5e511584d59ee60c68e6d86a93a9668bb945e..7fd8d05a9876d7f7b3cdd68e56df7df8c05e6021 100644 (file)
@@ -58,8 +58,10 @@ class TwinguardHandlerTest extends AbstractSmokeDetectorHandlerTest<TwinguardHan
     @Test
     void testUpdateChannelsAirQualityLevelService() {
         JsonElement jsonObject = JsonParser.parseString(
-                "{\"temperatureRating\":\"GOOD\",\"humidityRating\":\"MEDIUM\",\"purity\":620,\"@type\":\"airQualityLevelState\",\n"
-                        + "     \"purityRating\":\"GOOD\",\"temperature\":23.77,\"description\":\"LITTLE_DRY\",\"humidity\":32.69,\"combinedRating\":\"MEDIUM\"}");
+                """
+                        {"temperatureRating":"GOOD","humidityRating":"MEDIUM","purity":620,"@type":"airQualityLevelState",
+                             "purityRating":"GOOD","temperature":23.77,"description":"LITTLE_DRY","humidity":32.69,"combinedRating":"MEDIUM"}\
+                        """);
         getFixture().processUpdate("AirQualityLevel", jsonObject);
 
         verify(getCallback()).stateUpdated(
index e09860bb166d7e62df90e5d47ef96474b781e005..15ab0fe027fe847af7df237d8a40092d63fbfc2e 100644 (file)
@@ -56,8 +56,12 @@ class WallThermostatHandlerTest extends AbstractBatteryPoweredDeviceHandlerTest<
 
     @Test
     void testUpdateChannelsTemperatureLevelService() {
-        JsonElement jsonObject = JsonParser.parseString(
-                "{\n" + "   \"@type\": \"temperatureLevelState\",\n" + "   \"temperature\": 21.5\n" + " }");
+        JsonElement jsonObject = JsonParser.parseString("""
+                {
+                   "@type": "temperatureLevelState",
+                   "temperature": 21.5
+                 }\
+                """);
         getFixture().processUpdate("TemperatureLevel", jsonObject);
         verify(getCallback()).stateUpdated(
                 new ChannelUID(getThing().getUID(), BoschSHCBindingConstants.CHANNEL_TEMPERATURE),
index 3f4fe0c8334e79d956b08aecbfac11aece8a9a3e..6654440c7249be8deab6656beccacf664186ac46 100644 (file)
@@ -86,13 +86,35 @@ class IntrusionDetectionControlStateServiceTest {
 
     @Test
     void onStateUpdate() {
-        final String json = "{\n" + "\"@type\": \"intrusionDetectionControlState\",\n" + "\"activeProfile\": \"0\",\n"
-                + "\"alarmActivationDelayTime\": 30,\n" + "\"actuators\": [\n" + "{\n" + "\"readonly\": false,\n"
-                + "\"active\": true,\n" + "\"id\": \"intrusion:video\"\n" + "},\n" + "{\n" + "\"readonly\": false,\n"
-                + "\"active\": false,\n" + "\"id\": \"intrusion:siren\"\n" + "}\n" + "],\n"
-                + "\"remainingTimeUntilArmed\": 28959,\n" + "\"armActivationDelayTime\": 30,\n" + "\"triggers\": [\n"
-                + "{\n" + "\"readonly\": false,\n" + "\"active\": true,\n" + "\"id\": \"hdm:ZigBee:000d6f0422f42378\"\n"
-                + "}\n" + "],\n" + "\"value\": \"SYSTEM_ARMING\"\n" + "}";
+        final String json = """
+                {
+                    "@type":"intrusionDetectionControlState",
+                    "activeProfile":"0",
+                    "alarmActivationDelayTime":30,
+                    "actuators":[
+                        {
+                            "readonly":false,
+                            "active":true,
+                            "id":"intrusion:video"
+                        },
+                        {
+                            "readonly":false,
+                            "active":false,
+                            "id":"intrusion:siren"
+                        }
+                    ],
+                    "remainingTimeUntilArmed":28959,
+                    "armActivationDelayTime":30,
+                    "triggers":[
+                        {
+                            "readonly":false,
+                            "active":true,
+                            "id":"hdm:ZigBee:000d6f0422f42378"
+                        }
+                    ],
+                    "value":"SYSTEM_ARMING"
+                }\
+                """;
         JsonElement jsonElement = JsonParser.parseString(json);
         fixture.onStateUpdate(jsonElement);
         verify(consumer).accept(any());
index 7476af3ee7477ea417e57c2be1a87287761b4b33..d34866eed1183913750683a91eb8da336a0da11c 100644 (file)
@@ -53,9 +53,7 @@ public class BoseSoundTouchHandlerFactory extends BaseThingHandlerFactory {
                     ContentItem.class.getClassLoader());
             BoseStateDescriptionOptionProvider localDescriptionOptionProvider = stateOptionProvider;
             if (localDescriptionOptionProvider != null) {
-                BoseSoundTouchHandler handler = new BoseSoundTouchHandler(thing, new PresetContainer(storage),
-                        localDescriptionOptionProvider);
-                return handler;
+                return new BoseSoundTouchHandler(thing, new PresetContainer(storage), localDescriptionOptionProvider);
             }
         }
         return null;
index d219a7887734d91ae1cab9ce9cc246e9c9a3bad5..f8f31e61dc59913c798fc0b1149eb506f50df52d 100644 (file)
@@ -79,8 +79,7 @@ public class ContentItem {
      */
     @Override
     public boolean equals(@Nullable Object obj) {
-        if (obj instanceof ContentItem) {
-            ContentItem other = (ContentItem) obj;
+        if (obj instanceof ContentItem other) {
             return Objects.equals(other.source, this.source) || Objects.equals(other.sourceAccount, this.sourceAccount)
                     || other.presetable == this.presetable || Objects.equals(other.location, this.location)
                     || Objects.equals(other.itemName, this.itemName);
@@ -188,11 +187,11 @@ public class ContentItem {
      * ' - &apos;
      */
     private 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;
     }
 
@@ -251,7 +250,7 @@ public class ContentItem {
     }
 
     public StateOption toStateOption() {
-        String stateOptionLabel = String.valueOf(presetID) + ": " + itemName;
+        String stateOptionLabel = presetID + ": " + itemName;
         return new StateOption(String.valueOf(presetID), stateOptionLabel);
     }
 
index cf8b69fe5284e37cb4dd77f29c906df43eaf4c1b..714003afc165e9158281864c01660f28b23b7907 100644 (file)
@@ -90,7 +90,7 @@ public class BroadlinkDiscoveryService extends AbstractDiscoveryService {
                     Integer.toHexString(dev.getDeviceType()), dev.getHost(), dev.getMac());
 
             ThingUID thingUID;
-            String id = dev.getHost().replaceAll("\\.", "-");
+            String id = dev.getHost().replace(".", "-");
             logger.debug("Device ID with IP address replacement: {}", id);
             try {
                 id = getHostnameWithoutDomain(InetAddress.getByName(dev.getHost()).getHostName());
@@ -187,11 +187,11 @@ public class BroadlinkDiscoveryService extends AbstractDiscoveryService {
         if (hostname.matches(broadlinkRegex)) {
             String[] dotSeparatedString = hostname.split("\\.");
             logger.debug("Found original broadlink DNS name {}, removing domain", hostname);
-            return dotSeparatedString[0].replaceAll("\\.", "-");
+            return dotSeparatedString[0].replace(".", "-");
         } else {
             logger.debug("DNS name does not match original broadlink name: {}, using it without modification. ",
                     hostname);
-            return hostname.replaceAll("\\.", "-");
+            return hostname.replace(".", "-");
         }
     }
 }
index 26e261ec545465370e07b6468c4b8ace578382ac..644395b0a2dc9e706a100dc4c1e2fbd78c59e90b 100644 (file)
@@ -159,9 +159,9 @@ public class FloureonThermostatHandler extends BroadlinkBaseHandler {
 
     private void handleSetpointCommand(ChannelUID channelUID, Command command) {
         FloureonDevice floureonDevice = this.floureonDevice;
-        if (command instanceof QuantityType && floureonDevice != null) {
+        if (command instanceof QuantityType quantityCommand && floureonDevice != null) {
             try {
-                QuantityType<?> temperatureQuantityType = ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS);
+                QuantityType<?> temperatureQuantityType = quantityCommand.toUnit(SIUnits.CELSIUS);
                 if (temperatureQuantityType != null) {
                     floureonDevice.setThermostatTemp(temperatureQuantityType.doubleValue());
                 } else {
@@ -211,8 +211,8 @@ public class FloureonThermostatHandler extends BroadlinkBaseHandler {
     }
 
     private void handleSetTimeCommand(ChannelUID channelUID, Command command) {
-        if (command instanceof DateTimeType) {
-            ZonedDateTime zonedDateTime = ((DateTimeType) command).getZonedDateTime();
+        if (command instanceof DateTimeType dateTimeCommand) {
+            ZonedDateTime zonedDateTime = dateTimeCommand.getZonedDateTime();
             try {
                 new SetTimeCommand(tob(zonedDateTime.getHour()), tob(zonedDateTime.getMinute()),
                         tob(zonedDateTime.getSecond()), tob(zonedDateTime.getDayOfWeek().getValue()))
index c54280b80198626e7216131f8f9670295336c597..f4dcbfd0fee94cc3502f0f346cc063a2421de01f 100644 (file)
@@ -71,8 +71,8 @@ public abstract class BsbLanBaseThingHandler extends BaseThingHandler {
                 return null;
             }
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof BsbLanBridgeHandler) {
-                this.bridgeHandler = (BsbLanBridgeHandler) handler;
+            if (handler instanceof BsbLanBridgeHandler lanBridgeHandler) {
+                this.bridgeHandler = lanBridgeHandler;
             }
         }
         return this.bridgeHandler;
index fa48aa7c8e3a76dc18a959ffcf21590a8786d725..c1bd31c32a3cb12da216325760289778f513c3c8 100644 (file)
@@ -106,7 +106,7 @@ public class BsbLanParameterConverter {
 
     private static State getStateForSwitchValueChannel(BsbLanApiParameterDTO parameter) {
         // treat "0" as OFF and everything else as ON
-        return parameter.value.equals("0") ? OnOffType.OFF : OnOffType.ON;
+        return "0".equals(parameter.value) ? OnOffType.OFF : OnOffType.ON;
     }
 
     /**
@@ -134,9 +134,7 @@ public class BsbLanParameterConverter {
     }
 
     private static @Nullable String getValueForNumberValueChannel(Command command) {
-        if (command instanceof QuantityType<?>) {
-            // the target unit is yet unknown, so just use the value as is (without converting based on the unit)
-            QuantityType<?> quantity = (QuantityType<?>) command;
+        if (command instanceof QuantityType<?> quantity) {
             return String.valueOf(quantity.doubleValue());
         }
         // check if numeric
index ab0eaeb961fd7fb31ac16420b1f3ba895c64e804..49afff39f6dd62dbc8b72a9cc09d89268ef180d1 100644 (file)
@@ -35,8 +35,17 @@ public class BsbLanApiContentConverterTests {
 
     @Test
     public void parseBsbLanApiParameterQueryResponse() {
-        String content = "{\r\n" + "\"700\": {\r\n" + "\"name\": \"Betriebsart\",\r\n" + "\"value\": \"0\",\r\n"
-                + "\"unit\": \"\",\r\n" + "\"desc\": \"Schutzbetrieb\",\r\n" + "\"dataType\": 1\r\n" + "}\r\n" + "}";
+        String content = """
+                {
+                "700": {
+                "name": "Betriebsart",
+                "value": "0",
+                "unit": "",
+                "desc": "Schutzbetrieb",
+                "dataType": 1
+                }
+                }\
+                """;
 
         BsbLanApiParameterQueryResponseDTO r = BsbLanApiContentConverter.fromJson(content,
                 BsbLanApiParameterQueryResponseDTO.class);
index 479051f7bf4c8c0fb51aaec646b56e9a1697f081..6532aee7babca8f25869a99c81dab1a1e8101669 100644 (file)
@@ -128,8 +128,8 @@ public class SmartherApiConnector {
         } catch (ExecutionException e) {
             final Throwable cause = e.getCause();
 
-            if (cause instanceof SmartherGatewayException) {
-                throw (SmartherGatewayException) cause;
+            if (cause instanceof SmartherGatewayException gatewayException) {
+                throw gatewayException;
             } else {
                 throw new SmartherGatewayException(e.getMessage(), e);
             }
index b8a9ac89efd5025a597213cf4d65b99d19b8e797..fb9c1e2bb6056b519c959fdc83aa914a91a5aa1c 100644 (file)
@@ -173,7 +173,7 @@ public class Location {
         if (locations == null || locations.isEmpty()) {
             return null;
         }
-        return locations.stream().map(a -> String.valueOf(a.getName())).collect(Collectors.joining(NAME_SEPARATOR));
+        return locations.stream().map(a -> a.getName()).collect(Collectors.joining(NAME_SEPARATOR));
     }
 
     @Override
index 1d6d57554506266a58ba6896e6d21cda0132dca7..20448e04af143b2007f4fb56c4f61dbcfe0e2191 100644 (file)
@@ -50,6 +50,6 @@ public class Modules {
         if (modules == null || modules.isEmpty()) {
             return null;
         }
-        return modules.stream().map(a -> String.valueOf(a.getName())).collect(Collectors.joining(NAME_SEPARATOR));
+        return modules.stream().map(a -> a.getName()).collect(Collectors.joining(NAME_SEPARATOR));
     }
 }
index 9bde70ba1686ee30d233e9021961d7c946b056f5..87bbc52ab8817f5b9786ae612b669c509ad527f8 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.bticinosmarther.internal.discovery;
 
 import static org.openhab.binding.bticinosmarther.internal.SmartherBindingConstants.*;
 
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -47,7 +46,7 @@ public class SmartherModuleDiscoveryService extends AbstractDiscoveryService
         implements DiscoveryService, ThingHandlerService {
 
     // Only modules can be discovered. A bridge must be manually added.
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_MODULE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_MODULE);
 
     private static final int DISCOVERY_TIME_SECONDS = 30;
 
@@ -86,8 +85,7 @@ public class SmartherModuleDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof SmartherAccountHandler) {
-            final SmartherAccountHandler localBridgeHandler = (SmartherAccountHandler) handler;
+        if (handler instanceof SmartherAccountHandler localBridgeHandler) {
             this.bridgeHandler = localBridgeHandler;
             this.bridgeUID = localBridgeHandler.getUID();
         }
index ab88c78fd3438c0cfc8d602bdc224293a25328fb..cf1971e4de75fb606efb61c7c8fe425bd5a5759f 100644 (file)
@@ -90,8 +90,8 @@ public class SmartherHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected synchronized void removeHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof SmartherBridgeHandler) {
-            authService.removeSmartherAccountHandler((SmartherBridgeHandler) thingHandler);
+        if (thingHandler instanceof SmartherBridgeHandler bridgeHandler) {
+            authService.removeSmartherAccountHandler(bridgeHandler);
         }
     }
 }
index 884f90ac13a249e5e84b48978d73b6bbbf24aa6e..75952397ee321dcc1064bd131a37491f32c89c93 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -121,7 +122,7 @@ public class SmartherBridgeHandler extends BaseBridgeHandler
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(SmartherModuleDiscoveryService.class);
+        return Set.of(SmartherModuleDiscoveryService.class);
     }
 
     // ===========================================================================
index 0ae5cd4c0c0aecd5a2b3fb371508cc11330c3879..13ae557b6ffe551936d22af4a806ae7e24d73093 100644 (file)
@@ -222,14 +222,14 @@ public class SmartherModuleHandler extends BaseThingHandler {
                 }
                 break;
             case CHANNEL_SETTINGS_PROGRAM:
-                if (command instanceof DecimalType) {
-                    localModuleSettings.setProgram(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    localModuleSettings.setProgram(decimalCommand.intValue());
                     return;
                 }
                 break;
             case CHANNEL_SETTINGS_BOOSTTIME:
-                if (command instanceof DecimalType) {
-                    localModuleSettings.setBoostTime(BoostTime.fromValue(((DecimalType) command).intValue()));
+                if (command instanceof DecimalType decimalCommand) {
+                    localModuleSettings.setBoostTime(BoostTime.fromValue(decimalCommand.intValue()));
                     return;
                 }
                 break;
@@ -324,8 +324,8 @@ public class SmartherModuleHandler extends BaseThingHandler {
      * @return {@code true} if the change succeeded, {@code false} otherwise
      */
     private boolean changeTimeHour(Command command, final ModuleSettings settings) {
-        if (command instanceof DecimalType) {
-            int endHour = ((DecimalType) command).intValue();
+        if (command instanceof DecimalType decimalCommand) {
+            int endHour = decimalCommand.intValue();
             if (endHour >= 0 && endHour <= 23) {
                 settings.setEndHour(endHour);
                 return true;
@@ -344,8 +344,8 @@ public class SmartherModuleHandler extends BaseThingHandler {
      * @return {@code true} if the change succeeded, {@code false} otherwise
      */
     private boolean changeTimeMinute(Command command, final ModuleSettings settings) {
-        if (command instanceof DecimalType) {
-            int endMinute = ((DecimalType) command).intValue();
+        if (command instanceof DecimalType decimalCommand) {
+            int endMinute = decimalCommand.intValue();
             if (endMinute >= 0 && endMinute <= 59) {
                 // Only 15 min increments are allowed
                 endMinute = Math.round(endMinute / 15) * 15;
index 320b674d2ac47824a6ab8e704e71d6c587614d10..64c1929b06a692a31c6aac619dd2dc0c5bf36a61 100644 (file)
@@ -55,7 +55,7 @@ public final class StringUtil {
      * @return the passed in string, or the empty string if it was {@code null}
      *
      */
-    public static final String defaultString(@Nullable String str) {
+    public static String defaultString(@Nullable String str) {
         return (str == null) ? "" : str;
     }
 
index 02a689e2a9f662b430153cb38339d51a2ec54890..740a994c743888375ed9f12bb70b93a3171cbaa7 100644 (file)
@@ -126,7 +126,7 @@ public class BuienradarHandler extends BaseThingHandler {
         }
         try {
             final Optional<List<Prediction>> predictionsOpt = client.getPredictions(location);
-            if (!predictionsOpt.isPresent()) {
+            if (predictionsOpt.isEmpty()) {
                 // Did not get a result, retry the retrieval.
                 // Buienradar is not a very stable source and returns nothing quite regular
                 if (tries <= 2) {
index 8db4e35df785e6d0058666a3ec8fae607f94ef9d..52522568e3736ed351338b19f6eb40619968edc7 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.buienradar.internal;
 
 import static org.openhab.binding.buienradar.internal.BuienradarBindingConstants.THING_TYPE_RAIN_FORECAST;
 
-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.buienradar", service = ThingHandlerFactory.class)
 public class BuienradarHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RAIN_FORECAST);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RAIN_FORECAST);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index a406fc1c8d64aac1c8aa62116bd2bbb56daf3892..44eb5f2c44cffa3bef006f7b7a50abb9c5b53824 100644 (file)
@@ -23,5 +23,5 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 public enum CaddxMessageContext {
     NONE,
     DISCOVERY,
-    COMMAND;
+    COMMAND
 }
index 83715bdf609f453227b40314b44e8b8e620092cf..8571a178fcabed038b89bd02cb26c9229fd7b833 100644 (file)
@@ -38,8 +38,8 @@ public class CaddxBridgeActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof CaddxBridgeHandler) {
-            this.handler = (CaddxBridgeHandler) handler;
+        if (handler instanceof CaddxBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
         }
     }
 
index 0715148762377d49dff11a93308bb9d0944bee39..38d3fd8e977491e575709ad20c5a92878d52bf67 100644 (file)
@@ -43,8 +43,8 @@ public class CaddxKeypadActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ThingHandlerKeypad) {
-            this.handler = (ThingHandlerKeypad) handler;
+        if (handler instanceof ThingHandlerKeypad keypadHandler) {
+            this.handler = keypadHandler;
         }
     }
 
index c377d2f6fd0ffb932d94f7ba8eb2ecc2cf8659f1..1e447e8f0471eb3a47468bb9024a0a0488b2c077 100644 (file)
@@ -42,8 +42,8 @@ public class CaddxPanelActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ThingHandlerPanel) {
-            this.handler = (ThingHandlerPanel) handler;
+        if (handler instanceof ThingHandlerPanel panelHandler) {
+            this.handler = panelHandler;
         }
     }
 
index d8d4ba780eee59efb9ea0c76b9d4672c4585a9fb..fb1c48d96a2bd4dc3cea3e0468c2ed5600d5938a 100644 (file)
@@ -40,8 +40,8 @@ public class CaddxPartitionActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ThingHandlerPartition) {
-            this.handler = (ThingHandlerPartition) handler;
+        if (handler instanceof ThingHandlerPartition partitionHandler) {
+            this.handler = partitionHandler;
         }
     }
 
index cae2d06cb65deadf4030c6241a69740a2f3a61da..3dfef2632eebbd2fb55d108f216dd95ae34b185f 100644 (file)
@@ -39,8 +39,8 @@ public class CaddxZoneActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ThingHandlerZone) {
-            this.handler = (ThingHandlerZone) handler;
+        if (handler instanceof ThingHandlerZone zoneHandler) {
+            this.handler = zoneHandler;
         }
     }
 
index 709c4bdf09040c646a78549a7857e90f99453ea5..cbc83a009f279513fcb1e1fb161dbd4e5d28fc3e 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.caddx.internal.discovery;
 
-import java.util.Collections;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -85,7 +84,7 @@ public class CaddxDiscoveryService extends AbstractDiscoveryService implements T
                 thingUID = new ThingUID(CaddxBindingConstants.PARTITION_THING_TYPE, bridge.getUID(), thingID);
 
                 if (partition != null) {
-                    properties = Collections.singletonMap(CaddxPartitionConfiguration.PARTITION_NUMBER, partition);
+                    properties = Map.of(CaddxPartitionConfiguration.PARTITION_NUMBER, partition);
                     representationProperty = CaddxPartitionConfiguration.PARTITION_NUMBER;
                 }
 
@@ -96,7 +95,7 @@ public class CaddxDiscoveryService extends AbstractDiscoveryService implements T
                 thingUID = new ThingUID(CaddxBindingConstants.ZONE_THING_TYPE, bridge.getUID(), thingID);
 
                 if (zone != null) {
-                    properties = Collections.singletonMap(CaddxZoneConfiguration.ZONE_NUMBER, zone);
+                    properties = Map.of(CaddxZoneConfiguration.ZONE_NUMBER, zone);
                     representationProperty = CaddxZoneConfiguration.ZONE_NUMBER;
                 }
                 break;
@@ -106,7 +105,7 @@ public class CaddxDiscoveryService extends AbstractDiscoveryService implements T
                 thingUID = new ThingUID(CaddxBindingConstants.KEYPAD_THING_TYPE, bridge.getUID(), thingID);
 
                 if (keypad != null) {
-                    properties = Collections.singletonMap(CaddxKeypadConfiguration.KEYPAD_ADDRESS, keypad);
+                    properties = Map.of(CaddxKeypadConfiguration.KEYPAD_ADDRESS, keypad);
                     representationProperty = CaddxKeypadConfiguration.KEYPAD_ADDRESS;
                 }
                 break;
@@ -154,8 +153,8 @@ public class CaddxDiscoveryService extends AbstractDiscoveryService implements T
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof CaddxBridgeHandler) {
-            caddxBridgeHandler = (CaddxBridgeHandler) handler;
+        if (handler instanceof CaddxBridgeHandler bridgeHandler) {
+            caddxBridgeHandler = bridgeHandler;
         }
     }
 
index 380c8cdb41e3e035df4c5f9f19e7b8b0b2fa993c..ec4963c01318020db058a25185fcfad199d1baa0 100644 (file)
@@ -88,8 +88,8 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
 
             ThingHandler handler = bridge.getHandler();
 
-            if (handler instanceof CaddxBridgeHandler) {
-                this.caddxBridgeHandler = (CaddxBridgeHandler) handler;
+            if (handler instanceof CaddxBridgeHandler bridgeHandler) {
+                this.caddxBridgeHandler = bridgeHandler;
             } else {
                 logger.debug("getCaddxBridgeHandler(): Unable to get bridge handler!");
             }
index e00ef4aca27539418e811adfe753f8c6e215e728..f6c2c63dd215fa9d563dd2640f6212ab92e4d1c6 100644 (file)
@@ -375,7 +375,7 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
                 switch (caddxMessage.getCaddxMessageType()) {
                     case PARTITIONS_SNAPSHOT_MESSAGE:
                         for (int i = 1; i <= 8; i++) {
-                            if (caddxMessage.getPropertyById("partition_" + i + "_valid").equals("true")) {
+                            if ("true".equals(caddxMessage.getPropertyById("partition_" + i + "_valid"))) {
                                 thing = findThing(CaddxThingType.PARTITION, i, null, null);
                                 if (thing != null) {
                                     continue;
index 3fc33882f2e4d838863c1f0b74b28f0ebe12c4f4..ef8d5b501a4c36002fd78d2cf75ed2f0eda99e96 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.caddx.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.caddx.internal.CaddxBindingConstants;
@@ -99,7 +99,7 @@ public class ThingHandlerKeypad extends CaddxBaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(CaddxKeypadActions.class);
+        return Set.of(CaddxKeypadActions.class);
     }
 
     public void enterTerminalMode() {
index 778ac9c93cc67f943cf5abfac2ce101533979644..d6165848b7f9b663eceafa1df955ca9c36d9fa31 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.caddx.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -258,7 +258,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(CaddxPanelActions.class);
+        return Set.of(CaddxPanelActions.class);
     }
 
     private void sendPrimaryCommand(String pin, String function) {
index 285f014695f7c0ac37e72a6496c5811b813573b8..ea041e09753aa0fcb0825c42bf07f97591d0c295 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.caddx.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.caddx.internal.CaddxBindingConstants;
@@ -135,7 +135,7 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(CaddxPartitionActions.class);
+        return Set.of(CaddxPartitionActions.class);
     }
 
     private void sendPrimaryCommand(String pin, String function) {
index eeee553e1a012ae3f240bce1b6ef48ce2120b750..079ec8145d87cc5a3574057f66ccaaec92290e50 100644 (file)
@@ -13,7 +13,7 @@
 package org.openhab.binding.caddx.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.caddx.internal.CaddxBindingConstants;
@@ -147,7 +147,7 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(CaddxZoneActions.class);
+        return Set.of(CaddxZoneActions.class);
     }
 
     public void bypass() {
index 008bf6afb3a7e60d2e7ac58fe5675694ba78cec6..ab9cd8e37f3dcbd7b0fef452547b92c3da2e5e2b 100644 (file)
@@ -32,7 +32,7 @@ import org.openhab.binding.caddx.internal.CaddxMessageReaderUtil;
 public class CaddxMessageParseTest {
 
     // @formatter:off
-    public static final List<Object[]> data() {
+    public static List<Object[]> data() {
         return Arrays.asList(new Object[][] {
             { "interface_configuration_message", "panel_firmware_version", "5.37", },
             { "interface_configuration_message", "panel_interface_configuration_message", "true", },
index d644a7c24894217a0cbabea14f6ede3afe8ed108..d983bc9f09cf57321406c870e7e5c55b75e1991b 100644 (file)
@@ -152,8 +152,8 @@ public class CBusCGateHandler extends BaseBridgeHandler {
             // now also re-initialize all network handlers
             for (Thing thing : getThing().getThings()) {
                 ThingHandler handler = thing.getHandler();
-                if (handler instanceof CBusNetworkHandler) {
-                    ((CBusNetworkHandler) handler).cgateStateChanged(isOnline);
+                if (handler instanceof CBusNetworkHandler networkHandler) {
+                    networkHandler.cgateStateChanged(isOnline);
                 }
             }
         });
@@ -194,8 +194,8 @@ public class CBusCGateHandler extends BaseBridgeHandler {
                         continue;
                     }
 
-                    if (thingThingHandler instanceof CBusGroupHandler) {
-                        ((CBusGroupHandler) thingThingHandler).updateGroup(application, group, value);
+                    if (thingThingHandler instanceof CBusGroupHandler groupHandler) {
+                        groupHandler.updateGroup(application, group, value);
                     }
                 }
             }
index 01a48e3ac4d3f5a2dce719b7f6f9b86315a2f95b..08270e709311af99e500025ab696cc450b1dff1a 100644 (file)
@@ -72,9 +72,8 @@ public class CBusDaliHandler extends CBusGroupHandler {
                         } else if (command == OnOffType.OFF) {
                             group.off();
                         }
-                    } else if (command instanceof PercentType) {
-                        PercentType value = (PercentType) command;
-                        group.ramp((int) Math.round(value.doubleValue() / 100 * 255), 0);
+                    } else if (command instanceof PercentType percentCommand) {
+                        group.ramp((int) Math.round(percentCommand.doubleValue() / 100 * 255), 0);
                     } else if (command instanceof IncreaseDecreaseType) {
                         int level = group.getLevel();
                         if (command == IncreaseDecreaseType.DECREASE) {
@@ -93,6 +92,7 @@ public class CBusDaliHandler extends CBusGroupHandler {
         }
     }
 
+    @Override
     public void updateGroup(int updateApplicationId, int updateGroupId, String value) {
         if (updateGroupId == groupId && updateApplicationId == applicationId) {
             Thing thing = getThing();
index ed4c9bfd60cf18c01deddf9ebcede6356783b9b3..c64ddf93a29cc882079ab95f9bee7a439f2e4bbd 100644 (file)
@@ -151,8 +151,8 @@ public abstract class CBusGroupHandler extends BaseThingHandler {
             return null;
         }
         ThingHandler handler = bridge.getHandler();
-        if (handler instanceof CBusNetworkHandler) {
-            return (CBusNetworkHandler) handler;
+        if (handler instanceof CBusNetworkHandler networkHandler) {
+            return networkHandler;
         }
         logger.debug("No available bridge handler found for bridge: {}", bridge.getUID());
         return null;
index bbed50cbec7b6473e0e21d72922b583a149fb93e..745812169072153ba808d8e5afb7606129f9580f 100644 (file)
@@ -88,9 +88,8 @@ public class CBusLightHandler extends CBusGroupHandler {
                         } else if (command == OnOffType.OFF) {
                             group.off();
                         }
-                    } else if (command instanceof PercentType) {
-                        PercentType value = (PercentType) command;
-                        group.ramp((int) Math.round(value.doubleValue() / 100 * 255), 0);
+                    } else if (command instanceof PercentType percentCommand) {
+                        group.ramp((int) Math.round(percentCommand.doubleValue() / 100 * 255), 0);
                     } else if (command instanceof IncreaseDecreaseType) {
                         int level = group.getLevel();
                         if (command == IncreaseDecreaseType.DECREASE) {
@@ -109,6 +108,7 @@ public class CBusLightHandler extends CBusGroupHandler {
         }
     }
 
+    @Override
     public void updateGroup(int updateApplicationId, int updateGroupId, String value) {
         if (updateGroupId == groupId && updateApplicationId == applicationId) {
             Thing thing = getThing();
index 8ebeae84940aae615b6b056aace366e72a160735..8100c857afdcd8415f2c83ca52d98d4122a320c6 100644 (file)
@@ -235,8 +235,8 @@ public class CBusNetworkHandler extends BaseBridgeHandler {
             }
             for (Thing thing : getThing().getThings()) {
                 ThingHandler handler = thing.getHandler();
-                if (handler instanceof CBusGroupHandler) {
-                    ((CBusGroupHandler) handler).updateStatus();
+                if (handler instanceof CBusGroupHandler groupHandler) {
+                    groupHandler.updateStatus();
                 }
             }
         }
@@ -262,8 +262,8 @@ public class CBusNetworkHandler extends BaseBridgeHandler {
             return null;
         }
         ThingHandler handler = bridge.getHandler();
-        if (handler instanceof CBusCGateHandler) {
-            return (CBusCGateHandler) handler;
+        if (handler instanceof CBusCGateHandler gateHandler) {
+            return gateHandler;
         } else {
             logger.debug("No available bridge handler found for bridge: {}.", bridge.getUID());
             return null;
index 9c5af8ec1f21e308c1762bb8a6d308670f46b8d3..21e97f01fbc96d5ad62cdc1add6f6eff53e3dcca 100644 (file)
@@ -66,6 +66,7 @@ public class CBusTemperatureHandler extends CBusGroupHandler {
         }
     }
 
+    @Override
     public void updateGroup(int updateApplicationId, int updateGroupId, String value) {
         if (updateGroupId == groupId && updateApplicationId == applicationId) {
             Thing thing = getThing();
index 05188d4e0cf0e1dddcc1bb09d8740ff38f85bf23..31060fefc6687b795cd1a716be09495167f499eb 100644 (file)
@@ -58,8 +58,8 @@ public class CBusTriggerHandler extends CBusGroupHandler {
             if (channelUID.getId().equals(CBusBindingConstants.CHANNEL_VALUE)) {
                 logger.debug("Channel Value command for {}: {}", channelUID, command);
                 try {
-                    if (command instanceof DecimalType) {
-                        group.TriggerEvent(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        group.TriggerEvent(decimalCommand.intValue());
                     }
                 } catch (CGateException e) {
                     logger.debug("Failed to send trigger command {} to {}", command, group, e);
@@ -69,6 +69,7 @@ public class CBusTriggerHandler extends CBusGroupHandler {
         }
     }
 
+    @Override
     public void updateGroup(int updateApplicationId, int updateGroupId, String value) {
         if (updateGroupId == groupId && updateApplicationId == applicationId) {
             Thing thing = getThing();
index 80a6ab3c3a6fc7bd1cd120c6294b2a6cd2244fc7..04decc6065df59c48fff7c8cead04095c3f7ca3a 100644 (file)
@@ -78,9 +78,8 @@ public class ChromecastAudioSink extends AudioSinkAsync {
             handler.stop();
         } else {
             final String url;
-            if (audioStream instanceof URLAudioStream) {
-                // it is an external URL, the speaker can access it itself and play it.
-                URLAudioStream urlAudioStream = (URLAudioStream) audioStream;
+            if (audioStream instanceof URLAudioStream urlAudioStream) {
+                // it is an external URL, the speaker can access it itself and play it
                 url = urlAudioStream.getURL();
                 tryClose(audioStream);
             } else {
index 6497261098fc7ba29e95d23ec534a7264ef09120..411e8e953670ee92c511f67ebefcfafcfca3ee80 100644 (file)
@@ -158,18 +158,16 @@ public class ChromecastCommander {
                 return;
             }
 
-            if (command instanceof PlayPauseType) {
+            if (command instanceof PlayPauseType playPauseCommand) {
                 MediaStatus mediaStatus = chromeCast.getMediaStatus();
                 logger.debug("mediaStatus {}", mediaStatus);
                 if (mediaStatus == null || mediaStatus.playerState == MediaStatus.PlayerState.IDLE) {
                     logger.debug("{} command ignored because media is not loaded", command);
                     return;
                 }
-
-                final PlayPauseType playPause = (PlayPauseType) command;
-                if (playPause == PlayPauseType.PLAY) {
+                if (playPauseCommand == PlayPauseType.PLAY) {
                     chromeCast.play();
-                } else if (playPause == PlayPauseType.PAUSE
+                } else if (playPauseCommand == PlayPauseType.PAUSE
                         && ((mediaStatus.supportedMediaCommands & 0x00000001) == 0x1)) {
                     chromeCast.pause();
                 } else {
@@ -199,8 +197,8 @@ public class ChromecastCommander {
     }
 
     public void handleVolume(final Command command) {
-        if (command instanceof PercentType) {
-            setVolumeInternal((PercentType) command);
+        if (command instanceof PercentType percentCommand) {
+            setVolumeInternal(percentCommand);
         } else if (command == IncreaseDecreaseType.INCREASE) {
             setVolumeInternal(new PercentType(
                     Math.min(statusUpdater.getVolume().intValue() + VOLUMESTEP, PercentType.HUNDRED.intValue())));
index ea8a7cf0a941ba6486d021cbd517bc6d5fdaf90f..e03bd86c3474d12aed94edb13b2f70dc53dd214d 100644 (file)
@@ -318,8 +318,8 @@ public class ChromecastStatusUpdater {
             state = new DecimalType(((Integer) value).longValue());
         } else if (value instanceof String) {
             state = new StringType(value.toString());
-        } else if (value instanceof ZonedDateTime) {
-            state = new DateTimeType((ZonedDateTime) value);
+        } else if (value instanceof ZonedDateTime datetime) {
+            state = new DateTimeType(datetime);
         } else {
             state = UnDefType.UNDEF;
             logger.warn("Update channel {}: Unsupported value type {}", channelUID, value.getClass().getSimpleName());
index d06d4e1e75959882e3121d9d3b456300288986ba..0354e579d0485326d487f78b8494144c6ddb1996 100644 (file)
@@ -82,8 +82,8 @@ public class ChromecastActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ChromecastHandler) {
-            this.handler = (ChromecastHandler) handler;
+        if (handler instanceof ChromecastHandler chromecastHandler) {
+            this.handler = chromecastHandler;
         }
     }
 
index 3860827e9d238cf38dd28f3dc119d73fc74dd95e..d3ea931dd70f57924a0b2f4822dab900c0a85954 100644 (file)
@@ -14,9 +14,6 @@ package org.openhab.binding.cm11a.internal;
 
 import static org.openhab.binding.cm11a.internal.CM11ABindingConstants.*;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.openhab.binding.cm11a.internal.handler.Cm11aApplianceHandler;
@@ -43,8 +40,7 @@ public class Cm11aHandlerFactory extends BaseThingHandlerFactory {
 
     private final Logger logger = LoggerFactory.getLogger(Cm11aHandlerFactory.class);
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_SWITCH, THING_TYPE_DIMMER)));
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SWITCH, THING_TYPE_DIMMER);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 40fcf4fc7cc6ef3f50ffac59558f50105cacbfd5..226385ca5c83a591b0dd602e5015751d0e75798b 100644 (file)
@@ -79,13 +79,13 @@ public class X10ReceivedData {
     /**
      * Lookup table to convert House code received from the cm11a into an X10 house code
      */
-    public static final char HOUSE_CODE[] = new char[] { 'M', 'E', 'C', 'K', 'O', 'G', 'A', 'I', 'N', 'F', 'D', 'L',
+    public static final char[] HOUSE_CODE = new char[] { 'M', 'E', 'C', 'K', 'O', 'G', 'A', 'I', 'N', 'F', 'D', 'L',
             'P', 'H', 'B', 'J' };
 
     /**
      * Lookup table to convert Unit code received from the cm11a into an X10 unit code
      */
-    public static final byte UNIT_CODE[] = new byte[] { 13, 5, 3, 11, 15, 7, 1, 9, 14, 6, 4, 12, 16, 8, 2, 10 };
+    public static final byte[] UNIT_CODE = new byte[] { 13, 5, 3, 11, 15, 7, 1, 9, 14, 6, 4, 12, 16, 8, 2, 10 };
 
     private String[] addr;
     private X10COMMAND cmd;
index 7bcb4ba3becfd298fb7f596ac2dc9ad42f43f608..d6a997f5a4054d70383e044637a34b78f9f73296 100644 (file)
@@ -71,8 +71,8 @@ public class Cm11aLampHandler extends Cm11aAbstractHandler {
                 desiredState = OnOffType.ON;
             } else if (OnOffType.OFF.equals(command)) {
                 desiredState = OnOffType.OFF;
-            } else if (command instanceof PercentType) {
-                desiredState = (PercentType) command;
+            } else if (command instanceof PercentType percentCommand) {
+                desiredState = percentCommand;
             } else if (command instanceof RefreshType) {
                 // Refresh is triggered by framework during startup.
                 // Force the lamp off by indicating it is currently on and we want it off
@@ -105,10 +105,10 @@ public class Cm11aLampHandler extends Cm11aAbstractHandler {
                 x10Status = x10Interface.sendFunction(houseUnitCode, X10Interface.FUNC_ON);
             } else if (desiredState.equals(OnOffType.OFF)) {
                 x10Status = x10Interface.sendFunction(houseUnitCode, X10Interface.FUNC_OFF);
-            } else if (desiredState instanceof PercentType) {
+            } else if (desiredState instanceof PercentType desiredStatePercent) {
                 // desiredState must be a PercentType if we got here.
                 // Calc how many bright increments we need to send (0 to 22)
-                int desiredPercentFullBright = ((PercentType) desiredState).intValue();
+                int desiredPercentFullBright = desiredStatePercent.intValue();
                 int dims = (desiredPercentFullBright * X10_DIM_INCREMENTS) / 100;
                 if (currentState.equals(OnOffType.ON)) {
                     // The current level isn't known because it would have gone to
@@ -120,11 +120,11 @@ public class Cm11aLampHandler extends Cm11aAbstractHandler {
                     // desiredState must be a PercentType if we got here. And, the light should be off
                     // We should just be able to send the appropriate number if dims
                     x10Status = x10Interface.sendFunction(houseUnitCode, X10Interface.FUNC_BRIGHT, dims);
-                } else if (currentState instanceof PercentType) {
+                } else if (currentState instanceof PercentType currentStatePercent) {
                     // This is the expected case
                     // Now currentState and desiredState are both PercentType's
                     // Need to calc how much to dim or brighten
-                    int currentPercentFullBright = ((PercentType) currentState).intValue();
+                    int currentPercentFullBright = currentStatePercent.intValue();
                     int percentToBrighten = desiredPercentFullBright - currentPercentFullBright;
                     int brightens = (percentToBrighten * X10_DIM_INCREMENTS) / 100;
                     if (brightens > 0) {
index 7bbb845bd20c752397098b20bcca8dfa6ef90dc2..9b52212acda1135b5d1d20d574c9ec49677b35aa 100644 (file)
@@ -148,9 +148,9 @@ public class HVACHandler extends BaseThingHandler {
                         if (on != null) {
                             updateState(ON, "1".equals(on) ? OnOffType.ON : OnOffType.OFF);
                         }
-                    } else if (command instanceof OnOffType) {
-                        final OnOffType onoff = (OnOffType) command;
-                        controller.sendCommand(String.format("%s %s", onoff == OnOffType.ON ? "on" : "off", uid));
+                    } else if (command instanceof OnOffType onOffCommand) {
+                        controller
+                                .sendCommand(String.format("%s %s", onOffCommand == OnOffType.ON ? "on" : "off", uid));
                     }
                     break;
                 case SET_TEMP:
@@ -161,9 +161,8 @@ public class HVACHandler extends BaseThingHandler {
                             final QuantityType<?> value = new QuantityType<>(temp, controller.getUnit());
                             updateState(SET_TEMP, value);
                         }
-                    } else if (command instanceof QuantityType) {
-                        final QuantityType<?> temp = (QuantityType) command;
-                        final QuantityType<?> converted = temp.toUnit(controller.getUnit());
+                    } else if (command instanceof QuantityType quantityCommand) {
+                        final QuantityType<?> converted = quantityCommand.toUnit(controller.getUnit());
                         final String formatted = converted.format("%.1f");
                         controller.sendCommand(String.format("temp %s %s", uid, formatted));
                     }
@@ -174,8 +173,8 @@ public class HVACHandler extends BaseThingHandler {
                         if (mode != null) {
                             updateState(MODE, new StringType(mode));
                         }
-                    } else if (command instanceof StringType) {
-                        final String mode = ((StringType) command).toString();
+                    } else if (command instanceof StringType stringCommand) {
+                        final String mode = stringCommand.toString();
                         controller.sendCommand(String.format("%s %s", mode, uid));
                     }
                     break;
@@ -185,8 +184,8 @@ public class HVACHandler extends BaseThingHandler {
                         if (fan != null) {
                             updateState(FAN_SPEED, new StringType(fan));
                         }
-                    } else if (command instanceof StringType) {
-                        final String fan = ((StringType) command).toString();
+                    } else if (command instanceof StringType stringCommand) {
+                        final String fan = stringCommand.toString();
                         controller.sendCommand(String.format("fspeed %s %s", uid, fan));
                     }
                     break;
@@ -196,8 +195,8 @@ public class HVACHandler extends BaseThingHandler {
                         if (louvre != null) {
                             updateState(LOUVRE, new StringType(louvre));
                         }
-                    } else if (command instanceof StringType) {
-                        final String louvre = ((StringType) command).toString();
+                    } else if (command instanceof StringType stringCommand) {
+                        final String louvre = stringCommand.toString();
                         controller.sendCommand(String.format("swing %s %s", uid, louvre));
                     }
                     break;
index 0a062aa622b59826e4c318d9de829e9fd6ad07df..10496a49e8f7c7df11ec6850428e39ba87af2359 100644 (file)
@@ -87,8 +87,8 @@ public class CoronaStatsCountryHandler extends BaseThingHandler {
         Bridge bridge = getBridge();
         if (bridge != null) {
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof CoronaStatsWorldHandler) {
-                return (CoronaStatsWorldHandler) handler;
+            if (handler instanceof CoronaStatsWorldHandler worldHandler) {
+                return worldHandler;
             }
         }
 
index 41f509f00c22e129049a4b1ec52a118aeecab81c..8beb813207d3e61e331d83d333e834ef5fabea5d 100644 (file)
@@ -172,9 +172,8 @@ public class CoronaStatsWorldHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof CoronaStatsCountryHandler) {
+        if (childHandler instanceof CoronaStatsCountryHandler listener) {
             logger.debug("Register thing listener.");
-            final CoronaStatsCountryHandler listener = (CoronaStatsCountryHandler) childHandler;
             if (countryListeners.add(listener)) {
                 final CoronaStats localCoronaStats = coronaStats;
                 if (localCoronaStats != null) {
@@ -189,9 +188,9 @@ public class CoronaStatsWorldHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof CoronaStatsCountryHandler) {
+        if (childHandler instanceof CoronaStatsCountryHandler countryHandler) {
             logger.debug("Unregister thing listener.");
-            if (!countryListeners.remove((CoronaStatsCountryHandler) childHandler)) {
+            if (!countryListeners.remove(countryHandler)) {
                 logger.warn("Tried to remove listener {} but it was not registered. This is probably an error.",
                         childHandler);
             }
index 473a85a69f87a01374dcaa09ed2291f9297aacf2..7f043596f93fb99ca4f9ba5913d5c16a9a8bac3c 100644 (file)
@@ -35,7 +35,7 @@ public class AirbaseZoneInfo {
     private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseZoneInfo.class);
 
     public String zonenames = "";
-    public boolean zone[] = new boolean[8];
+    public boolean[] zone = new boolean[8];
 
     private AirbaseZoneInfo() {
     }
index d1b26f0a53de810e4dd1ce8baaa21a7e8847ccfc..1554cf3b86618239717980490600021b6ff69fca 100644 (file)
@@ -18,10 +18,10 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -65,7 +65,7 @@ public class DaikinACUnitDiscoveryService extends AbstractDiscoveryService {
     private @Nullable ScheduledFuture<?> backgroundFuture;
 
     public DaikinACUnitDiscoveryService() {
-        super(Collections.singleton(DaikinBindingConstants.THING_TYPE_AC_UNIT), 600, true);
+        super(Set.of(DaikinBindingConstants.THING_TYPE_AC_UNIT), 600, true);
     }
 
     @Override
index 4f3f664372de7f7f797d758109ef23cf4192ecb1..ed23fbfddded2291a565b2a7a26b58436a133f31 100644 (file)
@@ -159,20 +159,20 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
             throws DaikinCommunicationException {
         switch (channelUID.getId()) {
             case DaikinBindingConstants.CHANNEL_AC_FAN_DIR:
-                if (command instanceof StringType) {
-                    changeFanDir(((StringType) command).toString());
+                if (command instanceof StringType stringCommand) {
+                    changeFanDir(stringCommand.toString());
                     return true;
                 }
                 break;
             case DaikinBindingConstants.CHANNEL_AC_SPECIALMODE:
-                if (command instanceof StringType) {
-                    changeSpecialMode(((StringType) command).toString());
+                if (command instanceof StringType stringCommand) {
+                    changeSpecialMode(stringCommand.toString());
                     return true;
                 }
                 break;
             case DaikinBindingConstants.CHANNEL_AC_STREAMER:
-                if (command instanceof OnOffType) {
-                    changeStreamer(((OnOffType) command).equals(OnOffType.ON));
+                if (command instanceof OnOffType onOffCommand) {
+                    changeStreamer(onOffCommand.equals(OnOffType.ON));
                     return true;
                 }
                 break;
index 456794b80fa01975156b3e6481518cb629e4830c..7ebc6050f121e95f8953e7c0c241717ab0103dfe 100644 (file)
@@ -102,8 +102,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
             }
             switch (channelUID.getId()) {
                 case DaikinBindingConstants.CHANNEL_AC_POWER:
-                    if (command instanceof OnOffType) {
-                        changePower(((OnOffType) command).equals(OnOffType.ON));
+                    if (command instanceof OnOffType onOffCommand) {
+                        changePower(onOffCommand.equals(OnOffType.ON));
                         return;
                     }
                     break;
@@ -114,8 +114,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
                     break;
                 case DaikinBindingConstants.CHANNEL_AIRBASE_AC_FAN_SPEED:
                 case DaikinBindingConstants.CHANNEL_AC_FAN_SPEED:
-                    if (command instanceof StringType) {
-                        changeFanSpeed(((StringType) command).toString());
+                    if (command instanceof StringType stringCommand) {
+                        changeFanSpeed(stringCommand.toString());
                         return;
                     }
                     break;
@@ -126,8 +126,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
                     }
                     break;
                 case DaikinBindingConstants.CHANNEL_AC_MODE:
-                    if (command instanceof StringType) {
-                        changeMode(((StringType) command).toString());
+                    if (command instanceof StringType stringCommand) {
+                        changeMode(stringCommand.toString());
                         return;
                     }
                     break;
@@ -214,8 +214,8 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
      */
     private boolean changeSetPoint(Command command) throws DaikinCommunicationException {
         double newTemperature;
-        if (command instanceof DecimalType) {
-            newTemperature = ((DecimalType) command).doubleValue();
+        if (command instanceof DecimalType decimalCommand) {
+            newTemperature = decimalCommand.doubleValue();
         } else if (command instanceof QuantityType) {
             newTemperature = ((QuantityType<Temperature>) command).toUnit(SIUnits.CELSIUS).doubleValue();
         } else {
index 5c4b0269303bd55dffd133c09a35b48649b5a89e..45b3bd70187f271639da31191cdf99b33eb4ae96 100644 (file)
@@ -93,25 +93,25 @@ public class DaliDeviceHandler extends BaseThingHandler {
 
                 boolean queryDeviceState = false;
 
-                if (command instanceof PercentType) {
-                    byte dimmValue = (byte) ((((PercentType) command).floatValue() * DALI_SWITCH_100_PERCENT) / 100);
+                if (command instanceof PercentType percentCommand) {
+                    byte dimmValue = (byte) ((percentCommand.floatValue() * DALI_SWITCH_100_PERCENT) / 100);
                     // A dimm value of zero is handled correctly by DALI devices, i.e. they are turned off
                     getBridgeHandler().sendCommand(new DaliDAPCCommand(address, dimmValue));
-                } else if (command instanceof OnOffType) {
-                    if ((OnOffType) command == OnOffType.ON) {
+                } else if (command instanceof OnOffType onOffCommand) {
+                    if (onOffCommand == OnOffType.ON) {
                         getBridgeHandler().sendCommand(new DaliDAPCCommand(address, (byte) DALI_SWITCH_100_PERCENT));
                     } else {
                         getBridgeHandler().sendCommand(DaliStandardCommand.createOffCommand(address));
                     }
-                } else if (command instanceof IncreaseDecreaseType) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
                     if (CHANNEL_DIM_AT_FADE_RATE.equals(channelUID.getId())) {
-                        if ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE) {
+                        if (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE) {
                             getBridgeHandler().sendCommand(DaliStandardCommand.createUpCommand(address));
                         } else {
                             getBridgeHandler().sendCommand(DaliStandardCommand.createDownCommand(address));
                         }
                     } else {
-                        if ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE) {
+                        if (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE) {
                             getBridgeHandler().sendCommand(DaliStandardCommand.createStepUpCommand(address));
                         } else {
                             getBridgeHandler().sendCommand(DaliStandardCommand.createStepDownCommand(address));
index 00c2fe9d0212914e3543a04c8b4aeab9d167b446..7b6df1616b1e4c2bdf9af36c7ca67733e90fd6b5 100644 (file)
@@ -65,13 +65,13 @@ public class DaliDt8DeviceHandler extends DaliDeviceHandler {
                     throw new DaliException("unknown device type");
                 }
                 int mirek;
-                if (command instanceof DecimalType) {
+                if (command instanceof DecimalType decimalCommand) {
                     // Color temperature in DALI is represented in mirek ("reciprocal megakelvin")
                     // It is one million times the reciprocal of the color temperature (in Kelvin)
-                    mirek = (int) (1E6f / (Math.min(Math.max(((DecimalType) command).intValue(), 1000), 20000)));
-                } else if (command instanceof QuantityType) {
+                    mirek = (int) (1E6f / (Math.min(Math.max(decimalCommand.intValue(), 1000), 20000)));
+                } else if (command instanceof QuantityType quantityCommand) {
                     // ensure it's in the correct units
-                    QuantityType<?> commandQuantity = ((QuantityType) command).toInvertibleUnit(Units.MIRED);
+                    QuantityType<?> commandQuantity = quantityCommand.toInvertibleUnit(Units.MIRED);
                     if (commandQuantity == null) {
                         logger.warn("Unable to convert command {} to mireks", command);
                         return;
@@ -134,8 +134,8 @@ public class DaliDt8DeviceHandler extends DaliDeviceHandler {
                 } else {
                     throw new DaliException("unknown device type");
                 }
-                if (command instanceof HSBType) {
-                    PercentType[] rgb = ((HSBType) command).toRGB();
+                if (command instanceof HSBType hsbCommand) {
+                    PercentType[] rgb = hsbCommand.toRGB();
                     final int r = (int) (254 * (rgb[0].floatValue() / 100));
                     final int g = (int) (254 * (rgb[1].floatValue() / 100));
                     final int b = (int) (254 * (rgb[2].floatValue() / 100));
index 83dccadfc12f945a027361c46bb984b67999276d..c39631046b133a539b38ea6a27b3a9d977265f88 100644 (file)
@@ -76,16 +76,16 @@ public class DaliRgbHandler extends BaseThingHandler {
             if (CHANNEL_COLOR.equals(channelUID.getId())) {
                 boolean queryDeviceState = false;
 
-                if (command instanceof HSBType) {
-                    PercentType[] rgb = ((HSBType) command).toRGB();
+                if (command instanceof HSBType hsbCommand) {
+                    PercentType[] rgb = hsbCommand.toRGB();
 
                     for (int i = 0; i < 3; i++) {
                         byte dimmValue = (byte) ((rgb[i].floatValue() * DALI_SWITCH_100_PERCENT) / 100);
                         getBridgeHandler().sendCommand(
                                 new DaliDAPCCommand(DaliAddress.createShortAddress(outputs.get(i)), dimmValue));
                     }
-                } else if (command instanceof OnOffType) {
-                    if ((OnOffType) command == OnOffType.ON) {
+                } else if (command instanceof OnOffType onOffCommand) {
+                    if (onOffCommand == OnOffType.ON) {
                         for (Integer output : outputs) {
                             getBridgeHandler().sendCommand(new DaliDAPCCommand(DaliAddress.createShortAddress(output),
                                     (byte) DALI_SWITCH_100_PERCENT));
@@ -96,8 +96,8 @@ public class DaliRgbHandler extends BaseThingHandler {
                                     DaliStandardCommand.createOffCommand(DaliAddress.createShortAddress(output)));
                         }
                     }
-                } else if (command instanceof IncreaseDecreaseType) {
-                    if ((IncreaseDecreaseType) command == IncreaseDecreaseType.INCREASE) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    if (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE) {
                         for (Integer output : outputs) {
                             getBridgeHandler().sendCommand(
                                     DaliStandardCommand.createUpCommand(DaliAddress.createShortAddress(output)));
index 78370c149f5a19cf287c2727317f555217d1d6b5..6985628d8b5e0ddee8b7f2cf420ccd4cc36970d3 100644 (file)
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
-import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
@@ -50,7 +49,7 @@ import org.slf4j.LoggerFactory;
  */
 @NonNullByDefault
 public class DaliserverBridgeHandler extends BaseBridgeHandler {
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(BRIDGE_TYPE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(BRIDGE_TYPE);
 
     private final Logger logger = LoggerFactory.getLogger(DaliserverBridgeHandler.class);
     private static final int DALI_DEFAULT_TIMEOUT = 5000;
index 576130bd53ffcbf67d34dd721a5a215a9958c19e..91d5a97b2fe5e63735afb2708f73b712280fc303 100644 (file)
@@ -236,16 +236,16 @@ public class DanfossAirUnit {
     }
 
     private DecimalType setNumberTypeRegister(Command cmd, byte[] register) throws IOException {
-        if (cmd instanceof DecimalType) {
-            byte value = (byte) ((DecimalType) cmd).intValue();
+        if (cmd instanceof DecimalType decimalCommand) {
+            byte value = (byte) decimalCommand.intValue();
             set(REGISTER_1_WRITE, register, value);
         }
         return new DecimalType(BigDecimal.valueOf(getByte(REGISTER_1_READ, register)));
     }
 
     private PercentType setPercentTypeRegister(Command cmd, byte[] register) throws IOException {
-        if (cmd instanceof PercentType) {
-            byte value = (byte) ((((PercentType) cmd).intValue() + 5) / 10);
+        if (cmd instanceof PercentType percentCommand) {
+            byte value = (byte) ((percentCommand.intValue() + 5) / 10);
             set(REGISTER_1_WRITE, register, value);
         }
         return new PercentType(BigDecimal.valueOf(getByte(REGISTER_1_READ, register) * 10));
index e7c51a175fbce750ee02256da509edbf4f5d3e5c..7b397141fc1fcaab9fdb84c1cb2ca3eb626ba5ce 100644 (file)
@@ -52,6 +52,7 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
         this.port = port;
     }
 
+    @Override
     public synchronized void connect() throws IOException {
         if (connected) {
             return;
@@ -64,6 +65,7 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
         connected = true;
     }
 
+    @Override
     public synchronized void disconnect() {
         if (!connected) {
             return;
@@ -83,10 +85,12 @@ public class DanfossAirUnitCommunicationController implements CommunicationContr
         connected = false;
     }
 
+    @Override
     public byte[] sendRobustRequest(byte[] operation, byte[] register) throws IOException {
         return sendRobustRequest(operation, register, EMPTY);
     }
 
+    @Override
     public synchronized byte[] sendRobustRequest(byte[] operation, byte[] register, byte[] value) throws IOException {
         connect();
         byte[] request = new byte[4 + value.length];
index 0196cf15af7d06753b3a8df41cf8d474050ca67d..155cb28d59838f15f66b2479c46445423488aad8 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.danfossairunit.internal;
 
 import static org.openhab.binding.danfossairunit.internal.DanfossAirUnitBindingConstants.THING_TYPE_AIRUNIT;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -38,7 +37,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(configurationPid = "binding.danfossairunit", service = ThingHandlerFactory.class)
 public class DanfossAirUnitHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRUNIT);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIRUNIT);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 3a390a2981616695d0371a0fb5fbb5cedcc3ea52..618eaf959e18222dedc8020a181ee9379a30a6d3 100644 (file)
@@ -78,9 +78,9 @@ public class DBQueryActions implements IDBQueryActions, ThingActions {
     @RuleAction(label = "Set query parameters", description = "Set query parameters for a query")
     public void setQueryParameters(@ActionInput(name = "parameters") Map<String, @Nullable Object> parameters) {
         logger.debug("setQueryParameters {}", parameters);
-        var queryHandler = getThingHandler();
-        if (queryHandler instanceof QueryHandler) {
-            ((QueryHandler) queryHandler).setParameters(parameters);
+        var thingHandler = getThingHandler();
+        if (thingHandler instanceof QueryHandler queryHandler) {
+            queryHandler.setParameters(parameters);
         } else {
             logger.warn("setQueryParameters called on wrong Thing, it must be a Query Thing");
         }
@@ -100,10 +100,10 @@ public class DBQueryActions implements IDBQueryActions, ThingActions {
 
     @Override
     public void setThingHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof QueryHandler) {
-            this.queryHandler = ((QueryHandler) thingHandler);
-        } else if (thingHandler instanceof DatabaseBridgeHandler) {
-            this.databaseBridgeHandler = ((DatabaseBridgeHandler) thingHandler);
+        if (thingHandler instanceof QueryHandler queryHandler) {
+            this.queryHandler = queryHandler;
+        } else if (thingHandler instanceof DatabaseBridgeHandler databaseBridgeHandler) {
+            this.databaseBridgeHandler = databaseBridgeHandler;
         } else {
             throw new UnnexpectedCondition("Not expected thing handler " + thingHandler);
         }
index fa2a8960445d5c39df33749e2928549cbc614b0f..6e6762f7ea810e193ce63668015e4d82f3fe86bb 100644 (file)
@@ -193,13 +193,11 @@ public class QueryHandler extends BaseThingHandler {
 
     private void updateStateWithParentBridgeStatus() {
         final @Nullable Bridge bridge = getBridge();
-        DatabaseBridgeHandler databaseBridgeHandler;
 
         if (bridge != null) {
             @Nullable
             BridgeHandler bridgeHandler = bridge.getHandler();
-            if (bridgeHandler instanceof DatabaseBridgeHandler) {
-                databaseBridgeHandler = (DatabaseBridgeHandler) bridgeHandler;
+            if (bridgeHandler instanceof DatabaseBridgeHandler databaseBridgeHandler) {
                 database = databaseBridgeHandler.getDatabase();
                 if (bridge.getStatus() == ThingStatus.ONLINE) {
                     updateStatus(ThingStatus.ONLINE);
index dcfc5f3183066fc60bf7e09cb5ad55fcf66fdb13..ae01166b01eaf6c20cf137f9bf974fd990af8cde 100644 (file)
@@ -75,12 +75,12 @@ public class Value2StateConverter {
     }
 
     private State convert2DateTime(Object value) {
-        if (value instanceof Instant) {
-            return new DateTimeType(ZonedDateTime.ofInstant((Instant) value, ZoneId.systemDefault()));
-        } else if (value instanceof Date) {
-            return new DateTimeType(ZonedDateTime.ofInstant(((Date) value).toInstant(), ZoneId.systemDefault()));
-        } else if (value instanceof String) {
-            return new DateTimeType((String) value);
+        if (value instanceof Instant instant) {
+            return new DateTimeType(ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()));
+        } else if (value instanceof Date date) {
+            return new DateTimeType(ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()));
+        } else if (value instanceof String string) {
+            return new DateTimeType(string);
         } else {
             logger.warn("Can't convert {} to DateTimeType", value);
             return UnDefType.NULL;
@@ -96,16 +96,16 @@ public class Value2StateConverter {
             return new DecimalType((Float) value);
         } else if (value instanceof Double) {
             return new DecimalType((Double) value);
-        } else if (value instanceof BigDecimal) {
-            return new DecimalType((BigDecimal) value);
-        } else if (value instanceof BigInteger) {
-            return new DecimalType(new BigDecimal((BigInteger) value));
-        } else if (value instanceof Number) {
-            return new DecimalType(((Number) value).longValue());
-        } else if (value instanceof String) {
-            return DecimalType.valueOf((String) value);
-        } else if (value instanceof Duration) {
-            return new DecimalType(((Duration) value).toMillis());
+        } else if (value instanceof BigDecimal decimal) {
+            return new DecimalType(decimal);
+        } else if (value instanceof BigInteger integer) {
+            return new DecimalType(new BigDecimal(integer));
+        } else if (value instanceof Number number) {
+            return new DecimalType(number.longValue());
+        } else if (value instanceof String string) {
+            return DecimalType.valueOf(string);
+        } else if (value instanceof Duration duration) {
+            return new DecimalType(duration.toMillis());
         } else {
             logger.warn("Can't convert {} to DecimalType", value);
             return UnDefType.NULL;
@@ -113,25 +113,24 @@ public class Value2StateConverter {
     }
 
     private State convert2String(Object value) {
-        if (value instanceof String) {
-            return new StringType((String) value);
-        } else if (value instanceof byte[]) {
-            return new StringType(Base64.getEncoder().encodeToString((byte[]) value));
-        } else if (value instanceof QueryResult) {
-            return new StringType(jsonEncoder.encode((QueryResult) value));
+        if (value instanceof String string) {
+            return new StringType(string);
+        } else if (value instanceof byte[] bytes) {
+            return new StringType(Base64.getEncoder().encodeToString(bytes));
+        } else if (value instanceof QueryResult result) {
+            return new StringType(jsonEncoder.encode(result));
         } else {
             return new StringType(String.valueOf(value));
         }
     }
 
     private @Nullable Boolean convert2Boolean(Object value) {
-        if (value instanceof Boolean) {
-            return (Boolean) value;
-        } else if (value instanceof Number) {
-            return ((Number) value).doubleValue() != 0d;
-        } else if (value instanceof String) {
-            var svalue = (String) value;
-            return Boolean.parseBoolean(svalue) || (svalue.equalsIgnoreCase("on")) || svalue.equals("1");
+        if (value instanceof Boolean boolean1) {
+            return boolean1;
+        } else if (value instanceof Number number) {
+            return number.doubleValue() != 0d;
+        } else if (value instanceof String svalue) {
+            return Boolean.parseBoolean(svalue) || ("on".equalsIgnoreCase(svalue)) || "1".equals(svalue);
         } else {
             logger.warn("Can't convert {} to OnOffType or OpenClosedType", value);
             return null;
index f849275157dd130e38ce137f92aa65d0ba29dd75..b9cfa6157f9782b56a3cb95f9ef25d15715c4bd3 100644 (file)
@@ -81,8 +81,7 @@ public class Influx2Database implements Database {
     @Override
     public CompletableFuture<QueryResult> executeQuery(Query query) {
         try {
-            if (query instanceof Influx2QueryFactory.Influx2Query) {
-                Influx2QueryFactory.Influx2Query influxQuery = (Influx2QueryFactory.Influx2Query) query;
+            if (query instanceof Influx2QueryFactory.Influx2Query influxQuery) {
 
                 CompletableFuture<QueryResult> asyncResult = new CompletableFuture<>();
                 List<FluxRecord> records = new ArrayList<>();
index 135b0e767d1ef33bc1f76d56616a3d5a3f20d9fe..59fa462fa138de998ef31704094a7a6c6cb32e14 100644 (file)
@@ -90,16 +90,16 @@ public class DBQueryJSONEncoder {
     }
 
     private static JsonElement convertValueToJsonPrimitive(@Nullable Object value) {
-        if (value instanceof Number) {
-            return new JsonPrimitive((Number) value);
-        } else if (value instanceof Boolean) {
-            return new JsonPrimitive((Boolean) value);
+        if (value instanceof Number number) {
+            return new JsonPrimitive(number);
+        } else if (value instanceof Boolean boolean1) {
+            return new JsonPrimitive(boolean1);
         } else if (value instanceof Character) {
             return new JsonPrimitive((Character) value);
-        } else if (value instanceof Date) {
-            return new JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format(((Date) value).toInstant()));
-        } else if (value instanceof Instant) {
-            return new JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format((Instant) value));
+        } else if (value instanceof Date date) {
+            return new JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format(date.toInstant()));
+        } else if (value instanceof Instant instant) {
+            return new JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format(instant));
         } else if (value != null) {
             return new JsonPrimitive(value.toString());
         } else {
index ec8a1fd3ac68fb21aaa917bf7a936f9f02cf6637..358adc0df791539d0af96d2695bfdffa652c1118 100644 (file)
@@ -75,8 +75,8 @@ public class BridgeActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof DeconzBridgeHandler) {
-            this.handler = (DeconzBridgeHandler) handler;
+        if (handler instanceof DeconzBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
         }
     }
 
index 79f00578160ee3cb859ad34730b955a7530c8ccf..7e767d840313039483901dd28b6ad24b19f8f27f 100644 (file)
@@ -144,8 +144,8 @@ public class GroupActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof GroupThingHandler) {
-            this.handler = (GroupThingHandler) handler;
+        if (handler instanceof GroupThingHandler thingHandler) {
+            this.handler = thingHandler;
         }
     }
 
index 74894aafa695b84fe901d07801fb07a30d4a6bf0..caeb2e4007898c06916865710aaafc437ed214d3 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.deconz.internal.BindingConstants.*;
 
 import java.net.URI;
 import java.net.URL;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
@@ -48,7 +47,7 @@ public class BridgeDiscoveryParticipant implements UpnpDiscoveryParticipant {
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(BRIDGE_TYPE);
+        return Set.of(BRIDGE_TYPE);
     }
 
     @Override
index 0c391c44f77d4da94b2650890ebbf1ea6750ea59..653b80641404df2ac72a4b143571cfd2812d7940 100644 (file)
@@ -291,8 +291,8 @@ public class ThingDiscoveryService extends AbstractDiscoveryService implements D
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof DeconzBridgeHandler) {
-            this.handler = (DeconzBridgeHandler) handler;
+        if (handler instanceof DeconzBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
             this.bridgeUID = handler.getThing().getUID();
         }
     }
index 04a8144d56eb22716677b5a94821861a53a4d59d..1e0985c5b9c52d2de67b2ab480efa24ef3e03353 100644 (file)
@@ -119,10 +119,10 @@ public class GroupThingHandler extends DeconzBaseThingHandler {
                         newGroupAction.xy = new double[] { xy[0], xy[1] };
                         newGroupAction.bri = (int) (xy[2] * BRIGHTNESS_MAX);
                     }
-                } else if (command instanceof PercentType) {
-                    newGroupAction.bri = Util.fromPercentType((PercentType) command);
-                } else if (command instanceof DecimalType) {
-                    newGroupAction.bri = ((DecimalType) command).intValue();
+                } else if (command instanceof PercentType percentCommand) {
+                    newGroupAction.bri = Util.fromPercentType(percentCommand);
+                } else if (command instanceof DecimalType decimalCommand) {
+                    newGroupAction.bri = decimalCommand.intValue();
                 } else {
                     return;
                 }
index e0f4b455f876a30598d684df7796516e902545bc..7249119a49ac2ded024f18cc45de619c414efa7d 100644 (file)
@@ -17,7 +17,6 @@ import static org.openhab.core.library.unit.SIUnits.CELSIUS;
 import static org.openhab.core.library.unit.Units.PERCENT;
 
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -63,7 +62,7 @@ import com.google.gson.Gson;
  */
 @NonNullByDefault
 public class SensorThermostatThingHandler extends SensorBaseThingHandler {
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_THERMOSTAT);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_THERMOSTAT);
 
     private static final List<String> CONFIG_CHANNELS = List.of(CHANNEL_EXTERNAL_WINDOW_OPEN, CHANNEL_BATTERY_LEVEL,
             CHANNEL_BATTERY_LOW, CHANNEL_HEATSETPOINT, CHANNEL_TEMPERATURE_OFFSET, CHANNEL_THERMOSTAT_MODE,
@@ -102,8 +101,8 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
                 newConfig.offset = newOffset;
             }
             case CHANNEL_THERMOSTAT_MODE -> {
-                if (command instanceof StringType) {
-                    String thermostatMode = ((StringType) command).toString();
+                if (command instanceof StringType stringCommand) {
+                    String thermostatMode = stringCommand.toString();
                     try {
                         newConfig.mode = ThermostatMode.valueOf(thermostatMode);
                     } catch (IllegalArgumentException ex) {
@@ -205,8 +204,8 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
 
     private @Nullable Integer getTemperatureFromCommand(Command command) {
         BigDecimal newTemperature;
-        if (command instanceof DecimalType) {
-            newTemperature = ((DecimalType) command).toBigDecimal();
+        if (command instanceof DecimalType decimalCommand) {
+            newTemperature = decimalCommand.toBigDecimal();
         } else if (command instanceof QuantityType) {
             @SuppressWarnings("unchecked")
             QuantityType<Temperature> temperatureCelsius = ((QuantityType<Temperature>) command).toUnit(CELSIUS);
index 14f41ca82b099a1bae936737aef0aaf49d0fc770..3c952d85e509cd8e319bbe7f387a510400b929ce 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal;
 
 import static org.openhab.binding.denonmarantz.internal.DenonMarantzBindingConstants.THING_TYPE_AVR;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference;
 @NonNullByDefault
 public class DenonMarantzHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AVR);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AVR);
 
     private final HttpClient httpClient;
 
index effb5018c6da43e023d4272ee57e215a09f4af4e..cc9b916179bb8264b8e5ad0367a927a54ca39929 100644 (file)
@@ -165,10 +165,10 @@ public abstract class DenonMarantzConnector {
             cmd += "UP";
         } else if (command == IncreaseDecreaseType.DECREASE) {
             cmd += "DOWN";
-        } else if (command instanceof DecimalType) {
-            cmd += toDenonValue(((DecimalType) command));
-        } else if (command instanceof PercentType) {
-            cmd += percentToDenonValue(((PercentType) command).toBigDecimal());
+        } else if (command instanceof DecimalType decimalCommand) {
+            cmd += toDenonValue(decimalCommand);
+        } else if (command instanceof PercentType percentCommand) {
+            cmd += percentToDenonValue(percentCommand.toBigDecimal());
         } else {
             throw new UnsupportedCommandTypeException();
         }
index 2e9c73a838522fcf9c2134acb4d6d441a0e7a65e..f92c5746a854db65c6506a6038fa50b405086e02 100644 (file)
@@ -274,7 +274,7 @@ public class DenonMarantzTelnetConnector extends DenonMarantzConnector implement
      * Display info could contain some garbled text, attempt to clean it up.
      */
     private String cleanupDisplayInfo(String titleValue) {
-        byte firstByteRemoved[] = Arrays.copyOfRange(titleValue.getBytes(), 1, titleValue.getBytes().length);
+        byte[] firstByteRemoved = Arrays.copyOfRange(titleValue.getBytes(), 1, titleValue.getBytes().length);
         return new String(firstByteRemoved).replaceAll("[\u0000-\u001f]", "");
     }
 }
index 86756be823f4096947d591a09a2ea88bfb7e1bd3..fedf9f90685f380a6406a3320a2e11e40a966d91 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal.discovery;
 
 import static org.openhab.binding.denonmarantz.internal.DenonMarantzBindingConstants.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -66,7 +65,7 @@ public class DenonMarantzDiscoveryParticipant implements MDNSDiscoveryParticipan
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(THING_TYPE_AVR);
+        return Set.of(THING_TYPE_AVR);
     }
 
     @Override
@@ -115,9 +114,8 @@ public class DenonMarantzDiscoveryParticipant implements MDNSDiscoveryParticipan
             properties.put(Thing.PROPERTY_MODEL_ID, model);
 
             String label = friendlyName + " (" + vendor + ' ' + model + ")";
-            DiscoveryResult result = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withLabel(label)
+            return DiscoveryResultBuilder.create(thingUID).withProperties(properties).withLabel(label)
                     .withRepresentationProperty(Thing.PROPERTY_SERIAL_NUMBER).build();
-            return result;
 
         } else {
             return null;
index a0a694d5dea69596e67e5bdbd5852fff4dcfe1f2..6fff78d816957ee7be8d6453aa0995324c61baab 100644 (file)
@@ -24,7 +24,7 @@ public class OnOffAdapter extends XmlAdapter<String, Boolean> {
     @Override
     public Boolean unmarshal(String v) throws Exception {
         if (v != null) {
-            return Boolean.valueOf(v.toLowerCase().equals("on"));
+            return Boolean.valueOf("on".equals(v.toLowerCase()));
         }
 
         return Boolean.FALSE;
index a46aca2a18d70e826e054363df180b2379dd2d94..9ca8db11d373629e3c048c33f262c1965c8a2b48 100644 (file)
@@ -27,7 +27,7 @@ public class VolumeAdapter extends XmlAdapter<String, BigDecimal> {
 
     @Override
     public BigDecimal unmarshal(String v) throws Exception {
-        if (v != null && !v.trim().equals("--")) {
+        if (v != null && !"--".equals(v.trim())) {
             return new BigDecimal(v.trim()).add(DB_OFFSET);
         }
 
index 894d3aae0224a369e2d090de51a78cf9ed4da259..9171d49ed4348ebe21d96e2ee90417b19db2f297 100644 (file)
@@ -17,7 +17,6 @@ import java.text.SimpleDateFormat;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.function.BiConsumer;
@@ -236,9 +235,9 @@ public final class EventAttribute<VALUE_TYPE, STATE_TYPE extends State>
 
     private static List<String> listFromEventStatus(final @Nullable EventStatus value) {
         if (value == null) {
-            return Collections.emptyList();
+            return List.of();
         } else {
-            return Collections.singletonList(value.value());
+            return List.of(value.value());
         }
     }
 
@@ -247,14 +246,14 @@ public final class EventAttribute<VALUE_TYPE, STATE_TYPE extends State>
     }
 
     private static List<String> nullToEmptyList(@Nullable final List<String> value) {
-        return value == null ? Collections.emptyList() : value;
+        return value == null ? List.of() : value;
     }
 
     /**
      * Returns a list containing only the given value or empty list if value is <code>null</code>.
      */
     private static List<String> singletonList(@Nullable String value) {
-        return value == null ? Collections.emptyList() : Collections.singletonList(value);
+        return value == null ? List.of() : List.of(value);
     }
 
     private static OnOffType parseHidden(@Nullable Integer value) {
@@ -262,9 +261,7 @@ public final class EventAttribute<VALUE_TYPE, STATE_TYPE extends State>
     }
 
     private static Function<Event, @Nullable Date> getDate(final Function<Event, @Nullable String> getValue) {
-        return (final Event event) -> {
-            return parseDate(getValue.apply(event));
-        };
+        return (final Event event) -> parseDate(getValue.apply(event));
     }
 
     private static BiConsumer<Event, Date> setDate(final BiConsumer<Event, String> setter) {
@@ -331,7 +328,7 @@ public final class EventAttribute<VALUE_TYPE, STATE_TYPE extends State>
      */
     private static List<String> mapMessagesToList(final @Nullable List<Message> messages) {
         if (messages == null || messages.isEmpty()) {
-            return Collections.emptyList();
+            return List.of();
         } else {
             return messages //
                     .stream()//
@@ -360,18 +357,18 @@ public final class EventAttribute<VALUE_TYPE, STATE_TYPE extends State>
 
     private static List<String> mapIntegerToStringList(@Nullable Integer value) {
         if (value == null) {
-            return Collections.emptyList();
+            return List.of();
         } else {
-            return Collections.singletonList(String.valueOf(value));
+            return List.of(String.valueOf(value));
         }
     }
 
     private static List<String> mapDateToStringList(@Nullable Date value) {
         if (value == null) {
-            return Collections.emptyList();
+            return List.of();
         } else {
             synchronized (DATETIME_FORMAT) {
-                return Collections.singletonList(DATETIME_FORMAT.format(value));
+                return List.of(DATETIME_FORMAT.format(value));
             }
         }
     }
index 059c737774251b43c62ad4aeb474e8ff297b7c11..a444995f4ce53309db564859547430f35c897f09 100644 (file)
@@ -121,7 +121,7 @@ public final class TripLabelAttribute<VALUE_TYPE, STATE_TYPE extends State> exte
         if (value == null) {
             return Collections.emptyList();
         } else {
-            return Collections.singletonList(value.value());
+            return List.of(value.value());
         }
     }
 
@@ -129,7 +129,7 @@ public final class TripLabelAttribute<VALUE_TYPE, STATE_TYPE extends State> exte
      * Returns a list containing only the given value or empty list if value is <code>null</code>.
      */
     private static List<String> singletonList(@Nullable String value) {
-        return value == null ? Collections.emptyList() : Collections.singletonList(value);
+        return value == null ? Collections.emptyList() : List.of(value);
     }
 
     /**
index f28e6d3e51b61f654740fc9a78c5d74d87e7f2ff..7bb0c2a9e66f72032b5603238d60061d81acf75f 100644 (file)
@@ -14,9 +14,9 @@ package org.openhab.binding.digiplex.internal.discovery;
 
 import static org.openhab.binding.digiplex.internal.DigiplexBindingConstants.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -53,7 +53,7 @@ public class DigiplexDiscoveryService extends AbstractDiscoveryService
     private @Nullable DigiplexBridgeHandler bridgeHandler;
 
     public DigiplexDiscoveryService() {
-        super(Collections.singleton(THING_TYPE_ZONE), DISCOVERY_TIMEOUT, false);
+        super(Set.of(THING_TYPE_ZONE), DISCOVERY_TIMEOUT, false);
     }
 
     @Override
@@ -100,9 +100,8 @@ public class DigiplexDiscoveryService extends AbstractDiscoveryService
     }
 
     private boolean isDefaultName(ZoneLabelResponse response) {
-        return ZONE_DEFAULT_NAMES.stream().anyMatch(format -> {
-            return String.format(format, response.zoneNo).equals(response.zoneName);
-        });
+        return ZONE_DEFAULT_NAMES.stream()
+                .anyMatch(format -> String.format(format, response.zoneNo).equals(response.zoneName));
     }
 
     @Override
@@ -127,8 +126,8 @@ public class DigiplexDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof DigiplexBridgeHandler) {
-            bridgeHandler = (DigiplexBridgeHandler) handler;
+        if (handler instanceof DigiplexBridgeHandler digiplexBridgeHandler) {
+            bridgeHandler = digiplexBridgeHandler;
             bridgeHandler.registerMessageHandler(this);
         }
     }
index 7fecd10916c42990bab6a1b7dd922bedd3230cdb..4012f79faae234a1363adb6df23921c03289b504 100644 (file)
@@ -121,8 +121,8 @@ public class DigiplexAreaHandler extends BaseThingHandler {
             case AREA_CONTROL:
                 if (command == RefreshType.REFRESH) {
                     updateState(AREA_CONTROL, lastCommandResult);
-                } else if (command instanceof StringType) {
-                    processControlCommand(((StringType) command).toString());
+                } else if (command instanceof StringType stringCommand) {
+                    processControlCommand(stringCommand.toString());
                 }
                 break;
         }
index 546ab0d62a70154103ca8bc0d9695084b0cf3486..76adaa1704f76673ea073329c2c1ebfc38f4f27e 100644 (file)
@@ -18,7 +18,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TooManyListenersException;
@@ -272,7 +272,7 @@ public class DigiplexBridgeHandler extends BaseBridgeHandler implements SerialPo
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(DigiplexDiscoveryService.class);
+        return List.of(DigiplexDiscoveryService.class);
     }
 
     private class BridgeMessageHandler implements DigiplexMessageHandler {
@@ -367,7 +367,7 @@ public class DigiplexBridgeHandler extends BaseBridgeHandler implements SerialPo
                     stream.write(request.getSerialMessage().getBytes());
                     stream.flush();
                     updateState(BRIDGE_MESSAGES_SENT, new DecimalType(messagesSent.incrementAndGet()));
-                    logger.debug("message sent: '{}'", request.getSerialMessage().replaceAll("\r", ""));
+                    logger.debug("message sent: '{}'", request.getSerialMessage().replace("\r", ""));
                     Thread.sleep(SLEEP_TIME); // do not flood PRT3 with messages as it creates unpredictable responses
                 } catch (IOException e) {
                     handleCommunicationError();
index a86f0497b78d8aef95b07725ede5ac308098435b..685952bf68831aa4eebb2beddef0506d413eea38 100644 (file)
@@ -71,10 +71,13 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
             if (dSSUID != null) {
                 return super.createThing(thingTypeUID, configuration, dSSUID, null);
             } else {
-                logger.error("Can't generate thing UID for thing type {}"
-                        + ", because digitalSTROM-Server is not reachable. Please check these points:\n"
-                        + "Are the server address and portnumber correct?\n" + "Is the server turned on?\n"
-                        + "Is the network configured correctly?", thingTypeUID);
+                logger.error("""
+                        Can't generate thing UID for thing type {}\
+                        , because digitalSTROM-Server is not reachable. Please check these points:
+                        Are the server address and portnumber correct?
+                        Is the server turned on?
+                        Is the network configured correctly?\
+                        """, thingTypeUID);
                 return null;
             }
         }
index 52625faa11699d05294076a380bead5ca09e570d..425772bcd3bec7d3ae3fc9e26894ba7d372b454f 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.digitalstrom.internal.discovery;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -48,7 +47,7 @@ public class BridgeMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE);
+        return Set.of(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE);
     }
 
     @Override
index 762da5f004a4b90058d344ec1556d67d60fae98e..b34efc2ae55167bddffe32a232960d06e64664e4 100644 (file)
@@ -108,8 +108,7 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
 
     private void onDeviceAddedInternal(GeneralDeviceInformation device) {
         boolean isSupported = false;
-        if (device instanceof Device) {
-            Device tempDevice = (Device) device;
+        if (device instanceof Device tempDevice) {
             if ((tempDevice.isSensorDevice() && deviceType.equals(tempDevice.getHWinfo().replaceAll("-", "")))
                     || (deviceType.equals(tempDevice.getHWinfo().substring(0, 2))
                             && (tempDevice.isDeviceWithOutput() || tempDevice.isBinaryInputDevice())
@@ -135,18 +134,17 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
 
                 thingDiscovered(discoveryResult);
             } else {
-                if (device instanceof Device) {
-                    logger.debug("Discovered unsupported device hardware type '{}' with uid {}",
-                            ((Device) device).getHWinfo(), device.getDSUID());
+                if (device instanceof Device device1) {
+                    logger.debug("Discovered unsupported device hardware type '{}' with uid {}", device1.getHWinfo(),
+                            device.getDSUID());
                 }
             }
         } else {
-            if (device instanceof Device) {
-                logger.debug(
-                        "Discovered device with disabled or no output mode. Device was not added to inbox. "
-                                + "Device information: hardware info: {}, dSUID: {}, device-name: {}, output value: {}",
-                        ((Device) device).getHWinfo(), device.getDSUID(), device.getName(),
-                        ((Device) device).getOutputMode());
+            if (device instanceof Device device1) {
+                logger.debug("""
+                        Discovered device with disabled or no output mode. Device was not added to inbox. \
+                        Device information: hardware info: {}, dSUID: {}, device-name: {}, output value: {}\
+                        """, device1.getHWinfo(), device.getDSUID(), device.getName(), device1.getOutputMode());
             }
         }
     }
@@ -154,8 +152,7 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
     private ThingUID getThingUID(GeneralDeviceInformation device) {
         ThingUID bridgeUID = bridgeHandler.getThing().getUID();
         ThingTypeUID thingTypeUID = null;
-        if (device instanceof Device) {
-            Device tempDevice = (Device) device;
+        if (device instanceof Device tempDevice) {
             thingTypeUID = new ThingTypeUID(BINDING_ID, tempDevice.getHWinfo().substring(0, 2));
             if (tempDevice.isSensorDevice() && deviceType.equals(tempDevice.getHWinfo().replaceAll("-", ""))) {
                 thingTypeUID = new ThingTypeUID(BINDING_ID, deviceType);
@@ -166,8 +163,7 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
         }
         if (getSupportedThingTypes().contains(thingTypeUID)) {
             String thingDeviceId = device.getDSID().toString();
-            ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, thingDeviceId);
-            return thingUID;
+            return new ThingUID(thingTypeUID, bridgeUID, thingDeviceId);
         } else {
             return null;
         }
index 5893131873c88980350093e84042d5bea6f69671..5f761457a8e96c3928f10249bcf8bbd72a0e0fb9 100644 (file)
@@ -96,22 +96,19 @@ public class DiscoveryServiceManager
     public void unregisterDiscoveryServices(BundleContext bundleContext) {
         if (discoveryServices != null) {
             for (AbstractDiscoveryService service : discoveryServices.values()) {
-                if (service instanceof SceneDiscoveryService) {
-                    SceneDiscoveryService sceneDisServ = (SceneDiscoveryService) service;
+                if (service instanceof SceneDiscoveryService sceneDisServ) {
                     ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(bridgeUID + sceneDisServ.getID());
                     sceneDisServ.deactivate();
                     serviceReg.unregister();
                     discoveryServiceRegs.remove(bridgeUID + sceneDisServ.getID());
                 }
-                if (service instanceof DeviceDiscoveryService) {
-                    DeviceDiscoveryService devDisServ = (DeviceDiscoveryService) service;
+                if (service instanceof DeviceDiscoveryService devDisServ) {
                     ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(bridgeUID + devDisServ.getID());
                     devDisServ.deactivate();
                     serviceReg.unregister();
                     discoveryServiceRegs.remove(bridgeUID + devDisServ.getID());
                 }
-                if (service instanceof ZoneTemperatureControlDiscoveryService) {
-                    ZoneTemperatureControlDiscoveryService devDisServ = (ZoneTemperatureControlDiscoveryService) service;
+                if (service instanceof ZoneTemperatureControlDiscoveryService devDisServ) {
                     ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(bridgeUID + devDisServ.getID());
                     devDisServ.deactivate();
                     serviceReg.unregister();
@@ -130,18 +127,17 @@ public class DiscoveryServiceManager
     public void registerDiscoveryServices(BundleContext bundleContext) {
         if (discoveryServices != null) {
             for (AbstractDiscoveryService service : discoveryServices.values()) {
-                if (service instanceof SceneDiscoveryService) {
-                    this.discoveryServiceRegs.put(bridgeUID + ((SceneDiscoveryService) service).getID(), bundleContext
+                if (service instanceof SceneDiscoveryService discoveryService) {
+                    this.discoveryServiceRegs.put(bridgeUID + discoveryService.getID(), bundleContext
                             .registerService(DiscoveryService.class.getName(), service, new Hashtable<>()));
                 }
-                if (service instanceof DeviceDiscoveryService) {
-                    this.discoveryServiceRegs.put(bridgeUID + ((DeviceDiscoveryService) service).getID(), bundleContext
+                if (service instanceof DeviceDiscoveryService discoveryService) {
+                    this.discoveryServiceRegs.put(bridgeUID + discoveryService.getID(), bundleContext
                             .registerService(DiscoveryService.class.getName(), service, new Hashtable<>()));
                 }
-                if (service instanceof ZoneTemperatureControlDiscoveryService) {
-                    this.discoveryServiceRegs
-                            .put(bridgeUID + ((ZoneTemperatureControlDiscoveryService) service).getID(), bundleContext
-                                    .registerService(DiscoveryService.class.getName(), service, new Hashtable<>()));
+                if (service instanceof ZoneTemperatureControlDiscoveryService discoveryService) {
+                    this.discoveryServiceRegs.put(bridgeUID + discoveryService.getID(), bundleContext
+                            .registerService(DiscoveryService.class.getName(), service, new Hashtable<>()));
                 }
             }
         }
@@ -178,10 +174,10 @@ public class DiscoveryServiceManager
 
     @Override
     public void onDeviceRemoved(GeneralDeviceInformation device) {
-        if (device instanceof Device) {
-            String id = ((Device) device).getHWinfo().substring(0, 2);
-            if (((Device) device).isSensorDevice()) {
-                id = ((Device) device).getHWinfo().replace("-", "");
+        if (device instanceof Device dev) {
+            String id = dev.getHWinfo().substring(0, 2);
+            if (dev.isSensorDevice()) {
+                id = dev.getHWinfo().replace("-", "");
             }
             if (discoveryServices.get(id) != null) {
                 ((DeviceDiscoveryService) discoveryServices.get(id)).onDeviceRemoved(device);
@@ -198,10 +194,10 @@ public class DiscoveryServiceManager
     @Override
     public void onDeviceAdded(GeneralDeviceInformation device) {
         try {
-            if (device instanceof Device) {
-                String id = ((Device) device).getHWinfo().substring(0, 2);
-                if (((Device) device).isSensorDevice()) {
-                    id = ((Device) device).getHWinfo();
+            if (device instanceof Device dev) {
+                String id = dev.getHWinfo().substring(0, 2);
+                if (dev.isSensorDevice()) {
+                    id = dev.getHWinfo();
                 }
                 if (discoveryServices.get(id) != null) {
                     ((DeviceDiscoveryService) discoveryServices.get(id)).onDeviceAdded(device);
index d275567a0856e34e6d7f7d9496b3493ec19e4959..c4c4ddfd0a1144ef4c85110f345ffcb488989a6b 100644 (file)
@@ -173,8 +173,7 @@ public class SceneDiscoveryService extends AbstractDiscoveryService {
 
         if (getSupportedThingTypes().contains(thingTypeUID)) {
             String thingSceneId = scene.getID();
-            ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, thingSceneId);
-            return thingUID;
+            return new ThingUID(thingTypeUID, bridgeUID, thingSceneId);
         } else {
             return null;
         }
index 7b57652b7cefca23d3920a593d8f3e5e6dd4dcab..03b1472a365f7313b394f5e116254b0674ced045 100644 (file)
@@ -117,8 +117,7 @@ public class ZoneTemperatureControlDiscoveryService extends AbstractDiscoverySer
         ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, thingTypeID);
         if (getSupportedThingTypes().contains(thingTypeUID)) {
             String thingID = tempControlStatus.getZoneID().toString();
-            ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, thingID);
-            return thingUID;
+            return new ThingUID(thingTypeUID, bridgeUID, thingID);
         } else {
             return null;
         }
index 8d336eb021a239393ea83aaffe607fcd8174b68a..20d1228f818920d4cd8025cb3b879eb943808aba 100644 (file)
@@ -17,7 +17,6 @@ import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConst
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -95,7 +94,7 @@ public class BridgeHandler extends BaseBridgeHandler
     /**
      * Contains all supported thing types of this handler
      */
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_DSS_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_DSS_BRIDGE);
 
     private static final long RECONNECT_TRACKER_INTERVAL = 15;
 
@@ -631,8 +630,10 @@ public class BridgeHandler extends BaseBridgeHandler
             switch (reason) {
                 case WRONG_APP_TOKEN:
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                            "User defined Application-Token is wrong. "
-                                    + "Please set user name and password to generate an Application-Token or set a valid Application-Token.");
+                            """
+                                    User defined Application-Token is wrong. \
+                                    Please set user name and password to generate an Application-Token or set a valid Application-Token.\
+                                    """);
                     stopServices();
                     return;
                 case WRONG_USER_OR_PASSWORD:
@@ -655,10 +656,12 @@ public class BridgeHandler extends BaseBridgeHandler
                         return;
                     }
                 case HOST_NOT_FOUND:
-                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
-                            "Server not found! Please check these points:\n" + " - Is digitalSTROM-Server turned on?\n"
-                                    + " - Is the host address correct?\n"
-                                    + " - Is the ethernet cable connection established?");
+                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, """
+                            Server not found! Please check these points:
+                             - Is digitalSTROM-Server turned on?
+                             - Is the host address correct?
+                             - Is the ethernet cable connection established?\
+                            """);
                     break;
                 case UNKNOWN_HOST:
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
index cd169663c7fbc1c317196ff5025232e1228c542b..9f70548a605d9f7762fcd6313ba8e9b1f7fb4fdb 100644 (file)
@@ -111,8 +111,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
             }
             ThingHandler handler = bridge.getHandler();
 
-            if (handler instanceof BridgeHandler) {
-                dssBridgeHandler = (BridgeHandler) handler;
+            if (handler instanceof BridgeHandler bridgeHandler) {
+                dssBridgeHandler = bridgeHandler;
             } else {
                 return null;
             }
@@ -179,8 +179,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
 
     @Override
     public void onDeviceRemoved(GeneralDeviceInformation device) {
-        if (device instanceof Circuit) {
-            this.circuit = (Circuit) device;
+        if (device instanceof Circuit circ) {
+            this.circuit = circ;
             if (getThing().getStatus().equals(ThingStatus.ONLINE)) {
                 if (!circuit.isPresent()) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,
@@ -197,8 +197,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
 
     @Override
     public void onDeviceAdded(GeneralDeviceInformation device) {
-        if (device instanceof Circuit) {
-            this.circuit = (Circuit) device;
+        if (device instanceof Circuit circ) {
+            this.circuit = circ;
             if (this.circuit.isPresent()) {
                 ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
                 updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
index f33f1bbc85186dab8071d4ac0280b69764213824..745a6915f24d440b0c8473be14b2100e24784072 100644 (file)
@@ -204,9 +204,9 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
             }
         } else if (!device.isShade()) {
             if (DsChannelTypeProvider.isOutputChannel(channelUID.getId())) {
-                if (command instanceof PercentType) {
+                if (command instanceof PercentType percentCommand) {
                     device.setOutputValue(
-                            (short) fromPercentToValue(((PercentType) command).intValue(), device.getMaxOutputValue()));
+                            (short) fromPercentToValue(percentCommand.intValue(), device.getMaxOutputValue()));
                 } else if (command instanceof OnOffType) {
                     if (OnOffType.ON.equals(command)) {
                         device.setIsOn(true);
@@ -219,17 +219,17 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
                     } else {
                         device.decrease();
                     }
-                } else if (command instanceof StringType) {
-                    device.setOutputValue(Short.parseShort(((StringType) command).toString()));
+                } else if (command instanceof StringType stringCommand) {
+                    device.setOutputValue(Short.parseShort(stringCommand.toString()));
                 }
             } else {
                 logger.debug("Command sent to an unknown channel id: {}", channelUID);
             }
         } else {
             if (channelUID.getId().contains(DsChannelTypeProvider.ANGLE)) {
-                if (command instanceof PercentType) {
+                if (command instanceof PercentType percentCommand) {
                     device.setAnglePosition(
-                            (short) fromPercentToValue(((PercentType) command).intValue(), device.getMaxSlatAngle()));
+                            (short) fromPercentToValue(percentCommand.intValue(), device.getMaxSlatAngle()));
                 } else if (command instanceof OnOffType) {
                     if (OnOffType.ON.equals(command)) {
                         device.setAnglePosition(device.getMaxSlatAngle());
@@ -244,9 +244,9 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
                     }
                 }
             } else if (channelUID.getId().contains(DsChannelTypeProvider.SHADE)) {
-                if (command instanceof PercentType) {
-                    int percent = ((PercentType) command).intValue();
-                    if (!device.getHWinfo().equals("GR-KL200")) {
+                if (command instanceof PercentType percentCommand) {
+                    int percent = percentCommand.intValue();
+                    if (!"GR-KL200".equals(device.getHWinfo())) {
                         percent = 100 - percent;
                     }
                     device.setSlatPosition(fromPercentToValue(percent, device.getMaxSlatPosition()));
@@ -291,8 +291,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
             }
             ThingHandler handler = bridge.getHandler();
 
-            if (handler instanceof BridgeHandler) {
-                dssBridgeHandler = (BridgeHandler) handler;
+            if (handler instanceof BridgeHandler bridgeHandler) {
+                dssBridgeHandler = bridgeHandler;
             } else {
                 return null;
             }
@@ -398,7 +398,7 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
                         default:
                             return;
                     }
-                    if (!device.getHWinfo().equals("GR-KL210")) {
+                    if (!"GR-KL210".equals(device.getHWinfo())) {
                         percent = 100 - percent;
                     }
                     updateState(DsChannelTypeProvider.SHADE, new PercentType(percent));
@@ -418,10 +418,10 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
 
     @Override
     public synchronized void onDeviceRemoved(GeneralDeviceInformation device) {
-        if (device instanceof Device) {
-            this.device = (Device) device;
+        if (device instanceof Device dev) {
+            this.device = dev;
             if (this.getThing().getStatus().equals(ThingStatus.ONLINE)) {
-                if (!((Device) device).isPresent()) {
+                if (!dev.isPresent()) {
                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,
                             "Device is not present in the digitalSTROM-System.");
                 } else {
@@ -436,8 +436,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
 
     @Override
     public synchronized void onDeviceAdded(GeneralDeviceInformation device) {
-        if (device instanceof Device) {
-            this.device = (Device) device;
+        if (device instanceof Device dev) {
+            this.device = dev;
             if (this.device.isPresent()) {
                 ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
                 updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
@@ -458,11 +458,11 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
                     checkOutputChannel();
                 } else if (this.device.isBlind()) {
                     // load channel for set the angle of jalousie devices
-                    ApplicationGroup.Color color = ((Device) device).getFunctionalColorGroup() != null
-                            ? ((Device) device).getFunctionalColorGroup().getColor()
+                    ApplicationGroup.Color color = dev.getFunctionalColorGroup() != null
+                            ? dev.getFunctionalColorGroup().getColor()
                             : null;
-                    String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(color,
-                            ((Device) device).getOutputMode(), ((Device) device).getOutputChannels());
+                    String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(color, dev.getOutputMode(),
+                            dev.getOutputChannels());
                     loadOutputChannel(new ChannelTypeUID(BINDING_ID, channelTypeID),
                             DsChannelTypeProvider.getItemType(channelTypeID));
                 }
@@ -595,8 +595,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
         if (loadedSensorChannels == null) {
             loadedSensorChannels = new LinkedList<>();
         }
-        if (!loadedSensorChannels.contains(sensorChannelType.toString())) {
-            return loadedSensorChannels.add(sensorChannelType.toString());
+        if (!loadedSensorChannels.contains(sensorChannelType)) {
+            return loadedSensorChannels.add(sensorChannelType);
         }
         return false;
     }
index e632698e83d01d92bdb681b24b1ba9547ddce710..1b87feae7794052383347797feb8dc647dfe2eca 100644 (file)
@@ -312,8 +312,8 @@ public class SceneHandler extends BaseThingHandler implements SceneStatusListene
             }
             ThingHandler handler = bridge.getHandler();
 
-            if (handler instanceof BridgeHandler) {
-                this.bridgeHandler = (BridgeHandler) handler;
+            if (handler instanceof BridgeHandler bridgeHandler) {
+                this.bridgeHandler = bridgeHandler;
             } else {
                 logger.debug("BridgeHandler cannot be found");
                 return null;
index 3fbdf4310ff3dded15ab1230da90fcdcaae36aca..417606d6b3b5184d945b729a5eaf9db83438224e 100644 (file)
@@ -28,6 +28,7 @@ import org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlSt
 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
 import org.openhab.binding.digitalstrom.internal.lib.listener.TemperatureControlStatusListener;
 import org.openhab.binding.digitalstrom.internal.lib.manager.StructureManager;
+import org.openhab.binding.digitalstrom.internal.lib.manager.impl.TemperatureControlManager;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.ApplicationGroup;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.OutputChannelEnum;
 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.OutputModeEnum;
@@ -257,8 +258,8 @@ public class ZoneTemperatureControlHandler extends BaseThingHandler implements T
             }
             ThingHandler handler = bridge.getHandler();
 
-            if (handler instanceof BridgeHandler) {
-                dssBridgeHandler = (BridgeHandler) handler;
+            if (handler instanceof BridgeHandler bridgeHandler) {
+                dssBridgeHandler = bridgeHandler;
             } else {
                 return null;
             }
index 35f742d8dc2111752804ebe6b2e85140a2301d2a..5bdc50e7edbbcb07318964fea1fc2c826935962e 100644 (file)
@@ -610,9 +610,7 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
 
         @Override
         public boolean equals(Object object) {
-            return object instanceof TrashDevice
-                    ? this.device.getDSID().equals(((TrashDevice) object).getDevice().getDSID())
-                    : false;
+            return object instanceof TrashDevice td ? this.device.getDSID().equals(td.getDevice().getDSID()) : false;
         }
     }
 
index 7f101e5df000667d212301c5fcb3673dda7d2a95..15c9f8d564a31cd603831bcdb7abd92366e451d1 100644 (file)
@@ -464,7 +464,7 @@ public class SceneManagerImpl implements SceneManager {
 
     @Override
     public void scenesGenerated(char[] scenesGenerated) {
-        if (String.valueOf(scenesGenerated).equals("1111")) {
+        if ("1111".equals(String.valueOf(scenesGenerated))) {
             this.scenesGenerated = true;
             stateChanged(ManagerStates.RUNNING);
         }
index c3b12b2c45c95732bba7706f411b81a273e28321..59fb21bcf295cc9cb4744d0a68bae94950e80749 100644 (file)
@@ -79,8 +79,7 @@ public class DeviceConsumptionSensorJob implements SensorJob {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof DeviceConsumptionSensorJob) {
-            DeviceConsumptionSensorJob other = (DeviceConsumptionSensorJob) obj;
+        if (obj instanceof DeviceConsumptionSensorJob other) {
             String device = this.device.getDSID().getValue() + this.sensorType.getSensorType();
             return device.equals(other.device.getDSID().getValue() + other.sensorType.getSensorType());
         }
index ffb7d4473035d37f1f84897d2dbbc9366aa9fa99..6f15b4f2634573f2393b35bc8bf643f33138a716 100644 (file)
@@ -85,8 +85,7 @@ public class DeviceOutputValueSensorJob implements SensorJob {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof DeviceOutputValueSensorJob) {
-            DeviceOutputValueSensorJob other = (DeviceOutputValueSensorJob) obj;
+        if (obj instanceof DeviceOutputValueSensorJob other) {
             String key = this.device.getDSID().getValue() + this.index;
             return key.equals((other.device.getDSID().getValue() + other.index));
         }
index 984aa744ac800c73978cc46e5d0de3435b83edfa..b45d21a94478e92d4d737db92ef4ef8f8baac26b 100644 (file)
@@ -62,8 +62,7 @@ public class SceneConfigReadingJob implements SensorJob {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof SceneConfigReadingJob) {
-            SceneConfigReadingJob other = (SceneConfigReadingJob) obj;
+        if (obj instanceof SceneConfigReadingJob other) {
             String str = other.device.getDSID().getValue() + "-" + other.sceneID;
             return (this.device.getDSID().getValue() + "-" + this.sceneID).equals(str);
         }
index d84e34783395eee5550aff67d7e9c8acce1587fa..de430978ae258e7a9dfa3bf141ca11ce2176ca72 100644 (file)
@@ -65,8 +65,7 @@ public class SceneOutputValueReadingJob implements SensorJob {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof SceneOutputValueReadingJob) {
-            SceneOutputValueReadingJob other = (SceneOutputValueReadingJob) obj;
+        if (obj instanceof SceneOutputValueReadingJob other) {
             String str = other.device.getDSID().getValue() + "-" + other.sceneID;
             return (this.device.getDSID().getValue() + "-" + this.sceneID).equals(str);
         }
index 9bac1066652deff63f7cf2e39dbbead919179823..40840abdf927caca5b88446dbab9f9b1467eee26 100644 (file)
@@ -931,8 +931,9 @@ public class DsAPIImpl implements DsAPI {
                             .addRequestClass(ClassKeys.ZONE).addFunction(FunctionKeys.SET_TEMEPERATURE_CONTROL_VALUE)
                             .addDefaultZoneParameter(sessionToken, zoneID, zoneName);
                     for (Object[] objAry : controlValues) {
-                        if (objAry.length == 2 && objAry[0] instanceof String && objAry[1] instanceof Integer) {
-                            builder.addParameter((String) objAry[0], SimpleRequestBuilder.objectToString(objAry[1]));
+                        if (objAry.length == 2 && objAry[0] instanceof String stringValue
+                                && objAry[1] instanceof Integer) {
+                            builder.addParameter(stringValue, SimpleRequestBuilder.objectToString(objAry[1]));
                         } else {
                             builder.buildRequestString();
                             throw new IllegalArgumentException(
index 562d7d66305d4336b039f0b7220baa1e1b3daf09..6e656dc632210d1dd969f8fcd632f135c6b57fb7 100644 (file)
@@ -61,7 +61,7 @@ public class JSONResponseHandler {
      * @return jsonObject
      */
     public static JsonObject toJsonObject(String jsonResponse) {
-        if (jsonResponse != null && !jsonResponse.trim().equals("")) {
+        if (jsonResponse != null && !"".equals(jsonResponse.trim())) {
             try {
                 return (JsonObject) JsonParser.parseString(jsonResponse);
             } catch (JsonParseException e) {
index 9eb712e1ac6a55c70cb6408e82ce93817534561f..962868bbabdce3238d8da506f7e5bec5b39a0a04 100644 (file)
@@ -283,11 +283,11 @@ public class SimpleRequestBuilder {
         if (obj == null) {
             return null;
         }
-        if (obj instanceof DSID) {
-            return ((DSID) obj).getValue();
+        if (obj instanceof DSID id) {
+            return id.getValue();
         }
-        if (obj instanceof Number) {
-            return ((Number) obj).intValue() > -1 ? obj.toString() : null;
+        if (obj instanceof Number number) {
+            return number.intValue() > -1 ? obj.toString() : null;
         }
         return obj.toString();
     }
index afb279f521d28c8044aa2c0766b00728b2991fe4..1ad42098e3cbad1ba3e7c862c1430591df14623a 100644 (file)
@@ -54,8 +54,8 @@ public class DSID {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof DSID) {
-            return ((DSID) obj).getValue().equals(this.getValue());
+        if (obj instanceof DSID id) {
+            return id.getValue().equals(this.getValue());
         }
         return false;
     }
index 856cf4dc877e8ddf61ca418161b259724eff615c..f33dfde7b163283c51ae1837397e4a7021f3ff8c 100644 (file)
@@ -47,8 +47,8 @@ public class DSUID {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof DSUID) {
-            return ((DSUID) obj).getValue().equals(this.getValue());
+        if (obj instanceof DSUID id) {
+            return id.getValue().equals(this.getValue());
         }
         return false;
     }
index 7db29e6bcdebf10da290a452e6eb3dd0f9f87726..21151283318b88eab02dabc9c2e2a985efa5040a 100644 (file)
@@ -85,8 +85,8 @@ public class DeviceStateUpdateImpl implements DeviceStateUpdate {
             if (value instanceof Short) {
                 return ((Short) value).intValue();
             }
-            if (value instanceof String) {
-                return Integer.parseInt((String) value);
+            if (value instanceof String string) {
+                return Integer.parseInt(string);
             }
         } catch (Exception e) {
             throw new ClassCastException();
@@ -105,8 +105,8 @@ public class DeviceStateUpdateImpl implements DeviceStateUpdate {
         if (value instanceof Short) {
             return ((Short) value).toString();
         }
-        if (value instanceof String) {
-            return (String) value;
+        if (value instanceof String string) {
+            return string;
         }
         throw new ClassCastException();
     }
@@ -128,8 +128,8 @@ public class DeviceStateUpdateImpl implements DeviceStateUpdate {
             if (value instanceof Short) {
                 return (Short) value;
             }
-            if (value instanceof String) {
-                return Short.parseShort((String) value);
+            if (value instanceof String string) {
+                return Short.parseShort(string);
             }
         } catch (Exception e) {
             throw new ClassCastException();
@@ -149,8 +149,8 @@ public class DeviceStateUpdateImpl implements DeviceStateUpdate {
             if (value instanceof Short) {
                 return ((Short) value).floatValue();
             }
-            if (value instanceof String) {
-                return Float.parseFloat((String) value);
+            if (value instanceof String string) {
+                return Float.parseFloat(string);
             }
         } catch (Exception e) {
             throw new ClassCastException();
index 0f83bf63007268ac031718120119a98cda00ac42..8b4588543742bca3ee81a498f157b9417e171e91 100644 (file)
@@ -952,8 +952,7 @@ public class DeviceImpl extends AbstractGeneralDeviceInformations implements Dev
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof Device) {
-            Device device = (Device) obj;
+        if (obj instanceof Device device) {
             return device.getDSID().equals(this.getDSID());
         }
         return false;
@@ -1781,7 +1780,7 @@ public class DeviceImpl extends AbstractGeneralDeviceInformations implements Dev
         String[] scenes = propertries.split("\n");
         for (int i = 0; i < scenes.length; i++) {
             logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid, i);
-            String[] sceneIdToConfig = scenes[i].replaceAll(" ", "").split("=");
+            String[] sceneIdToConfig = scenes[i].replace(" ", "").split("=");
             String[] sceneParm = sceneIdToConfig[1].split(",");
             JSONDeviceSceneSpecImpl sceneSpecNew = null;
             int sceneValue = -1;
index 4b405667cc21cea5da890bf288ca66b1132bd607..d5525681178d8bf3af0a9988c95fca367cc0ff3d 100644 (file)
@@ -75,8 +75,7 @@ public class JSONDetailedGroupInfoImpl implements DetailedGroupInfo {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof DetailedGroupInfo) {
-            DetailedGroupInfo group = (DetailedGroupInfo) obj;
+        if (obj instanceof DetailedGroupInfo group) {
             return group.getGroupID() == this.getGroupID();
         }
         return false;
index ebaff0b977d887416595ac6d646ee46b6859fd0f..77aaf5f01a6a2ea7a3bbc8dbfcebd37b29d19fd3 100644 (file)
@@ -129,8 +129,7 @@ public class JSONZoneImpl implements Zone {
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof Zone) {
-            Zone other = (Zone) obj;
+        if (obj instanceof Zone other) {
             return (other.getZoneId() == this.getZoneId());
         }
         return false;
index cf11f1ece7519495c409baa1b74b9a29da668ed1..864bb442026bb67f217ac3e80b508904a0dc616d 100644 (file)
@@ -62,7 +62,7 @@ public class DsDeviceThingTypeProvider extends BaseDsI18n implements ThingTypePr
      * @author Michael Ochel - Initial contribution
      * @author Matthias Siegele - Initial contribution
      */
-    public static enum SupportedThingTypes {
+    public enum SupportedThingTypes {
         // ThingType, responsible ThingHanlder, Device config-description with power-sensors
         GE(DeviceHandler.class.getSimpleName(), true),
         GR(DeviceHandler.class.getSimpleName(), false),
index f034752f988a03b87d73c4452da931c30b6f901f..929756ed2a04ad3bfd1b500c92a5b0442c43c1f1 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.dlinksmarthome.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public class DLinkSmartHomeBindingConstants {
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_DCHS150 = new ThingTypeUID(BINDING_ID, "DCH-S150");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_DCHS150);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_DCHS150);
 
     // Motion trigger channel
     public static final String MOTION = "motion";
index e87dc0890c3f93fc4b0f10b7c0e811bbd9c87a87..144e402df0692e2d26085054725e33433cb26b9d 100644 (file)
@@ -87,7 +87,7 @@ public class DLinkSmartHomeDiscoveryParticipant implements MDNSDiscoveryParticip
 
         if (model == null) {
             return null;
-        } else if (model.equals("DCH-S150")) {
+        } else if ("DCH-S150".equals(model)) {
             return THING_TYPE_DCHS150;
         } else {
             logger.debug("D-Link HNAP Type: {}", model);
index 7b600ca4064a687fffc37a46067954bb9b6d8ab6..30e255bd4c47ba3176a9c1b468cc67bb7a22a728 100644 (file)
@@ -79,7 +79,7 @@ public class DmxBindingConstants {
     public static final ChannelTypeUID MUTE_CHANNEL_TYPEUID = new ChannelTypeUID(BINDING_ID, CHANNEL_MUTE);
 
     // Listener Type for channel updates
-    public static enum ListenerType {
+    public enum ListenerType {
         VALUE,
         ACTION
     }
index dcbd8e466721bd909992e194575004947a3201f7..c2727be2179bdd433c56c0d27c20b7f9e2889209 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.CHANNEL_MUTE;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -275,6 +274,6 @@ public abstract class DmxBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(DmxActions.class);
+        return List.of(DmxActions.class);
     }
 }
index 2b8f258d83cf30cfe5e65a2a788774e32dd2c3cb..0662cb640bb473aa0c5290eea334289eed0f4950 100644 (file)
@@ -60,26 +60,19 @@ public class DmxHandlerFactory extends BaseThingHandlerFactory {
     protected @Nullable ThingHandler createHandler(Thing thing) {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
         if (thingTypeUID.equals(THING_TYPE_ARTNET_BRIDGE)) {
-            ArtnetBridgeHandler handler = new ArtnetBridgeHandler((Bridge) thing);
-            return handler;
+            return new ArtnetBridgeHandler((Bridge) thing);
         } else if (thingTypeUID.equals(THING_TYPE_LIB485_BRIDGE)) {
-            Lib485BridgeHandler handler = new Lib485BridgeHandler((Bridge) thing);
-            return handler;
+            return new Lib485BridgeHandler((Bridge) thing);
         } else if (thingTypeUID.equals(THING_TYPE_SACN_BRIDGE)) {
-            SacnBridgeHandler handler = new SacnBridgeHandler((Bridge) thing);
-            return handler;
+            return new SacnBridgeHandler((Bridge) thing);
         } else if (thingTypeUID.equals(THING_TYPE_DIMMER)) {
-            DimmerThingHandler handler = new DimmerThingHandler(thing);
-            return handler;
+            return new DimmerThingHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_COLOR)) {
-            ColorThingHandler handler = new ColorThingHandler(thing);
-            return handler;
+            return new ColorThingHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_TUNABLEWHITE)) {
-            TunableWhiteThingHandler handler = new TunableWhiteThingHandler(thing);
-            return handler;
+            return new TunableWhiteThingHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_CHASER)) {
-            ChaserThingHandler handler = new ChaserThingHandler(thing);
-            return handler;
+            return new ChaserThingHandler(thing);
         }
         return null;
     }
index 7acd492479615623a2f0df6d4857920bacb71434..b94404dcada27287dada064a061d60894eb18cde 100644 (file)
@@ -73,8 +73,8 @@ public class DmxActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof DmxBridgeHandler) {
-            this.handler = (DmxBridgeHandler) handler;
+        if (handler instanceof DmxBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
         }
     }
 
index 0244096604da40dd85c840634a90573ad590b9cd..dfa8df12b9d965c2b0482531d1a70b6e1e53c594 100644 (file)
@@ -82,7 +82,7 @@ public class ArtnetBridgeHandler extends DmxOverEthernetHandler {
         }
         logger.debug("originating address is {} for {}", senderNode, this.thing.getUID());
 
-        refreshAlways = configuration.refreshmode.equals("always");
+        refreshAlways = "always".equals(configuration.refreshmode);
 
         logger.debug("refresh mode set to always: {}", refreshAlways);
 
index 347a41fe12c913e07b90f6e0efc970b3e63a6888..5a08a286484d2086331c8e2605ba92b7404925f1 100644 (file)
@@ -68,8 +68,8 @@ public class ChaserThingHandler extends DmxThingHandler {
     public void handleCommand(ChannelUID channelUID, Command command) {
         switch (channelUID.getId()) {
             case CHANNEL_SWITCH:
-                if (command instanceof OnOffType) {
-                    if (((OnOffType) command).equals(OnOffType.ON)) {
+                if (command instanceof OnOffType onOffCommand) {
+                    if (onOffCommand.equals(OnOffType.ON)) {
                         Integer channelCounter = 0;
                         for (DmxChannel channel : channels) {
                             if (resumeAfter) {
@@ -104,8 +104,8 @@ public class ChaserThingHandler extends DmxThingHandler {
                 }
                 break;
             case CHANNEL_CONTROL:
-                if (command instanceof StringType) {
-                    List<ValueSet> newValues = ValueSet.parseChaseConfig(((StringType) command).toString());
+                if (command instanceof StringType stringCommand) {
+                    List<ValueSet> newValues = ValueSet.parseChaseConfig(stringCommand.toString());
                     if (!newValues.isEmpty()) {
                         values = newValues;
                         logger.debug("updated chase config in {}", this.thing.getUID());
@@ -206,8 +206,8 @@ public class ChaserThingHandler extends DmxThingHandler {
     @Override
     public void updateSwitchState(ChannelUID channelUID, State state) {
         logger.trace("received {} for {}", state, channelUID);
-        if (channelUID.getId().equals(CHANNEL_SWITCH) && (state instanceof OnOffType)) {
-            this.isRunning = (OnOffType) state;
+        if (channelUID.getId().equals(CHANNEL_SWITCH) && (state instanceof OnOffType onOffState)) {
+            this.isRunning = onOffState;
             updateState(channelUID, state);
         } else {
             logger.debug("unknown state received: {} in channel {} thing {}", state, channelUID, this.thing.getUID());
index 1540a3f632b1b7beb93af7814a707423391c66e3..8bd90d81c50450cd6d66aa1c067f74b50493d6d8 100644 (file)
@@ -117,9 +117,9 @@ public class ColorThingHandler extends DmxThingHandler {
                     return;
                 }
             case CHANNEL_COLOR: {
-                if (command instanceof OnOffType) {
+                if (command instanceof OnOffType onOffCommand) {
                     logger.trace("adding {} fade to channels in thing {}", command, this.thing.getUID());
-                    if (((OnOffType) command) == OnOffType.ON) {
+                    if (onOffCommand == OnOffType.ON) {
                         targetValueSet = turnOnValue;
                     } else {
                         if (dynamicTurnOnValue) {
@@ -131,21 +131,21 @@ public class ColorThingHandler extends DmxThingHandler {
                         }
                         targetValueSet = turnOffValue;
                     }
-                } else if (command instanceof HSBType) {
+                } else if (command instanceof HSBType hsbCommand) {
                     logger.trace("adding color fade to channels in thing {}", this.thing.getUID());
-                    targetValueSet.addValue(((HSBType) command).getRed());
-                    targetValueSet.addValue(((HSBType) command).getGreen());
-                    targetValueSet.addValue(((HSBType) command).getBlue());
+                    targetValueSet.addValue(hsbCommand.getRed());
+                    targetValueSet.addValue(hsbCommand.getGreen());
+                    targetValueSet.addValue(hsbCommand.getBlue());
                 } else if ((command instanceof PercentType) || (command instanceof DecimalType)) {
                     logger.trace("adding brightness fade to channels in thing {}", this.thing.getUID());
-                    PercentType brightness = (command instanceof PercentType) ? (PercentType) command
+                    PercentType brightness = (command instanceof PercentType percentCommand) ? percentCommand
                             : Util.toPercentValue(((DecimalType) command).intValue());
                     HSBType targetColor = new HSBType(currentColor.getHue(), currentColor.getSaturation(), brightness);
                     targetValueSet.addValue(targetColor.getRed());
                     targetValueSet.addValue(targetColor.getGreen());
                     targetValueSet.addValue(targetColor.getBlue());
-                } else if (command instanceof IncreaseDecreaseType) {
-                    if (isDimming && ((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    if (isDimming && increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                         logger.trace("stopping fade in thing {}", this.thing.getUID());
                         channels.forEach(DmxChannel::clearAction);
                         isDimming = false;
@@ -153,7 +153,7 @@ public class ColorThingHandler extends DmxThingHandler {
                     } else {
                         logger.trace("starting {} fade in thing {}", command, this.thing.getUID());
                         HSBType targetColor;
-                        if (((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)) {
+                        if (increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                             targetColor = new HSBType(currentColor.getHue(), currentColor.getSaturation(),
                                     PercentType.HUNDRED);
                         } else {
@@ -239,7 +239,7 @@ public class ColorThingHandler extends DmxThingHandler {
         dimTime = configuration.dimtime;
         logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());
 
-        String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
+        String turnOnValueString = fadeTime + ":" + configuration.turnonvalue + ":-1";
         ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
         if (turnOnValue.size() % 3 == 0) {
             this.turnOnValue = turnOnValue;
@@ -253,7 +253,7 @@ public class ColorThingHandler extends DmxThingHandler {
 
         dynamicTurnOnValue = configuration.dynamicturnonvalue;
 
-        String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
+        String turnOffValueString = fadeTime + ":" + configuration.turnoffvalue + ":-1";
         ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
         if (turnOffValue.size() % 3 == 0) {
             this.turnOffValue = turnOffValue;
index 475a16f10d43cab4d671bb1e814b76314fd2222c..c289d1bcf629a0bb91cb6718759b6f278dbd926b 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.dmx.internal.handler;
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.IntStream;
@@ -52,7 +51,7 @@ import org.slf4j.LoggerFactory;
  */
 
 public class DimmerThingHandler extends DmxThingHandler {
-    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 Logger logger = LoggerFactory.getLogger(DimmerThingHandler.class);
 
@@ -79,13 +78,13 @@ public class DimmerThingHandler extends DmxThingHandler {
         switch (channelUID.getId()) {
             case CHANNEL_BRIGHTNESS: {
                 if (command instanceof PercentType || command instanceof DecimalType) {
-                    PercentType brightness = (command instanceof PercentType) ? (PercentType) command
+                    PercentType brightness = (command instanceof PercentType percentCommand) ? percentCommand
                             : Util.toPercentValue(((DecimalType) command).intValue());
                     logger.trace("adding fade to channels in thing {}", this.thing.getUID());
                     targetValueSet.addValue(brightness);
-                } else if (command instanceof OnOffType) {
+                } else if (command instanceof OnOffType onOffCommand) {
                     logger.trace("adding {} fade to channels in thing {}", command, this.thing.getUID());
-                    if (((OnOffType) command) == OnOffType.ON) {
+                    if (onOffCommand == OnOffType.ON) {
                         targetValueSet = turnOnValue;
                     } else {
                         if (dynamicTurnOnValue) {
@@ -97,16 +96,15 @@ public class DimmerThingHandler extends DmxThingHandler {
                         }
                         targetValueSet = turnOffValue;
                     }
-                } else if (command instanceof IncreaseDecreaseType) {
-                    if (isDimming && ((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    if (isDimming && increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                         logger.trace("stopping fade in thing {}", this.thing.getUID());
                         channels.forEach(DmxChannel::clearAction);
                         isDimming = false;
                         return;
                     } else {
                         logger.trace("starting {} fade in thing {}", command, this.thing.getUID());
-                        targetValueSet = ((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)
-                                ? turnOnValue
+                        targetValueSet = increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE) ? turnOnValue
                                 : turnOffValue;
                         targetValueSet.setFadeTime(dimTime);
                         isDimming = true;
@@ -178,7 +176,7 @@ public class DimmerThingHandler extends DmxThingHandler {
         dimTime = configuration.dimtime;
         logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());
 
-        String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
+        String turnOnValueString = fadeTime + ":" + configuration.turnonvalue + ":-1";
 
         ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
         if (!turnOnValue.isEmpty()) {
@@ -194,7 +192,7 @@ public class DimmerThingHandler extends DmxThingHandler {
 
         dynamicTurnOnValue = configuration.dynamicturnonvalue;
 
-        String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
+        String turnOffValueString = fadeTime + ":" + configuration.turnoffvalue + ":-1";
         ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
         if (!turnOffValue.isEmpty()) {
             this.turnOffValue = turnOffValue;
index c13449b8af94a319afe00d8c94f3b819416919f1..10bccb01b7d8decf94d0276334f59f859f097923 100644 (file)
@@ -65,7 +65,7 @@ public class SacnBridgeHandler extends DmxOverEthernetHandler {
         packetTemplate.setUniverse(universe.getUniverseId());
 
         receiverNodes.clear();
-        if ((configuration.mode.equals("unicast"))) {
+        if (("unicast".equals(configuration.mode))) {
             if (configuration.address.isEmpty()) {
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                         "Could not initialize unicast sender (address not set)");
@@ -90,7 +90,7 @@ public class SacnBridgeHandler extends DmxOverEthernetHandler {
         }
         logger.debug("originating address is {} for {}", senderNode, this.thing.getUID());
 
-        refreshAlways = configuration.refreshmode.equals("always");
+        refreshAlways = "always".equals(configuration.refreshmode);
         logger.debug("refresh mode set to always: {}", refreshAlways);
 
         updateStatus(ThingStatus.UNKNOWN);
index 915e7c75eab9fd443dc0dfbb7c92391f19230aaf..383b9aaf56d44d8df51aae9221a5401fe460385d 100644 (file)
@@ -81,16 +81,16 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
         switch (channelUID.getId()) {
             case CHANNEL_BRIGHTNESS: {
                 if (command instanceof PercentType || command instanceof DecimalType) {
-                    PercentType brightness = (command instanceof PercentType) ? (PercentType) command
+                    PercentType brightness = (command instanceof PercentType percentCommand) ? percentCommand
                             : Util.toPercentValue(((DecimalType) command).intValue());
                     logger.trace("adding fade to channels in thing {}", this.thing.getUID());
                     targetValueSet.addValue(Util.toDmxValue(
                             Util.toDmxValue(brightness) * (100 - currentColorTemperature.intValue()) / 100));
                     targetValueSet.addValue(
                             Util.toDmxValue(Util.toDmxValue(brightness) * currentColorTemperature.intValue() / 100));
-                } else if (command instanceof OnOffType) {
+                } else if (command instanceof OnOffType onOffCommand) {
                     logger.trace("adding {} fade to channels in thing {}", command, this.thing.getUID());
-                    if (((OnOffType) command) == OnOffType.ON) {
+                    if (onOffCommand == OnOffType.ON) {
                         targetValueSet = turnOnValue;
                     } else {
                         if (dynamicTurnOnValue) {
@@ -102,16 +102,15 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
                         }
                         targetValueSet = turnOffValue;
                     }
-                } else if (command instanceof IncreaseDecreaseType) {
-                    if (isDimming && ((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)) {
+                } else if (command instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    if (isDimming && increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE)) {
                         logger.trace("stopping fade in thing {}", this.thing.getUID());
                         channels.forEach(DmxChannel::clearAction);
                         isDimming = false;
                         return;
                     } else {
                         logger.trace("starting {} fade in thing {}", command, this.thing.getUID());
-                        targetValueSet = ((IncreaseDecreaseType) command).equals(IncreaseDecreaseType.INCREASE)
-                                ? turnOnValue
+                        targetValueSet = increaseDecreaseCommand.equals(IncreaseDecreaseType.INCREASE) ? turnOnValue
                                 : turnOffValue;
                         targetValueSet.setFadeTime(dimTime);
                         isDimming = true;
@@ -153,8 +152,7 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
                     return;
                 }
             case CHANNEL_COLOR_TEMPERATURE: {
-                if (command instanceof PercentType) {
-                    PercentType colorTemperature = (PercentType) command;
+                if (command instanceof PercentType colorTemperature) {
                     targetValueSet.addValue(Util.toDmxValue(
                             Util.toDmxValue(currentBrightness) * (100 - colorTemperature.intValue()) / 100));
                     targetValueSet.addValue(
@@ -231,7 +229,7 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
         dimTime = configuration.dimtime;
         logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());
 
-        String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
+        String turnOnValueString = fadeTime + ":" + configuration.turnonvalue + ":-1";
         ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
         if (turnOnValue.size() % 2 == 0) {
             this.turnOnValue = turnOnValue;
@@ -245,7 +243,7 @@ public class TunableWhiteThingHandler extends DmxThingHandler {
 
         dynamicTurnOnValue = configuration.dynamicturnonvalue;
 
-        String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
+        String turnOffValueString = fadeTime + ":" + configuration.turnoffvalue + ":-1";
         ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
         if (turnOffValue.size() % 2 == 0) {
             this.turnOffValue = turnOffValue;
index b9480c588ac82c06d0f9b0d72daad883735a9bd2..bd3f9c819a611d8c87a0808a941458086b7efa86 100644 (file)
@@ -97,7 +97,7 @@ public class BaseDmxChannel implements Comparable<BaseDmxChannel> {
         if (otherDmxChannel == null) {
             return -1;
         }
-        int universeCompare = Integer.valueOf(getUniverseId()).compareTo(otherDmxChannel.getUniverseId());
+        int universeCompare = Integer.compare(getUniverseId(), otherDmxChannel.getUniverseId());
         if (universeCompare == 0) {
             return Integer.compare(getChannelId(), otherDmxChannel.getChannelId());
         } else {
@@ -127,7 +127,7 @@ public class BaseDmxChannel implements Comparable<BaseDmxChannel> {
             if (channelMatch.matches()) {
                 final int universeId = (channelMatch.group(1) == null) ? defaultUniverseId
                         : Integer.parseInt(channelMatch.group(1));
-                dmxChannelWidth = channelMatch.group(3).equals("") ? 1 : Integer.parseInt(channelMatch.group(3));
+                dmxChannelWidth = "".equals(channelMatch.group(3)) ? 1 : Integer.parseInt(channelMatch.group(3));
                 dmxChannelId = Integer.parseInt(channelMatch.group(2));
                 LOGGER.trace("parsed channel string {} to universe {}, id {}, width {}", singleDmxChannelString,
                         universeId, dmxChannelId, dmxChannelWidth);
index 3d58bf5b67e0f600ebe2c193c1f6959aefb077d6..9a106f60d254f718b712b6ec23b1ac93e2cd5c0e 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.dmx.test;
 
 import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
 
-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 TestBridgeHandler extends DmxBridgeHandler {
     public static final ThingTypeUID THING_TYPE_TEST_BRIDGE = new ThingTypeUID(BINDING_ID, "test-bridge");
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_TEST_BRIDGE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_TEST_BRIDGE);
     public static final int MIN_UNIVERSE_ID = 0;
     public static final int MAX_UNIVERSE_ID = 0;
 
index 0e1831c42f900e9c89cef3aeab8967cc56497a52..6e1a1decc5e4cc478e9522b1fee70a75fe505625 100644 (file)
@@ -41,8 +41,8 @@ public class DoorbirdActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof DoorbellHandler) {
-            this.handler = (DoorbellHandler) handler;
+        if (handler instanceof DoorbellHandler doorbellHandler) {
+            this.handler = doorbellHandler;
         }
     }
 
index dce27e1fcdce2ecb3aaacdc1fb1cd5627a625e33..d275b720b98ce1258574146b1f49235dac17c34f 100644 (file)
@@ -29,36 +29,40 @@ public class DoorbirdInfoTest {
 
     private final String infoWithControllerId =
     //@formatter:off
-    "{" +
-        "'BHA': {" +
-            "'RETURNCODE': '1'," +
-            "'VERSION': [{" +
-                "'FIRMWARE': '000109'," +
-                "'BUILD_NUMBER': '15120529'," +
-                "'PRIMARY_MAC_ADDR': '1CCAE3711111'," +
-                "'WIFI_MAC_ADDR': '1CCAE3799999'," +
-                "'RELAYS': ['1', '2', 'gggaaa@1', 'gggaaa@2']," +
-                "'DEVICE-TYPE': 'DoorBird D101'" +
-            "}]" +
-        "}" +
-    "}";
+    """
+    {\
+    'BHA': {\
+    'RETURNCODE': '1',\
+    'VERSION': [{\
+    'FIRMWARE': '000109',\
+    'BUILD_NUMBER': '15120529',\
+    'PRIMARY_MAC_ADDR': '1CCAE3711111',\
+    'WIFI_MAC_ADDR': '1CCAE3799999',\
+    'RELAYS': ['1', '2', 'gggaaa@1', 'gggaaa@2'],\
+    'DEVICE-TYPE': 'DoorBird D101'\
+    }]\
+    }\
+    }\
+    """;
     //@formatter:on
 
     private final String infoWithoutControllerId =
     //@formatter:off
-    "{" +
-        "'BHA': {" +
-            "'RETURNCODE': '1'," +
-            "'VERSION': [{" +
-                "'FIRMWARE': '000109'," +
-                "'BUILD_NUMBER': '15120529'," +
-                "'PRIMARY_MAC_ADDR': '1CCAE3711111'," +
-                "'WIFI_MAC_ADDR': '1CCAE3799999'," +
-                "'RELAYS': ['1', '2']," +
-                "'DEVICE-TYPE': 'DoorBird D101'" +
-            "}]" +
-        "}" +
-    "}";
+    """
+    {\
+    'BHA': {\
+    'RETURNCODE': '1',\
+    'VERSION': [{\
+    'FIRMWARE': '000109',\
+    'BUILD_NUMBER': '15120529',\
+    'PRIMARY_MAC_ADDR': '1CCAE3711111',\
+    'WIFI_MAC_ADDR': '1CCAE3799999',\
+    'RELAYS': ['1', '2'],\
+    'DEVICE-TYPE': 'DoorBird D101'\
+    }]\
+    }\
+    }\
+    """;
     //@formatter:on
 
     @Test
index 06ef3fb8cdd3534fd0e754e549f9116d811fde8e..66640da2d3673b1f8361a991a66780a2a25b7ed3 100644 (file)
@@ -29,33 +29,35 @@ public class SipStatusTest {
 
     private final String sipStatusJson =
     //@formatter:off
-    "{" +
-        "'BHA': {" +
-            "'RETURNCODE': '1'," +
-            "'SIP': [{" +
-            "'ENABLE': '10'," +
-            "'PRIORITIZE_APP': '1'," +
-            "'REGISTER_URL': '192.168.178.1'," +
-            "'REGISTER_USER': 'xxxxx'," +
-            "'REGISTER_PASSWORD': 'yyyyy'," +
-            "'AUTOCALL_MOTIONSENSOR_URL': 'motion-url'," +
-            "'AUTOCALL_DOORBELL_URL': 'doorbell-url'," +
-            "'SPK_VOLUME': '70'," +
-            "'MIC_VOLUME': '33'," +
-            "'DTMF': '1'," +
-            "'relais:1': '0'," +
-            "'relais:2': '1'," +
-            "'LIGHT_PASSCODE': 'light-passcode'," +
-            "'INCOMING_CALL_ENABLE': '0'," +
-            "'INCOMING_CALL_USER': 'abcde'," +
-            "'ANC': '1'," +
-            "'LASTERRORCODE': '901'," +
-            "'LASTERRORTEXT': 'OK'," +
-            "'RING_TIME_LIMIT': '60'," +
-            "'CALL_TIME_LIMIT': '180'" +
-            "}]" +
-        "}" +
-    "}";
+    """
+    {\
+    'BHA': {\
+    'RETURNCODE': '1',\
+    'SIP': [{\
+    'ENABLE': '10',\
+    'PRIORITIZE_APP': '1',\
+    'REGISTER_URL': '192.168.178.1',\
+    'REGISTER_USER': 'xxxxx',\
+    'REGISTER_PASSWORD': 'yyyyy',\
+    'AUTOCALL_MOTIONSENSOR_URL': 'motion-url',\
+    'AUTOCALL_DOORBELL_URL': 'doorbell-url',\
+    'SPK_VOLUME': '70',\
+    'MIC_VOLUME': '33',\
+    'DTMF': '1',\
+    'relais:1': '0',\
+    'relais:2': '1',\
+    'LIGHT_PASSCODE': 'light-passcode',\
+    'INCOMING_CALL_ENABLE': '0',\
+    'INCOMING_CALL_USER': 'abcde',\
+    'ANC': '1',\
+    'LASTERRORCODE': '901',\
+    'LASTERRORTEXT': 'OK',\
+    'RING_TIME_LIMIT': '60',\
+    'CALL_TIME_LIMIT': '180'\
+    }]\
+    }\
+    }\
+    """;
     //@formatter:on
 
     @Test
index 4443576fb49ac9bd1d4b281a5b095db2b2554f0a..186a1486da759f90d8b6236a3ab13b416ae0a38c 100644 (file)
@@ -12,9 +12,6 @@
  */
 package org.openhab.binding.draytonwiser.internal;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -109,9 +106,8 @@ public class DraytonWiserBindingConstants {
     public static final String CHANNEL_SMARTPLUG_INSTANTANEOUS_POWER = "plugInstantaneousPower";
     public static final String CHANNEL_SMARTPLUG_ENERGY_DELIVERED = "plugEnergyDelivered";
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_CONTROLLER, THING_TYPE_ROOM, THING_TYPE_ROOMSTAT,
-                    THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG)));
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_CONTROLLER, THING_TYPE_ROOM,
+            THING_TYPE_ROOMSTAT, THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG);
 
     // Lookups from text representations to useful values
 
index 260799212bdb6df4b447069ff26d1aaa34e6e3ae..0f32dcf8fbb2471382f1a2b7b3224614bf2eb251 100644 (file)
@@ -202,8 +202,8 @@ public class DraytonWiserDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable final ThingHandler handler) {
-        if (handler instanceof HeatHubHandler) {
-            bridgeHandler = (HeatHubHandler) handler;
+        if (handler instanceof HeatHubHandler hubHandler) {
+            bridgeHandler = hubHandler;
             bridgeUID = handler.getThing().getUID();
         } else {
             bridgeHandler = null;
index 8cd56bce2795fb1f5558386c26e135e6e8c587c9..720f34189b3f6b21af42bacc45926bb60090306d 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.draytonwiser.internal.discovery;
 import static org.openhab.binding.draytonwiser.internal.DraytonWiserBindingConstants.*;
 
 import java.net.InetAddress;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -50,7 +49,7 @@ public class DraytonWiserMDNSDiscoveryParticipant implements MDNSDiscoveryPartic
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(THING_TYPE_BRIDGE);
+        return Set.of(THING_TYPE_BRIDGE);
     }
 
     @Override
index e5e845147fdaf24a07e3befe830c38f1b4d63183..cd9a4bd7a714573b8b07bd879ca497aaa5ff20f3 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.draytonwiser.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -71,7 +71,7 @@ public class HeatHubHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(DraytonWiserDiscoveryService.class);
+        return Set.of(DraytonWiserDiscoveryService.class);
     }
 
     public void setDiscoveryService(final DraytonWiserRefreshListener discoveryService) {
index 3885d8e5b5d802fbb716de5ac25a6223d8b314ac..2414ee0d821ab3ca7f9461946acc817209577a38 100644 (file)
@@ -59,8 +59,8 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
     protected void handleCommand(final String channelId, final Command command) throws DraytonWiserApiException {
         switch (channelId) {
             case CHANNEL_CURRENT_SETPOINT:
-                if (command instanceof QuantityType) {
-                    setSetPoint((QuantityType<?>) command);
+                if (command instanceof QuantityType quantityCommand) {
+                    setSetPoint(quantityCommand);
                 }
                 break;
             case CHANNEL_MANUAL_MODE_STATE:
@@ -69,8 +69,8 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
                 }
                 break;
             case CHANNEL_ROOM_BOOST_DURATION:
-                if (command instanceof DecimalType) {
-                    setBoostDuration(Math.round((((DecimalType) command).floatValue() * 60)));
+                if (command instanceof DecimalType decimalCommand) {
+                    setBoostDuration(Math.round((decimalCommand.floatValue() * 60)));
                 }
                 break;
             case CHANNEL_ROOM_WINDOW_STATE_DETECTION:
index 902ac1b93d74b4afbce141187de5d82b95d9fec8..52780beb8aa35fb240959b822e9529d2b13d0e81 100644 (file)
@@ -233,15 +233,15 @@ public class DSCAlarmMessage {
                     case UserClosing: /* 700 */
                         user = message.substring(4);
                         name = name.concat(": " + user);
-                        description = codeReceived + ": Partition " + String.valueOf(partition)
-                                + " has been armed by user " + user + ".";
+                        description = codeReceived + ": Partition " + partition + " has been armed by user " + user
+                                + ".";
                         messageType = DSCAlarmMessageType.PARTITION_EVENT;
                         break;
                     case UserOpening: /* 750 */
                         user = message.substring(4);
                         name = name.concat(": " + user);
-                        description = codeReceived + ": Partition " + String.valueOf(partition)
-                                + " has been disarmed by user " + user + ".";
+                        description = codeReceived + ": Partition " + partition + " has been disarmed by user " + user
+                                + ".";
                         messageType = DSCAlarmMessageType.PARTITION_EVENT;
                         break;
 
index 4b4a3e8d38aed81fdd08b50b2a0d77a6f860241f..dc9fb44279061e63320e92ad2aca1aa86861c391 100644 (file)
@@ -97,8 +97,8 @@ public class DSCAlarmDiscoveryService extends AbstractDiscoveryService {
                 break;
             case PARTITION:
                 if (partitionNumber >= 1 && partitionNumber <= 8) {
-                    thingID = "partition" + String.valueOf(partitionNumber);
-                    thingLabel = "Partition " + String.valueOf(partitionNumber);
+                    thingID = "partition" + partitionNumber;
+                    thingLabel = "Partition " + partitionNumber;
                     properties = new HashMap<>(0);
                     thingUID = new ThingUID(DSCAlarmBindingConstants.PARTITION_THING_TYPE, bridge.getUID(), thingID);
                     properties.put(DSCAlarmPartitionConfiguration.PARTITION_NUMBER, partitionNumber);
@@ -107,8 +107,8 @@ public class DSCAlarmDiscoveryService extends AbstractDiscoveryService {
                 break;
             case ZONE:
                 if (zoneNumber >= 1 && zoneNumber <= 64) {
-                    thingID = "zone" + String.valueOf(zoneNumber);
-                    thingLabel = "Zone " + String.valueOf(zoneNumber);
+                    thingID = "zone" + zoneNumber;
+                    thingLabel = "Zone " + zoneNumber;
                     properties = new HashMap<>(0);
                     thingUID = new ThingUID(DSCAlarmBindingConstants.ZONE_THING_TYPE, bridge.getUID(), thingID);
                     properties.put(DSCAlarmZoneConfiguration.ZONE_NUMBER, zoneNumber);
index 1cede27911029faab1a64f98f5736fdbd48493f1..de26b1e88c6cb0114b8966054f7c412870e130a3 100644 (file)
@@ -136,7 +136,7 @@ public class EnvisalinkBridgeDiscovery {
      * @return
      */
     private long convertIPToNumber(String ipAddress) {
-        String octets[] = ipAddress.split("\\.");
+        String[] octets = ipAddress.split("\\.");
 
         if (octets.length != 4) {
             throw new IllegalArgumentException("Invalid IP address: " + ipAddress);
index c719f9afa2ab0b32e211527a2183d5913384149a..b677d2bb684c82c6c5fd3a602ddfe0cba4871372 100644 (file)
@@ -202,17 +202,17 @@ public class PanelThingHandler extends DSCAlarmBaseThingHandler {
                     updateState(channelUID, new StringType(String.valueOf(-1)));
                     break;
                 case PANEL_TIME_STAMP:
-                    if (command instanceof OnOffType) {
+                    if (command instanceof OnOffType onOffCommand) {
                         cmd = command == OnOffType.ON ? 1 : 0;
                         dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.TimeStampControl, String.valueOf(cmd));
-                        updateState(channelUID, (OnOffType) command);
+                        updateState(channelUID, onOffCommand);
                     }
                     break;
                 case PANEL_TIME_BROADCAST:
-                    if (command instanceof OnOffType) {
+                    if (command instanceof OnOffType onOffCommand) {
                         cmd = command == OnOffType.ON ? 1 : 0;
                         dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.TimeDateBroadcastControl, String.valueOf(cmd));
-                        updateState(channelUID, (OnOffType) command);
+                        updateState(channelUID, onOffCommand);
                     }
                     break;
                 default:
index 42dd1a9ba98937d58d5df226a4788001ddc4fe1f..d2dd43a682b23b0caf654b776f437de8e7d16cd4 100644 (file)
@@ -107,7 +107,7 @@ public class ZoneThingHandler extends DSCAlarmBaseThingHandler {
 
         if (dscAlarmBridgeHandler != null && dscAlarmBridgeHandler.isConnected()
                 && channelUID.getId().equals(ZONE_BYPASS_MODE)) {
-            String data = String.valueOf(getPartitionNumber()) + "*1" + String.format("%02d", getZoneNumber()) + "#";
+            String data = getPartitionNumber() + "*1" + String.format("%02d", getZoneNumber()) + "#";
 
             dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.KeySequence, data);
         }
index 8c7c844351a831ba89719a0f3998bb2ee0542ccc..415bd9e30681617ca8c1b753d203485a7794092a 100644 (file)
@@ -194,8 +194,8 @@ public class OBISIdentifier {
     @Override
     public boolean equals(@Nullable final Object other) {
         OBISIdentifier o;
-        if (other != null && other instanceof OBISIdentifier) {
-            o = (OBISIdentifier) other;
+        if (other != null && other instanceof OBISIdentifier identifier) {
+            o = identifier;
         } else {
             return false;
         }
index abc422d94be229d83985d67669f0083bd67e34ef..64c7606445e6ee6fab84cb2d9158314220a6891a 100644 (file)
@@ -125,9 +125,11 @@ public class DSMRBridgeDiscoveryService extends DSMRDiscoveryService implements
                     logger.trace("Possible port to check:{}, owned:{} by:{}", currentScannedPortName,
                             portIdentifier.isCurrentlyOwned(), portIdentifier.getCurrentOwner());
                     if (DSMR_PORT_NAME.equals(portIdentifier.getCurrentOwner())) {
-                        logger.debug("The port {} is owned by this binding. If no DSMR meters will be found it "
-                                + "might indicate the port is locked by an older instance of this binding. "
-                                + "Restart the system to unlock the port.", currentScannedPortName);
+                        logger.debug("""
+                                The port {} is owned by this binding. If no DSMR meters will be found it \
+                                might indicate the port is locked by an older instance of this binding. \
+                                Restart the system to unlock the port.\
+                                """, currentScannedPortName);
                     }
                 } else {
                     logger.debug("Start discovery on serial port: {}", currentScannedPortName);
index 7717699c0d9e67f53277beaf5f0833311b0ecb7b..0db8a986fc30f4b784c1ce446369dc5c201ea320 100644 (file)
@@ -76,8 +76,8 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P
 
     @Override
     public void setThingHandler(final ThingHandler handler) {
-        if (handler instanceof DSMRBridgeHandler) {
-            dsmrBridgeHandler = (DSMRBridgeHandler) handler;
+        if (handler instanceof DSMRBridgeHandler bridgeHandler) {
+            dsmrBridgeHandler = bridgeHandler;
         }
     }
 
@@ -124,14 +124,18 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P
                 reportUnregisteredMeters();
             } else {
                 reportUnrecognizedCosemObjects(list);
-                logger.info("There are unrecognized cosem values in the data received from the meter,"
-                        + " which means some meters might not be detected. Please report your raw data as reference: {}",
-                        telegram.getRawTelegram());
+                logger.info("""
+                        There are unrecognized cosem values in the data received from the meter,\
+                         which means some meters might not be detected. Please report your raw data as reference: {}\
+                        """, telegram.getRawTelegram());
             }
         }
         if (!telegram.getUnknownCosemObjects().isEmpty()) {
-            logger.info("There are unrecognized cosem values in the data received from the meter,"
-                    + " which means you have values that can't be read by a channel: {}. Please report them and your raw data as reference: {}",
+            logger.info(
+                    """
+                            There are unrecognized cosem values in the data received from the meter,\
+                             which means you have values that can't be read by a channel: {}. Please report them and your raw data as reference: {}\
+                            """,
                     telegram.getUnknownCosemObjects().stream()
                             .map(e -> String.format("obis id:%s, value:%s", e.getKey(), e.getValue()))
                             .collect(Collectors.joining(", ")),
@@ -196,10 +200,10 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P
      */
     protected void reportConfigurationValidationResults(final List<DSMRMeterType> invalidConfigured,
             final List<DSMRMeterType> unconfiguredMeters) {
-        logger.info(
-                "Possible incorrect meters configured. These are configured: {}."
-                        + "But the following unconfigured meters are found in the data received from the meter: {}",
-                invalidConfigured.stream().map(m -> m.name()).collect(Collectors.joining(", ")),
+        logger.info("""
+                Possible incorrect meters configured. These are configured: {}.\
+                But the following unconfigured meters are found in the data received from the meter: {}\
+                """, invalidConfigured.stream().map(m -> m.name()).collect(Collectors.joining(", ")),
                 unconfiguredMeters.stream().map(m -> m.name()).collect(Collectors.joining(", ")));
     }
 }
index 179cc3a1c5c1927b0fba2e94ae1681eb7841316b..5025351fb41d730ca12afefc0bc7d2f0d17b190f 100644 (file)
@@ -73,12 +73,11 @@ public class DSMRMeter {
      */
     public List<CosemObject> filterMeterValues(List<CosemObject> cosemObjects, int channel) {
         logger.trace("supported identifiers: {}, searching for objects {}", supportedIdentifiers, cosemObjects);
-        List<CosemObject> filteredValues = cosemObjects.stream()
+        return cosemObjects.stream()
                 .filter(cosemObject -> (DSMRMeterConstants.UNKNOWN_CHANNEL == channel
                         || cosemObject.getObisIdentifier().getChannel() == channel)
                         && supportedIdentifiers.contains(cosemObject.getObisIdentifier().getReducedOBISIdentifier()))
                 .collect(Collectors.toList());
-        return filteredValues;
     }
 
     /**
index 818fcab56994690f150bd0f8d4ba1c864c7fde74..1f0f7eecc3bb628cfd63657301b6046252d13a2b 100644 (file)
@@ -31,7 +31,7 @@ import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
 public class P1TelegramParserTest {
 
     // @formatter:off
-    public static final List<Object[]> data() {
+    public static List<Object[]> data() {
         return Arrays.asList(new Object[][] {
             { "ace4000", 59, 0},
             { "dsmr_40", 39, 0},
index 558ac6c533ea3e98617a937dfe84acad8697a035..60aa984d076ee947ca7bb4639dc667d238424dc5 100644 (file)
@@ -54,7 +54,7 @@ import org.openhab.binding.dsmr.internal.meter.DSMRMeterType;
 public class DSMRMeterDetectorTest {
 
     // @formatter:off
-    public static final List<Object[]> data() {
+    public static List<Object[]> data() {
         return Arrays.asList(new Object[][] {
             { "ace4000", EnumSet.of(ELECTRICITY_ACE4000, GAS_ACE4000)},
             { "dsmr_40", EnumSet.of(DEVICE_V4, ELECTRICITY_V4_2, M3_V5_0)},
index 1e1fbda0c9c297524e837e2de24274d10e3ac688..a898083d4bbd34a746df8a0aedbb9ec92cac364e 100644 (file)
@@ -170,9 +170,8 @@ public class DWDPollenflugBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof DWDPollenflugRegionHandler) {
+        if (childHandler instanceof DWDPollenflugRegionHandler regionListener) {
             logger.debug("Register region listener.");
-            final DWDPollenflugRegionHandler regionListener = (DWDPollenflugRegionHandler) childHandler;
             if (regionListeners.add(regionListener)) {
                 final DWDPollenflug localPollenflug = pollenflug;
                 if (localPollenflug != null) {
@@ -187,9 +186,9 @@ public class DWDPollenflugBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof DWDPollenflugRegionHandler) {
+        if (childHandler instanceof DWDPollenflugRegionHandler handler) {
             logger.debug("Unregister region listener.");
-            if (!regionListeners.remove((DWDPollenflugRegionHandler) childHandler)) {
+            if (!regionListeners.remove(handler)) {
                 logger.warn("Tried to remove listener {} but it was not registered. This is probably an error.",
                         childHandler);
             }
index 351c20a9ad9d8a12639031a913b9d9f814f780bb..0b131c268ceba1ac485b7c3d786fdf9019b1a144 100644 (file)
@@ -66,8 +66,7 @@ public class DWDPollenflugRegionHandler extends BaseThingHandler {
         Bridge bridge = getBridge();
         if (bridge != null) {
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof DWDPollenflugBridgeHandler) {
-                DWDPollenflugBridgeHandler bridgeHandler = (DWDPollenflugBridgeHandler) handler;
+            if (handler instanceof DWDPollenflugBridgeHandler bridgeHandler) {
                 return bridgeHandler;
             }
         }
index 24bd9b099577cd7b06adc59e29723aac88f5069a..3c9fa622c8e2b077071777e28a93f86319cd1a9b 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.dwdunwetter.internal.factory;
 
 import static org.openhab.binding.dwdunwetter.internal.DwdUnwetterBindingConstants.THING_TYPE_WARNINGS;
 
-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.dwdunwetter", service = ThingHandlerFactory.class)
 public class DwdUnwetterHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_WARNINGS);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_WARNINGS);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
index 9a57d99ea97821c6b8d215a7906e5683bb777fe4..148630b4c5ee279ef529a7df93ee0c63bda1b4c1 100644 (file)
@@ -137,7 +137,7 @@ public class DwdUnwetterHandlerTest extends JavaTest {
     private String getLabel(NodeList nodeList) {
         for (int i = 0; i < nodeList.getLength(); i++) {
             Node node = nodeList.item(i);
-            if (node.getNodeName().equals("label")) {
+            if ("label".equals(node.getNodeName())) {
                 return node.getTextContent();
             }
         }
index 4dbe0311ebd96831ba62228e53f7fe42f7a5a52c..53fcd39322f8dab0a30286c54d4f09254e4de110 100644 (file)
@@ -61,8 +61,7 @@ public final class Utils {
             formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX");
         }
         LOGGER.trace("parsing: {}", date);
-        ZonedDateTime zdt = ZonedDateTime.parse(date, formatter);
-        return zdt;
+        return ZonedDateTime.parse(date, formatter);
     }
 
     /**
index 42cfb43d46e2f1b34d3e1fd67e0727b20cc815c4..faaa252b453d55b1dfaa8bde1d4384f44cf51a78 100644 (file)
@@ -52,14 +52,14 @@ import com.google.gson.ToNumberPolicy;
 @NonNullByDefault
 public abstract class AbstractCommand extends BufferingResponseListener implements EaseeCommand {
 
-    public static enum RetryOnFailure {
+    public enum RetryOnFailure {
         YES,
-        NO;
+        NO
     }
 
-    public static enum ProcessFailureResponse {
+    public enum ProcessFailureResponse {
         YES,
-        NO;
+        NO
     }
 
     /**
index 93bfed6a919de2bc333a0b6a1314569cbcb11b38..a66644441e930cb59e5270bb5ce2f98f89a9ec94 100644 (file)
@@ -60,9 +60,9 @@ public abstract class AbstractWriteCommand extends AbstractCommand {
      * @return value as String without unit.
      */
     protected String getCommandValue() {
-        if (command instanceof QuantityType<?>) {
+        if (command instanceof QuantityType<?> quantityCommand) {
             // this is necessary because we must not send the unit to the backend
-            return String.valueOf(((QuantityType<?>) command).doubleValue());
+            return String.valueOf(quantityCommand.doubleValue());
         } else if (command instanceof OnOffType) {
             // this is necessary because we must send booleans and not ON/OFF to the backend
             return String.valueOf(command.equals(OnOffType.ON));
index 4065f71ef1bde08e03eca911de128adf9e30fc59..db7ee8676b8b0541baf765c274fcb1a95319443d 100644 (file)
@@ -57,8 +57,8 @@ public class EaseeSiteDiscoveryService extends AbstractDiscoveryService implemen
 
     @Override
     public void setThingHandler(ThingHandler handler) {
-        if (handler instanceof EaseeSiteHandler) {
-            this.bridgeHandler = (EaseeSiteHandler) handler;
+        if (handler instanceof EaseeSiteHandler siteHandler) {
+            this.bridgeHandler = siteHandler;
             this.bridgeHandler.setDiscoveryService(this);
         }
     }
index ef007fe58eeab53cf27647f8831671cea24796a9..58adde308bd6eaba733a7161d0b966418533eb4d 100644 (file)
@@ -15,9 +15,9 @@ package org.openhab.binding.easee.internal.handler;
 import static org.openhab.binding.easee.internal.EaseeBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -181,7 +181,7 @@ public class EaseeSiteHandler extends BaseBridgeHandler implements EaseeBridgeHa
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(EaseeSiteDiscoveryService.class);
+        return Set.of(EaseeSiteDiscoveryService.class);
     }
 
     public void setDiscoveryService(EaseeSiteDiscoveryService discoveryService) {
index 7b9d4658449ce53b1b799a7c185a8a372ffbda53..3f7edf8a16b8f29c36dd5ec00d6019fd2d9ea6f0 100644 (file)
@@ -130,7 +130,6 @@ public interface EaseeThingHandler extends ThingHandler, ChannelProvider {
     default @Nullable Channel getChannel(String groupId, String channelId) {
         ThingUID thingUID = this.getThing().getUID();
         ChannelGroupUID channelGroupUID = new ChannelGroupUID(thingUID, groupId);
-        Channel channel = getThing().getChannel(new ChannelUID(channelGroupUID, channelId));
-        return channel;
+        return getThing().getChannel(new ChannelUID(channelGroupUID, channelId));
     }
 }
index ebea21f43bf7d5eda554c6f167f2c263fb44c44a..de6ab958ab7db9a3ac140c6adc48736522799995 100644 (file)
@@ -122,9 +122,9 @@ class CustomResponseTransformer {
         String phase2 = Utils.getAsString(rawData, channelPhase2);
         String phase3 = Utils.getAsString(rawData, channelPhase3);
         if (channel != null && phase1 != null && phase2 != null && phase3 != null) {
-            phase1 = phase1.replaceAll("\\.0", "");
-            phase2 = phase2.replaceAll("\\.0", "");
-            phase3 = phase3.replaceAll("\\.0", "");
+            phase1 = phase1.replace(".0", "");
+            phase2 = phase2.replace(".0", "");
+            phase3 = phase3.replace(".0", "");
             result.put(channel, new StringType(phase1 + ";" + phase2 + ";" + phase3));
         }
     }
index 05f39debc48d2ea4b345d7f6c365129c5fa19727..2d6822f43a050a2b8a4a6accf4e4bf58b1305fb1 100644 (file)
@@ -70,6 +70,7 @@ public enum EchonetClass {
         return classProperties;
     }
 
+    @Override
     public String toString() {
         return name() + "{" + "groupCode=0x" + Integer.toHexString(groupCode) + ", classCode=0x"
                 + Integer.toHexString(0xFF & classCode) + '}';
index 3091cdb98e45d023fac51aaaa8d5faf12d0972f5..41dfd62be0851163bdfc3db51bb975aeb855a31e 100644 (file)
@@ -48,6 +48,7 @@ public class EchonetDevice extends EchonetObject {
         this.listener = listener;
     }
 
+    @Override
     public void applyProperty(InstanceKey sourceInstanceKey, Esv esv, final int epcCode, final int pdc,
             final ByteBuffer edt) {
         final Epc epc = Epc.lookup(instanceKey().klass.groupCode(), instanceKey().klass.classCode(), epcCode);
@@ -112,6 +113,7 @@ public class EchonetDevice extends EchonetObject {
         return identificationNumber.toString();
     }
 
+    @Override
     public boolean buildUpdateMessage(final EchonetMessageBuilder messageBuilder, final ShortSupplier tidSupplier,
             final long nowMs, InstanceKey managementControllerKey) {
         if (pendingSets.isEmpty()) {
@@ -141,6 +143,7 @@ public class EchonetDevice extends EchonetObject {
         return true;
     }
 
+    @Override
     public void update(String channelId, State state) {
         final Epc epc = epcByChannelId.get(channelId);
         if (null == epc) {
@@ -156,12 +159,14 @@ public class EchonetDevice extends EchonetObject {
         listener.onRemoved();
     }
 
+    @Override
     public void checkTimeouts() {
         if (EchonetLiteBindingConstants.OFFLINE_TIMEOUT_COUNT <= inflightGetRequest.timeoutCount()) {
             listener.onOffline();
         }
     }
 
+    @Override
     public void refreshAll(long nowMs) {
         final EchonetPropertyMap getPropertyMap = this.getPropertyMap;
         if (lastPollMs + pollIntervalMs <= nowMs && null != getPropertyMap) {
index 5a1f20a1ef0d57260b817a7635d305b6d79c6a34..aeceb558442ce6d3928bbadd388474ab7a90458f 100644 (file)
@@ -100,8 +100,8 @@ public class EchonetDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(ThingHandler thingHandler) {
-        if (thingHandler instanceof EchonetLiteBridgeHandler) {
-            this.bridgeHandler = (EchonetLiteBridgeHandler) thingHandler;
+        if (thingHandler instanceof EchonetLiteBridgeHandler bridgeHandler) {
+            this.bridgeHandler = bridgeHandler;
         }
     }
 
index b526f6d0423e78075a563a7b4acf4baf7ec611e5..8fb51e7eb9fce8d257bb50959858d8b6018992fe 100644 (file)
@@ -19,8 +19,8 @@ import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.TimeUnit;
@@ -90,9 +90,8 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
     private void newDeviceInternal(final NewDeviceMessage message) {
         final EchonetObject echonetObject = devicesByKey.get(message.instanceKey);
         if (null != echonetObject) {
-            if (echonetObject instanceof EchonetDevice) {
+            if (echonetObject instanceof EchonetDevice device) {
                 logger.debug("Update item: {} already discovered", message.instanceKey);
-                EchonetDevice device = (EchonetDevice) echonetObject;
                 device.setTimeouts(message.pollIntervalMs, message.retryTimeoutMs);
                 device.setListener(message.echonetDeviceListener);
             } else {
@@ -198,18 +197,18 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
         Message message;
         while (null != (message = requestsPoll())) {
             logger.debug("Received request: {}", message);
-            if (message instanceof NewDeviceMessage) {
-                newDeviceInternal((NewDeviceMessage) message);
-            } else if (message instanceof RefreshMessage) {
-                refreshDeviceInternal((RefreshMessage) message);
-            } else if (message instanceof RemoveDevice) {
-                removeDeviceInternal((RemoveDevice) message);
-            } else if (message instanceof UpdateDevice) {
-                updateDeviceInternal((UpdateDevice) message);
-            } else if (message instanceof StartDiscoveryMessage) {
-                startDiscoveryInternal((StartDiscoveryMessage) message);
-            } else if (message instanceof StopDiscoveryMessage) {
-                stopDiscoveryInternal((StopDiscoveryMessage) message);
+            if (message instanceof NewDeviceMessage deviceMessage) {
+                newDeviceInternal(deviceMessage);
+            } else if (message instanceof RefreshMessage refreshMessage) {
+                refreshDeviceInternal(refreshMessage);
+            } else if (message instanceof RemoveDevice device) {
+                removeDeviceInternal(device);
+            } else if (message instanceof UpdateDevice device) {
+                updateDeviceInternal(device);
+            } else if (message instanceof StartDiscoveryMessage discoveryMessage) {
+                startDiscoveryInternal(discoveryMessage);
+            } else if (message instanceof StopDiscoveryMessage discoveryMessage) {
+                stopDiscoveryInternal(discoveryMessage);
             }
         }
     }
@@ -319,7 +318,7 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(EchonetDiscoveryService.class);
+        return List.of(EchonetDiscoveryService.class);
     }
 
     private abstract static class Message {
@@ -390,6 +389,7 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
             this.state = state;
         }
 
+        @Override
         public String toString() {
             return "UpdateDevice{" + "instanceKey=" + instanceKey + ", channelId='" + channelId + '\'' + ", state="
                     + state + "} " + super.toString();
index 571748dd96a654be1c4435bb4292d9ea37b30bed..acef67b57a44f246379728df41ae7cfa628a8e9f 100644 (file)
@@ -88,10 +88,10 @@ public class EchonetLiteHandler extends BaseThingHandler implements EchonetDevic
             } else {
                 updateState(channelUID, currentState);
             }
-        } else if (command instanceof State) {
+        } else if (command instanceof State stateCommand) {
             logger.debug("Updating: {} to {}", channelUID, command);
 
-            handler.updateDevice(requireNonNull(instanceKey), channelUID.getId(), (State) command);
+            handler.updateDevice(requireNonNull(instanceKey), channelUID.getId(), stateCommand);
         }
     }
 
@@ -124,6 +124,7 @@ public class EchonetLiteHandler extends BaseThingHandler implements EchonetDevic
         }
     }
 
+    @Override
     public void handleRemoval() {
         @Nullable
         final EchonetLiteBridgeHandler bridgeHandler = bridgeHandler();
@@ -136,6 +137,7 @@ public class EchonetLiteHandler extends BaseThingHandler implements EchonetDevic
         bridgeHandler.removeDevice(requireNonNull(instanceKey));
     }
 
+    @Override
     public void onInitialised(String identifier, InstanceKey instanceKey, Map<String, String> channelIdAndType) {
         logger.debug("Initialised Channels: {}", channelIdAndType);
 
@@ -167,6 +169,7 @@ public class EchonetLiteHandler extends BaseThingHandler implements EchonetDevic
         updateStatus(ThingStatus.ONLINE);
     }
 
+    @Override
     public void onUpdated(final String channelId, final State value) {
         stateByChannelId.put(channelId, value);
 
@@ -176,10 +179,12 @@ public class EchonetLiteHandler extends BaseThingHandler implements EchonetDevic
         updateState(channelId, value);
     }
 
+    @Override
     public void onRemoved() {
         updateStatus(ThingStatus.REMOVED);
     }
 
+    @Override
     public void onOffline() {
         if (ThingStatus.OFFLINE != getThing().getStatus()) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
index c479bbf64f3fdd79077c45cb1dd1ace215cae3dc..0439ca2dc321ab899800f9def85b4f7e01ae5fde 100644 (file)
@@ -96,6 +96,7 @@ public abstract class EchonetObject {
     public void refreshAll(long nowMs) {
     }
 
+    @Override
     public String toString() {
         return "ItemBase{" + "instanceKey=" + instanceKey + ", pendingProperties=" + pendingGets + '}';
     }
index 54539204c76a4dab433f0584e0236203d4d735ae..3bbda8ab85ef113fd4301322a8cf8adbcdd988ed 100644 (file)
@@ -86,6 +86,7 @@ public class EchonetPropertyMap {
         return properties;
     }
 
+    @Override
     public String toString() {
         return "EnPropertyMap{" + "propertyMap=" + HexUtil.hex(propertyMap) + '}';
     }
index 04cd6767b7e7005c0ae81dcb10332b85bf413008..2245874571cbfe7197dd10dcb7b7624bd5372739 100644 (file)
@@ -234,16 +234,19 @@ public interface Epc {
             this(code, stateCodec, stateCodec);
         }
 
+        @Override
         public int code() {
             return code;
         }
 
         @Nullable
+        @Override
         public StateDecode decoder() {
             return stateDecode;
         }
 
         @Nullable
+        @Override
         public StateEncode encoder() {
             return stateEncode;
         }
@@ -363,16 +366,19 @@ public interface Epc {
             this(code, stateCodec, stateCodec);
         }
 
+        @Override
         public int code() {
             return code;
         }
 
         @Nullable
+        @Override
         public StateDecode decoder() {
             return stateDecode;
         }
 
         @Nullable
+        @Override
         public StateEncode encoder() {
             return stateEncode;
         }
@@ -389,6 +395,7 @@ public interface Epc {
             this.code = code;
         }
 
+        @Override
         public int code() {
             return code;
         }
@@ -421,16 +428,19 @@ public interface Epc {
             this(code, stateCodec, stateCodec);
         }
 
+        @Override
         public int code() {
             return code;
         }
 
         @Nullable
+        @Override
         public StateDecode decoder() {
             return stateDecode;
         }
 
         @Nullable
+        @Override
         public StateEncode encoder() {
             return stateEncode;
         }
@@ -445,6 +455,7 @@ public interface Epc {
             this.code = code;
         }
 
+        @Override
         public int code() {
             return code;
         }
@@ -480,6 +491,7 @@ public interface Epc {
             this.code = code;
         }
 
+        @Override
         public int code() {
             return code;
         }
index cebb946fab1325953fa873c1f32c2262716648bd..08abf06d923ebe6549a6a6af969878e7527bdb48 100644 (file)
@@ -36,6 +36,7 @@ public class InstanceKey {
         this.instance = instance;
     }
 
+    @Override
     public String toString() {
         return "InstanceKey{" + "address=" + address + ", klass=" + klass + ", instance=" + instance + '}';
     }
@@ -45,6 +46,7 @@ public class InstanceKey {
                 + hex(instance);
     }
 
+    @Override
     public boolean equals(@Nullable final Object o) {
         if (this == o) {
             return true;
@@ -56,6 +58,7 @@ public class InstanceKey {
         return instance == that.instance && address.equals(that.address) && klass == that.klass;
     }
 
+    @Override
     public int hashCode() {
         return Objects.hash(address, klass, instance);
     }
index 44e3fb34dfbf19e0b305055bf9c01662df972351..44f857d13a9aa3224fb6fdd054be3d51c2149712 100644 (file)
@@ -49,15 +49,18 @@ public interface StateCodec extends StateEncode, StateDecode {
             this.off = off;
         }
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             return b(on) == edt.get() ? OnOffType.ON : OnOffType.OFF;
         }
 
+        @Override
         public void encodeState(final State state, final ByteBuffer edt) {
             final OnOffType onOff = (OnOffType) state;
             edt.put(onOff == OnOffType.ON ? b(on) : b(off));
         }
 
+        @Override
         public String itemType() {
             return "Switch";
         }
@@ -67,6 +70,7 @@ public interface StateCodec extends StateEncode, StateDecode {
 
         INSTANCE;
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             final int pdc = edt.remaining();
             if (pdc != 4) {
@@ -76,6 +80,7 @@ public interface StateCodec extends StateEncode, StateDecode {
             return new StringType("" + (char) edt.get(edt.position() + 2));
         }
 
+        @Override
         public String itemType() {
             return "String";
         }
@@ -85,10 +90,12 @@ public interface StateCodec extends StateEncode, StateDecode {
 
         INSTANCE;
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             return new StringType(hex(edt, "", "", "", ""));
         }
 
+        @Override
         public String itemType() {
             return "String";
         }
@@ -97,6 +104,7 @@ public interface StateCodec extends StateEncode, StateDecode {
     enum OperatingTimeDecode implements StateDecode {
         INSTANCE;
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             // Specification isn't explicit about byte order, but seems to be work with testing.
             edt.order(ByteOrder.BIG_ENDIAN);
@@ -127,6 +135,7 @@ public interface StateCodec extends StateEncode, StateDecode {
             return new QuantityType<>(timeUnit.toSeconds(time), Units.SECOND);
         }
 
+        @Override
         public String itemType() {
             return "Number:Time";
         }
@@ -158,16 +167,19 @@ public interface StateCodec extends StateEncode, StateDecode {
             }
         }
 
+        @Override
         public String itemType() {
             return "String";
         }
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             final int value = edt.get() & 0xFF;
             final Option option = optionByValue[value];
             return null != option ? option.state : unknown;
         }
 
+        @Override
         public void encodeState(final State state, final ByteBuffer edt) {
             final Option option = optionByName.get(state.toFullString());
             if (null != option) {
@@ -182,15 +194,18 @@ public interface StateCodec extends StateEncode, StateDecode {
 
         INSTANCE;
 
+        @Override
         public String itemType() {
             return "Number";
         }
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             final int value = edt.get(); // Should expand to typed value (mask excluded)
             return new DecimalType(value);
         }
 
+        @Override
         public void encodeState(final State state, final ByteBuffer edt) {
             edt.put((byte) (((DecimalType) state).intValue()));
         }
@@ -199,15 +214,18 @@ public interface StateCodec extends StateEncode, StateDecode {
     enum Temperature8bitCodec implements StateCodec {
         INSTANCE;
 
+        @Override
         public State decodeState(final ByteBuffer edt) {
             final int value = edt.get();
             return new QuantityType<>(value, SIUnits.CELSIUS);
         }
 
+        @Override
         public String itemType() {
             return "Number:Temperature";
         }
 
+        @Override
         public void encodeState(final State state, final ByteBuffer edt) {
             final @Nullable QuantityType<?> tempCelsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
             edt.put((byte) (Objects.requireNonNull(tempCelsius).intValue()));
index 3fa2251c00c78aec31318faf6d7b10bc3a74c78f..1d5f1d765e9b9f9726188245416f1b72d22c8f71 100644 (file)
@@ -69,8 +69,8 @@ public class EcobeeActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof EcobeeThermostatBridgeHandler) {
-            this.handler = (EcobeeThermostatBridgeHandler) handler;
+        if (handler instanceof EcobeeThermostatBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
         }
     }
 
index d50fc820c9654fd1ef4fcf113ee34492607bf96f..252e7e5df003401768ac391bcb6f8be25ae2634f 100644 (file)
@@ -39,5 +39,5 @@ enum EcobeeAuthState {
     /*
      * This state indicates that the "authorize" and "token" steps were successful.
      */
-    COMPLETE;
+    COMPLETE
 }
index 18870310a2fa0cf6871576071963d5895e2d093f..5465e62ac6c900efb451debf89e413175a1e22a9 100644 (file)
@@ -61,8 +61,8 @@ public class EcobeeDiscoveryService extends AbstractDiscoveryService implements
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof EcobeeAccountBridgeHandler) {
-            this.bridgeHandler = (EcobeeAccountBridgeHandler) handler;
+        if (handler instanceof EcobeeAccountBridgeHandler accountBridgeHandler) {
+            this.bridgeHandler = accountBridgeHandler;
         }
     }
 
index 1d61419d873f37e6c76803f09bf9162a93ec7fc6..57314acd88cb925b2596ed07b216d7ae27ea2880 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.ecobee.internal.EcobeeBindingConstants.CONFIG_
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -137,7 +136,7 @@ public class EcobeeAccountBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(EcobeeDiscoveryService.class);
+        return Set.of(EcobeeDiscoveryService.class);
     }
 
     @Override
index 20867209653c66b245185a2b363b61f1526e6bb8..91fbfcdc29fcc24e831c6e1b7c5585116f0316ac 100644 (file)
@@ -16,10 +16,10 @@ import static org.openhab.binding.ecobee.internal.EcobeeBindingConstants.*;
 
 import java.lang.reflect.Field;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -237,9 +237,9 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
     public boolean actionPerformFunction(AbstractFunction function) {
         logger.debug("ThermostatBridge: Perform function '{}' on thermostat {}", function.type, thermostatId);
         SelectionDTO selection = new SelectionDTO();
-        selection.setThermostats(Collections.singleton(thermostatId));
+        selection.setThermostats(Set.of(thermostatId));
         FunctionRequest request = new FunctionRequest(selection);
-        request.functions = Collections.singletonList(function);
+        request.functions = List.of(function);
         EcobeeAccountBridgeHandler handler = getBridgeHandler();
         if (handler != null) {
             return handler.performThermostatFunction(request);
@@ -249,7 +249,7 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(EcobeeActions.class);
+        return List.of(EcobeeActions.class);
     }
 
     public void updateChannels(ThermostatDTO thermostat) {
@@ -329,15 +329,15 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
                     success = true;
                 }
             } else if (Integer.class.isAssignableFrom(fieldClass)) {
-                if (command instanceof DecimalType) {
+                if (command instanceof DecimalType decimalCommand) {
                     logger.debug("Set field of type Integer to value of DecimalType");
-                    field.set(object, Integer.valueOf(((DecimalType) command).intValue()));
+                    field.set(object, Integer.valueOf(decimalCommand.intValue()));
                     success = true;
-                } else if (command instanceof QuantityType) {
-                    Unit<?> unit = ((QuantityType<?>) command).getUnit();
+                } else if (command instanceof QuantityType quantityCommand) {
+                    Unit<?> unit = quantityCommand.getUnit();
                     logger.debug("Set field of type Integer to value of QuantityType with unit {}", unit);
                     if (unit.equals(ImperialUnits.FAHRENHEIT) || unit.equals(SIUnits.CELSIUS)) {
-                        QuantityType<?> quantity = ((QuantityType<?>) command).toUnit(ImperialUnits.FAHRENHEIT);
+                        QuantityType<?> quantity = quantityCommand.toUnit(ImperialUnits.FAHRENHEIT);
                         if (quantity != null) {
                             field.set(object, quantity.intValue() * 10);
                             success = true;
@@ -801,7 +801,7 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
 
     private void performThermostatUpdate(ThermostatDTO thermostat) {
         SelectionDTO selection = new SelectionDTO();
-        selection.setThermostats(Collections.singleton(thermostatId));
+        selection.setThermostats(Set.of(thermostatId));
         ThermostatUpdateRequestDTO request = new ThermostatUpdateRequestDTO(selection);
         request.thermostat = thermostat;
         EcobeeAccountBridgeHandler handler = getBridgeHandler();
index 2f27e1df8ae0bcb56d1aa1cd777a9016dab8c655..589959caadaf0668b9faf7eb9d0942c2ea3cc8e0 100644 (file)
@@ -104,13 +104,13 @@ public class EcoTouchConnector {
             cause = e.toString();
         }
 
-        if (line2 != null && line2.trim().equals("#E_USER_DONT_EXIST")) {
+        if (line2 != null && "#E_USER_DONT_EXIST".equals(line2.trim())) {
             throw new IOException("Username does not exist.");
         }
-        if (line2 != null && line2.trim().equals("#E_PASS_DONT_MATCH")) {
+        if (line2 != null && "#E_PASS_DONT_MATCH".equals(line2.trim())) {
             throw new IOException("Password does not match.");
         }
-        if (line2 != null && line2.trim().equals("#E_TOO_MANY_USERS")) {
+        if (line2 != null && "#E_TOO_MANY_USERS".equals(line2.trim())) {
             throw new IOException("Too many users already logged in.");
         }
         if (cookies == null) {
index e605b280e654e520eb37ffa0db6b6f24a758f3f0..34e19f1ed0b37de97856cc0475911ba8b0b24ff0 100644 (file)
@@ -122,10 +122,8 @@ public class EcoTouchHandler extends BaseThingHandler {
                     localConnector.setValue(ecoTouchTag.getTagName(), raw);
                 } else {
                     if (ecoTouchTag.getUnit() != ONE) {
-                        if (command instanceof QuantityType) {
-                            // convert from user unit to heat pump unit
-                            QuantityType<?> value = (QuantityType<?>) command;
-                            QuantityType<?> rawUnit = value.toUnit(ecoTouchTag.getUnit());
+                        if (command instanceof QuantityType quantityCommand) {
+                            QuantityType<?> rawUnit = quantityCommand.toUnit(ecoTouchTag.getUnit());
                             if (rawUnit != null) {
                                 int raw = (int) (rawUnit.doubleValue() * ecoTouchTag.getDivisor());
                                 localConnector.setValue(ecoTouchTag.getTagName(), raw);
index 1d0a941662ef99b9668c1f83d85375a22b577355..a3f56762c2f7756e21dd938adb14a42c10fad315 100644 (file)
@@ -71,14 +71,14 @@ public class EcovacsVacuumActions implements ThingActions {
     }
 
     public static void playSound(@Nullable ThingActions actions, String type) {
-        if (actions instanceof EcovacsVacuumActions) {
-            ((EcovacsVacuumActions) actions).playSound(type);
+        if (actions instanceof EcovacsVacuumActions action) {
+            action.playSound(type);
         }
     }
 
     public static void playSoundWithId(@Nullable ThingActions actions, int soundId) {
-        if (actions instanceof EcovacsVacuumActions) {
-            ((EcovacsVacuumActions) actions).playSoundWithId(soundId);
+        if (actions instanceof EcovacsVacuumActions action) {
+            action.playSoundWithId(soundId);
         }
     }
 }
index 943846afdc1294103563330ac2737e14ce1390db..9d7a78f69a55147e6e46d00eba8f91cd86fb023f 100644 (file)
@@ -40,9 +40,8 @@ public class GetActiveMapIdCommand extends IotDeviceCommand<String> {
     @Override
     public String convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            CachedMapInfoReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    CachedMapInfoReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            CachedMapInfoReport resp = jsonResponse.getResponsePayloadAs(gson, CachedMapInfoReport.class);
             return resp.mapInfos.stream().filter(i -> i.used != 0).map(i -> i.mapId).findFirst().orElse("");
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index 9b5b0cdcf42f030a60ec01887447b6b0c183db06..f88d7c7533e1812b339a649dbfaec73d08f379bb 100644 (file)
@@ -40,9 +40,8 @@ public class GetBatteryInfoCommand extends IotDeviceCommand<Integer> {
     @Override
     public Integer convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            BatteryReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    BatteryReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            BatteryReport resp = jsonResponse.getResponsePayloadAs(gson, BatteryReport.class);
             return resp.percent;
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index ebf79af19d02ca70d2e13dab7b0304e8b1f27385..1d952f59c8a1d94874960e4ad39bd7a4112e6dc7 100644 (file)
@@ -41,9 +41,8 @@ public class GetChargeStateCommand extends IotDeviceCommand<ChargeMode> {
     @Override
     public ChargeMode convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            ChargeReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    ChargeReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            ChargeReport resp = jsonResponse.getResponsePayloadAs(gson, ChargeReport.class);
             return resp.isCharging != 0 ? ChargeMode.CHARGING : ChargeMode.IDLE;
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index 66b23e65238efd8dc28241c175557f881afb05fc..f15d80ee65c4371742ad796a8ffb8cd938aefdc7 100644 (file)
@@ -50,8 +50,7 @@ public class GetCleanStateCommand extends IotDeviceCommand<CleanMode> {
     @Override
     public CleanMode convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            final PortalIotCommandJsonResponse jsonResponse = (PortalIotCommandJsonResponse) response;
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
             final CleanMode mode;
             if (version == ProtocolVersion.JSON) {
                 CleanReport resp = jsonResponse.getResponsePayloadAs(gson, CleanReport.class);
index 92dbaed614635cfe032f896c3edf189d9cb0efe4..b190d8662054ca208e05dfec21b66fecff2d36d0 100644 (file)
@@ -65,8 +65,8 @@ public class GetComponentLifeSpanCommand extends IotDeviceCommand<Integer> {
     @Override
     public Integer convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            JsonElement respPayloadRaw = ((PortalIotCommandJsonResponse) response).getResponsePayload(gson);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            JsonElement respPayloadRaw = jsonResponse.getResponsePayload(gson);
             Type type = new TypeToken<List<ComponentLifeSpanReport>>() {
             }.getType();
             try {
index 7c12ccee26d8cd87248937d4c3227aa98e4eebb9..889b7128deac8ced49357af7471b8533e29c4609 100644 (file)
@@ -47,9 +47,8 @@ public class GetContinuousCleaningCommand extends IotDeviceCommand<Boolean> {
     @Override
     public Boolean convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            EnabledStateReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    EnabledStateReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            EnabledStateReport resp = jsonResponse.getResponsePayloadAs(gson, EnabledStateReport.class);
             return resp.enabled != 0;
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index fac4743c9bcfc9b7bc44a62dab37fc1797569699..f1f2327f157648e85978933a55d16ab7238e68aa 100644 (file)
@@ -42,8 +42,8 @@ public class GetErrorCommand extends IotDeviceCommand<Optional<Integer>> {
     @Override
     public Optional<Integer> convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version,
             Gson gson) throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            ErrorReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson, ErrorReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            ErrorReport resp = jsonResponse.getResponsePayloadAs(gson, ErrorReport.class);
             if (resp.errorCodes.isEmpty()) {
                 return Optional.empty();
             }
index 496fbb49fa8fb791f7e1bc499b65b1b728ea7462..ad7392c6966756c169b2ac385f154da2f1f00f9c 100644 (file)
@@ -65,9 +65,8 @@ public class GetMapSpotAreasWithMapIdCommand extends IotDeviceCommand<List<Strin
     @Override
     public List<String> convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            MapSetReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    MapSetReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            MapSetReport resp = jsonResponse.getResponsePayloadAs(gson, MapSetReport.class);
             return resp.subsets.stream().map(i -> i.id).collect(Collectors.toList());
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index e300e9879cf88c2b2e6d05e745517f426211b154..31cf3c5f28306e8c85a7991a707778b3792837ab 100644 (file)
@@ -41,9 +41,8 @@ public class GetMoppingWaterAmountCommand extends IotDeviceCommand<MoppingWaterA
     @Override
     public MoppingWaterAmount convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version,
             Gson gson) throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            WaterInfoReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    WaterInfoReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            WaterInfoReport resp = jsonResponse.getResponsePayloadAs(gson, WaterInfoReport.class);
             return MoppingWaterAmount.fromApiValue(resp.waterAmount);
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index 4c23ca375dd3cabe45e9bce95c2b7fdc5da1d67c..227ca688f639c08f3694c278e3e2effb7563c5fd 100644 (file)
@@ -42,9 +42,8 @@ public class GetNetworkInfoCommand extends IotDeviceCommand<NetworkInfo> {
     @Override
     public NetworkInfo convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            NetworkInfoReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    NetworkInfoReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            NetworkInfoReport resp = jsonResponse.getResponsePayloadAs(gson, NetworkInfoReport.class);
             try {
                 return new NetworkInfo(resp.ip, resp.mac, resp.ssid, Integer.valueOf(resp.rssi));
             } catch (NumberFormatException e) {
index 45b86d8ead647263b158551ba74aabd6a5845e8f..f1b52422813d152e0800192f0a097b010f5195f9 100644 (file)
@@ -41,8 +41,8 @@ public class GetSuctionPowerCommand extends IotDeviceCommand<SuctionPower> {
     @Override
     public SuctionPower convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            SpeedReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson, SpeedReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            SpeedReport resp = jsonResponse.getResponsePayloadAs(gson, SpeedReport.class);
             return SuctionPower.fromJsonValue(resp.speedLevel);
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index 04179c1c5425b6ded593ee036fed3f7b7ecd992f..b1edd847f3606b9b08eccc48dce80a98f9ce4d1e 100644 (file)
@@ -55,8 +55,8 @@ public class GetTotalStatsCommand extends IotDeviceCommand<GetTotalStatsCommand.
     @Override
     public TotalStats convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            return ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson, TotalStats.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            return jsonResponse.getResponsePayloadAs(gson, TotalStats.class);
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
             String area = XPathUtils.getFirstXPathMatch(payload, "//@a").getNodeValue();
index fc75720425c541a4510b133cefbf7f939025e100..353910b75f20550d7a31f2bce5af83e13db25bc1 100644 (file)
@@ -41,9 +41,8 @@ public class GetVolumeCommand extends IotDeviceCommand<Integer> {
     @Override
     public Integer convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            JsonResponse resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    JsonResponse.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            JsonResponse resp = jsonResponse.getResponsePayloadAs(gson, JsonResponse.class);
             return resp.volume;
         } else {
             // unsupported in XML case?
index 55e5d3265223fc783dae177ecd554d1094d65805..57ef18edf2b218e40c1c7278cbae59ae378b4a12 100644 (file)
@@ -40,9 +40,8 @@ public class GetWaterSystemPresentCommand extends IotDeviceCommand<Boolean> {
     @Override
     public Boolean convertResponse(AbstractPortalIotCommandResponse response, ProtocolVersion version, Gson gson)
             throws DataParsingException {
-        if (response instanceof PortalIotCommandJsonResponse) {
-            WaterInfoReport resp = ((PortalIotCommandJsonResponse) response).getResponsePayloadAs(gson,
-                    WaterInfoReport.class);
+        if (response instanceof PortalIotCommandJsonResponse jsonResponse) {
+            WaterInfoReport resp = jsonResponse.getResponsePayloadAs(gson, WaterInfoReport.class);
             return resp.waterPlatePresent != 0;
         } else {
             String payload = ((PortalIotCommandXmlResponse) response).getResponsePayloadXml();
index 2411fe5041ff2a69902562a9f0ca2cf087e3914e..a9f4d65f593fab1b535abaa49ccaf1a1b9a595c9 100644 (file)
@@ -172,7 +172,7 @@ public final class EcovacsApiImpl implements EcovacsApi {
         List<EcovacsDevice> devices = new ArrayList<>();
         for (Device dev : getDeviceList()) {
             Optional<DeviceDescription> descOpt = Optional.ofNullable(descriptions.get(dev.getDeviceClass()));
-            if (!descOpt.isPresent()) {
+            if (descOpt.isEmpty()) {
                 if (products == null) {
                     products = getIotProductMap();
                 }
@@ -226,7 +226,7 @@ public final class EcovacsApiImpl implements EcovacsApi {
             DeviceDescription desc = descEntry.getValue();
             if (desc.deviceClassLink != null) {
                 Optional<DeviceDescription> linkedDescOpt = Optional.ofNullable(descs.get(desc.deviceClassLink));
-                if (!linkedDescOpt.isPresent()) {
+                if (linkedDescOpt.isEmpty()) {
                     logger.warn("Device description {} links unknown description {}", desc.deviceClass,
                             desc.deviceClassLink);
                 }
index fe57fd3f2306a152027b14e1d6b3e3e1dfbbeeb1..e9e9a5b1df3509412715b6917500dd1cfaf647bd 100644 (file)
@@ -177,8 +177,8 @@ public class EcovacsIotMqDevice implements EcovacsDevice {
             logger.debug("Established MQTT connection to device {}", getSerialNumber());
         } catch (ExecutionException e) {
             Throwable cause = e.getCause();
-            boolean isAuthFailure = cause instanceof Mqtt3ConnAckException && ((Mqtt3ConnAckException) cause)
-                    .getMqttMessage().getReturnCode() == Mqtt3ConnAckReturnCode.NOT_AUTHORIZED;
+            boolean isAuthFailure = cause instanceof Mqtt3ConnAckException connAckException
+                    && connAckException.getMqttMessage().getReturnCode() == Mqtt3ConnAckReturnCode.NOT_AUTHORIZED;
             throw new EcovacsApiException(e, isAuthFailure);
         }
     }
index 193ed6ad993b54f2b71758d498a9cfabe870d168..1c4229e000f15a496fca94f769a1505f8cb7b685 100644 (file)
@@ -347,8 +347,7 @@ public class EcovacsXmppDevice implements EcovacsDevice {
                 return null;
             }
 
-            if (iqRequest instanceof DeviceCommandIQ) {
-                DeviceCommandIQ iq = (DeviceCommandIQ) iqRequest;
+            if (iqRequest instanceof DeviceCommandIQ iq) {
 
                 try {
                     if (!iq.id.isEmpty()) {
@@ -372,8 +371,8 @@ public class EcovacsXmppDevice implements EcovacsDevice {
                 } catch (DataParsingException e) {
                     listener.onEventStreamFailure(EcovacsXmppDevice.this, e);
                 }
-            } else if (iqRequest instanceof ErrorIQ) {
-                StanzaError error = ((ErrorIQ) iqRequest).getError();
+            } else if (iqRequest instanceof ErrorIQ errorIQ) {
+                StanzaError error = errorIQ.getError();
                 logger.trace("{}: Got error response {}", getSerialNumber(), error);
                 listener.onEventStreamFailure(EcovacsXmppDevice.this,
                         new XMPPException.XMPPErrorException(iqRequest, error));
index 13987989ff0aad166c78c538573c101306602810..3692a1420d5aaec3d7c37f7e592477ac7e7b302c 100644 (file)
@@ -24,5 +24,5 @@ public enum PortalTodo {
     @SerializedName("GetDeviceList")
     GET_DEVICE_LIST,
     @SerializedName("loginByItToken")
-    LOGIN_BY_TOKEN;
+    LOGIN_BY_TOKEN
 }
index 33a3ce49c0631ced26b5dc78d7079d97337e90b1..a1e06e3a1005a795369f2aee06e3da9ed8bd4270 100644 (file)
@@ -14,9 +14,9 @@ package org.openhab.binding.ecovacs.internal.discovery;
 
 import static org.openhab.binding.ecovacs.internal.EcovacsBindingConstants.*;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -57,13 +57,13 @@ public class EcovacsDeviceDiscoveryService extends AbstractDiscoveryService impl
             this::scanForDevices);
 
     public EcovacsDeviceDiscoveryService() {
-        super(Collections.singleton(THING_TYPE_VACUUM), DISCOVER_TIMEOUT_SECONDS, true);
+        super(Set.of(THING_TYPE_VACUUM), DISCOVER_TIMEOUT_SECONDS, true);
     }
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof EcovacsApiHandler) {
-            this.apiHandler = (EcovacsApiHandler) handler;
+        if (handler instanceof EcovacsApiHandler ecovacsApiHandler) {
+            this.apiHandler = ecovacsApiHandler;
             this.apiHandler.setDiscoveryService(this);
         }
     }
index 70c26224ae72eb6d87d6232615350ad9fb701268..4367d45a2c3de54441469bc59e97dfe22729e41b 100644 (file)
@@ -15,8 +15,8 @@ package org.openhab.binding.ecovacs.internal.handler;
 import static org.openhab.binding.ecovacs.internal.EcovacsBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -96,7 +96,7 @@ public class EcovacsApiHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(EcovacsDeviceDiscoveryService.class);
+        return Set.of(EcovacsDeviceDiscoveryService.class);
     }
 
     @Override
index febdb7edc17ef959c25939597334c44ee358386d..128afa340900ed500c3758251bbd6165463e1292 100644 (file)
@@ -18,10 +18,10 @@ import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.Optional;
+import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
@@ -152,7 +152,7 @@ public class EcovacsVacuumHandler extends BaseThingHandler implements EcovacsDev
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(EcovacsVacuumActions.class);
+        return Set.of(EcovacsVacuumActions.class);
     }
 
     @Override
@@ -171,8 +171,8 @@ public class EcovacsVacuumHandler extends BaseThingHandler implements EcovacsDev
                     device.sendCommand(cmd);
                     return;
                 }
-            } else if (channel.equals(CHANNEL_ID_VOICE_VOLUME) && command instanceof DecimalType) {
-                int volumePercent = ((DecimalType) command).intValue();
+            } else if (channel.equals(CHANNEL_ID_VOICE_VOLUME) && command instanceof DecimalType volume) {
+                int volumePercent = volume.intValue();
                 device.sendCommand(new SetVolumeCommand((volumePercent + 5) / 10));
                 return;
             } else if (channel.equals(CHANNEL_ID_SUCTION_POWER) && command instanceof StringType) {
@@ -191,7 +191,7 @@ public class EcovacsVacuumHandler extends BaseThingHandler implements EcovacsDev
                 if (command instanceof OnOffType) {
                     device.sendCommand(new SetDustbinAutoEmptyCommand(command == OnOffType.ON));
                     return;
-                } else if (command instanceof StringType && command.toString().equals("trigger")) {
+                } else if (command instanceof StringType && "trigger".equals(command.toString())) {
                     device.sendCommand(new EmptyDustbinCommand());
                     return;
                 }
@@ -201,8 +201,8 @@ public class EcovacsVacuumHandler extends BaseThingHandler implements EcovacsDev
             } else if (channel.equals(CHANNEL_ID_CONTINUOUS_CLEANING) && command instanceof OnOffType) {
                 device.sendCommand(new SetContinuousCleaningCommand(command == OnOffType.ON));
                 return;
-            } else if (channel.equals(CHANNEL_ID_CLEANING_PASSES) && command instanceof DecimalType) {
-                int passes = ((DecimalType) command).intValue();
+            } else if (channel.equals(CHANNEL_ID_CLEANING_PASSES) && command instanceof DecimalType type) {
+                int passes = type.intValue();
                 device.sendCommand(new SetDefaultCleanPassesCommand(passes));
                 lastDefaultCleaningPasses = passes; // if we get here, the command was executed successfully
                 return;
index e29d69ea34a1c7a5f03c5c82b2b2dfe71e9c9296..365d65c67e2b018f12fb6983d52c9f5c96587f44 100644 (file)
@@ -201,10 +201,10 @@ public class EcowattHandler extends BaseThingHandler {
             // Invalidate the cache to be sure the next request will trigger the API
             cachedApiResponse.invalidateValue();
 
-            if (retryIfApiLimitReached && exception instanceof EcowattApiLimitException
-                    && ((EcowattApiLimitException) exception).getRetryAfter() > 0) {
+            if (retryIfApiLimitReached && exception instanceof EcowattApiLimitException limitException
+                    && limitException.getRetryAfter() > 0) {
                 // Will retry when the API is available again (just after the limit expired)
-                retryDelay = ((EcowattApiLimitException) exception).getRetryAfter();
+                retryDelay = limitException.getRetryAfter();
             }
         } else {
             updateStatus(ThingStatus.ONLINE);
index d918783a0c5f4174249fca7827d07e7fceb72bf4..4f7d70a5a8ec00eba67389ffa6c577d70fa67197 100644 (file)
@@ -45,8 +45,8 @@ public class ElectroluxAirDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof ElectroluxAirBridgeHandler) {
-            this.handler = (ElectroluxAirBridgeHandler) handler;
+        if (handler instanceof ElectroluxAirBridgeHandler bridgeHandler) {
+            this.handler = bridgeHandler;
         }
     }
 
index b510aadcb5aa5fb46b728d1ce2cee606f0222fd5..f8f37555a7fff7f3c63958457bb166ede0bbe578 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.electroluxair.internal.handler;
 import static org.openhab.binding.electroluxair.internal.ElectroluxAirBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -50,7 +49,7 @@ import com.google.gson.Gson;
 @NonNullByDefault
 public class ElectroluxAirBridgeHandler 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 int refreshTimeInSeconds = 300;
 
@@ -100,7 +99,7 @@ public class ElectroluxAirBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ElectroluxAirDiscoveryService.class);
+        return Set.of(ElectroluxAirDiscoveryService.class);
     }
 
     @Override
index e0196c29b4e3c9f0b9f19a2359c4b6269a23329a..936da60cd95e1333ee5fe44148c23a1b00b87353 100644 (file)
@@ -82,9 +82,7 @@ public class EleroTransmitterStickHandlerFactory extends BaseThingHandlerFactory
 
             return bridgeHandler;
         } else if (thingTypeUID.equals(THING_TYPE_ELERO_CHANNEL)) {
-            EleroChannelHandler h = new EleroChannelHandler(thing);
-
-            return h;
+            return new EleroChannelHandler(thing);
         }
 
         return null;
index 9d273a2ff4a3b6173f50f34fd9beea639f3009fd..0f5760bc649f4a8cd9cc215402a706b6caf1cc08 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.elerotransmitterstick.internal.discovery;
 import static org.openhab.binding.elerotransmitterstick.internal.EleroTransmitterStickBindingConstants.*;
 
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -44,7 +44,7 @@ public class EleroChannelDiscoveryService extends AbstractDiscoveryService {
      * Creates the discovery service for the given handler and converter.
      */
     public EleroChannelDiscoveryService(EleroTransmitterStickHandler stickHandler) {
-        super(Collections.singleton(THING_TYPE_ELERO_CHANNEL), DISCOVER_TIMEOUT_SECONDS, true);
+        super(Set.of(THING_TYPE_ELERO_CHANNEL), DISCOVER_TIMEOUT_SECONDS, true);
 
         bridge = stickHandler;
     }
index 8d3b0b0493e7571a94677ca79094e6499036ca4a..dda33d81776bfb42697c8705e0dc48fe8bb50778 100644 (file)
@@ -14,7 +14,7 @@ package org.openhab.binding.elerotransmitterstick.internal.handler;
 
 import static org.openhab.binding.elerotransmitterstick.internal.EleroTransmitterStickBindingConstants.*;
 
-import java.util.Collections;
+import java.util.List;
 
 import org.openhab.binding.elerotransmitterstick.internal.config.EleroChannelConfig;
 import org.openhab.binding.elerotransmitterstick.internal.stick.CommandType;
@@ -88,20 +88,20 @@ public class EleroChannelHandler extends BaseThingHandler implements StatusListe
 
         if (channelUID.getIdWithoutGroup().equals(CONTROL_CHANNEL)) {
             if (command == UpDownType.UP) {
-                bridge.getStick().sendCommand(CommandType.UP, Collections.singletonList(channelId));
+                bridge.getStick().sendCommand(CommandType.UP, List.of(channelId));
             } else if (command == UpDownType.DOWN) {
-                bridge.getStick().sendCommand(CommandType.DOWN, Collections.singletonList(channelId));
+                bridge.getStick().sendCommand(CommandType.DOWN, List.of(channelId));
             } else if (command == StopMoveType.STOP) {
-                bridge.getStick().sendCommand(CommandType.STOP, Collections.singletonList(channelId));
-            } else if (command instanceof PercentType) {
-                CommandType cmd = CommandType.getForPercent(((PercentType) command).intValue());
+                bridge.getStick().sendCommand(CommandType.STOP, List.of(channelId));
+            } else if (command instanceof PercentType pt) {
+                CommandType cmd = CommandType.getForPercent(pt.intValue());
                 if (cmd != null) {
-                    bridge.getStick().sendCommand(cmd, Collections.singletonList(channelId));
+                    bridge.getStick().sendCommand(cmd, List.of(channelId));
                 } else {
                     logger.debug("Unhandled command {}.", command);
                 }
             } else if (command == RefreshType.REFRESH) {
-                bridge.getStick().requestUpdate(Collections.singletonList(channelId));
+                bridge.getStick().requestUpdate(List.of(channelId));
             }
         }
     }
index 35ca545793f6ca1e470b7905aee698b675b4408e..4462cfac20ab414c71924b46b0129a6448447dc8 100644 (file)
@@ -16,7 +16,6 @@ import java.io.IOException;
 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.Iterator;
@@ -226,7 +225,7 @@ public class TransmitterStick {
             // handle commands that are sent to multiple channels correctly
             if (channelIds.size() > 1) {
                 for (int channelId : channelIds) {
-                    requestUpdates(Collections.singletonList(channelId));
+                    requestUpdates(List.of(channelId));
                 }
             } else if (!channelIds.isEmpty()) {
                 final Integer[] ids = channelIds.toArray(new Integer[channelIds.size()]);
@@ -241,7 +240,7 @@ public class TransmitterStick {
             // handle commands that are sent to multiple channels correctly
             if (channelIds.size() > 1) {
                 for (int channelId : channelIds) {
-                    executeCommand(command, Collections.singletonList(channelId));
+                    executeCommand(command, List.of(channelId));
                 }
             } else if (!channelIds.isEmpty()) {
                 final Integer[] ids = channelIds.toArray(new Integer[channelIds.size()]);
@@ -307,8 +306,8 @@ public class TransmitterStick {
                                 }
                             }
 
-                            if (cmd instanceof TimedCommand) {
-                                long delay = 1000 * ((TimedCommand) cmd).getDuration();
+                            if (cmd instanceof TimedCommand timedCommand) {
+                                long delay = 1000 * timedCommand.getDuration();
                                 logger.debug("adding timed command STOP for channel ids {} to queue with delay {}...",
                                         cmd.getChannelIds(), delay);
 
index b602e96a6e5564bf264e2e7d1107d52448aeea95..570a03ba13f9a51212e8d05dac999bf8dd028ff4 100644 (file)
@@ -136,7 +136,7 @@ public class ElroConnectsBindingConstants {
             .collect(Collectors.toUnmodifiableMap(Map.Entry::getValue, Map.Entry::getKey));
 
     // ELRO device types
-    public static enum ElroDeviceType {
+    public enum ElroDeviceType {
         ENTRY_SENSOR,
         CO_ALARM,
         CXSM_ALARM,
@@ -197,7 +197,7 @@ public class ElroConnectsBindingConstants {
             .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
 
     // ELRO device status
-    public static enum ElroDeviceStatus {
+    public enum ElroDeviceStatus {
         NORMAL,
         TRIGGERED,
         TEST,
index fd3f0114e03c70b6a09631514a0eba59236995a4..bb882d088f0102493cc03276849c6aa5bc6e130a 100644 (file)
@@ -52,8 +52,7 @@ public class ElroConnectsDynamicStateDescriptionProvider implements DynamicState
     @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 1f804bbfe94446fa8cee6de40ca5ad14ad65e970..3a5c9d121553b386fc2906fb2d15b089be897735 100644 (file)
@@ -110,7 +110,7 @@ public abstract class ElroConnectsDevice {
             typeName = getDeviceType();
         }
 
-        return deviceName.isEmpty() ? typeName + "-" + String.valueOf(deviceId) : deviceName;
+        return deviceName.isEmpty() ? typeName + "-" + deviceId : deviceName;
     }
 
     public String getDeviceType() {
index c0dffb2423e2bdf82abadeec6f9a9967987c70c2..8d21f443bc9e7e7b8b036f639dcb1f9dd24ce0e4 100644 (file)
@@ -85,7 +85,7 @@ public class ElroConnectsBridgeDiscoveryService extends AbstractDiscoveryService
                 String firmwareVersion = c.getValue().binVersion;
                 boolean legacy = false;
                 try {
-                    legacy = !(Integer.valueOf(firmwareVersion.substring(firmwareVersion.lastIndexOf(".") + 1)) > 14);
+                    legacy = Integer.valueOf(firmwareVersion.substring(firmwareVersion.lastIndexOf(".") + 1)) <= 14;
                 } catch (NumberFormatException e) {
                     // Assume new firmware if we cannot decode firmwareVersion
                     logger.debug("Cannot get firmware version from {}, assume new firmware", firmwareVersion);
@@ -141,14 +141,9 @@ public class ElroConnectsBridgeDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        ElroConnectsAccountHandler account = null;
-        if (handler instanceof ElroConnectsAccountHandler) {
-            account = (ElroConnectsAccountHandler) handler;
-            accountHandler = account;
-        }
-
-        if (account != null) {
-            account.setDiscoveryService(this);
+        if (handler instanceof ElroConnectsAccountHandler accountHandler) {
+            this.accountHandler = accountHandler;
+            accountHandler.setDiscoveryService(this);
         }
     }
 
index c8f02b52a996ea2b9498180282e232a34bb0082c..a153755051666f8e73041fff1e531320baf84d75 100644 (file)
@@ -121,14 +121,9 @@ public class ElroConnectsDiscoveryService extends AbstractDiscoveryService imple
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        ElroConnectsBridgeHandler bridge = null;
-        if (handler instanceof ElroConnectsBridgeHandler) {
-            bridge = (ElroConnectsBridgeHandler) handler;
-            bridgeHandler = bridge;
-        }
-
-        if (bridge != null) {
-            bridge.setDiscoveryService(this);
+        if (handler instanceof ElroConnectsBridgeHandler bridgeHandler) {
+            this.bridgeHandler = bridgeHandler;
+            bridgeHandler.setDiscoveryService(this);
         }
     }
 
index 6046d5912c22671fe4528e6c858c94fa24011690..d2a818bcdcb0bb2f0c3ac6d43b0c50bc386722c2 100644 (file)
@@ -16,10 +16,10 @@ import java.lang.reflect.Type;
 import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ScheduledFuture;
@@ -349,7 +349,7 @@ public class ElroConnectsAccountHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ElroConnectsBridgeDiscoveryService.class);
+        return Set.of(ElroConnectsBridgeDiscoveryService.class);
     }
 
     /**
index d387dbb4ea27d1f0cb2ccdabd296c74d4ebbb42d..1d62817f4c4c0a4e00cf83510787d428842f1eec 100644 (file)
@@ -23,9 +23,9 @@ import java.net.UnknownHostException;
 import java.nio.charset.StandardCharsets;
 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.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
@@ -864,9 +864,9 @@ public class ElroConnectsBridgeHandler extends BaseBridgeHandler {
             if (SCENE.equals(channelUID.getId())) {
                 if (command instanceof RefreshType) {
                     updateState(SCENE, new StringType(String.valueOf(currentScene)));
-                } else if (command instanceof StringType) {
+                } else if (command instanceof StringType stringCommand) {
                     try {
-                        selectScene(Integer.valueOf(((StringType) command).toString()));
+                        selectScene(Integer.valueOf(stringCommand.toString()));
                     } catch (NumberFormatException nfe) {
                         logger.debug("Cannot interpret scene command {}", command);
                     }
@@ -965,7 +965,7 @@ public class ElroConnectsBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ElroConnectsDiscoveryService.class);
+        return Set.of(ElroConnectsDiscoveryService.class);
     }
 
     public Map<Integer, String> listDevicesFromConsole() {
index a39897deb713731c11b30ca7b5db4137f0974ccd..3e9a3e64271b8d8e63016ad7afa58b5e5f2ecf48 100644 (file)
@@ -280,11 +280,11 @@ public class EnergiDataServiceActions implements ThingActions {
      * @return Map of prices
      */
     public static Map<Instant, BigDecimal> getPrices(@Nullable ThingActions actions, @Nullable String priceElements) {
-        if (actions instanceof EnergiDataServiceActions) {
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
             if (priceElements != null && !priceElements.isBlank()) {
-                return ((EnergiDataServiceActions) actions).getPrices(priceElements);
+                return serviceActions.getPrices(priceElements);
             } else {
-                return ((EnergiDataServiceActions) actions).getPrices();
+                return serviceActions.getPrices();
             }
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
@@ -305,8 +305,8 @@ public class EnergiDataServiceActions implements ThingActions {
         if (start == null || end == null || power == null) {
             return BigDecimal.ZERO;
         }
-        if (actions instanceof EnergiDataServiceActions) {
-            return ((EnergiDataServiceActions) actions).calculatePrice(start, end, power);
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
+            return serviceActions.calculatePrice(start, end, power);
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
         }
@@ -314,11 +314,11 @@ public class EnergiDataServiceActions implements ThingActions {
 
     public static Map<String, Object> calculateCheapestPeriod(@Nullable ThingActions actions,
             @Nullable Instant earliestStart, @Nullable Instant latestEnd, @Nullable Duration duration) {
-        if (actions instanceof EnergiDataServiceActions) {
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
             if (earliestStart == null || latestEnd == null || duration == null) {
                 return Map.of();
             }
-            return ((EnergiDataServiceActions) actions).calculateCheapestPeriod(earliestStart, latestEnd, duration);
+            return serviceActions.calculateCheapestPeriod(earliestStart, latestEnd, duration);
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
         }
@@ -327,12 +327,11 @@ public class EnergiDataServiceActions implements ThingActions {
     public static Map<String, Object> calculateCheapestPeriod(@Nullable ThingActions actions,
             @Nullable Instant earliestStart, @Nullable Instant latestEnd, @Nullable Duration duration,
             @Nullable QuantityType<Power> power) {
-        if (actions instanceof EnergiDataServiceActions) {
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
             if (earliestStart == null || latestEnd == null || duration == null || power == null) {
                 return Map.of();
             }
-            return ((EnergiDataServiceActions) actions).calculateCheapestPeriod(earliestStart, latestEnd, duration,
-                    power);
+            return serviceActions.calculateCheapestPeriod(earliestStart, latestEnd, duration, power);
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
         }
@@ -341,13 +340,13 @@ public class EnergiDataServiceActions implements ThingActions {
     public static Map<String, Object> calculateCheapestPeriod(@Nullable ThingActions actions,
             @Nullable Instant earliestStart, @Nullable Instant latestEnd, @Nullable Duration totalDuration,
             @Nullable List<Duration> durationPhases, @Nullable QuantityType<Energy> energyUsedPerPhase) {
-        if (actions instanceof EnergiDataServiceActions) {
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
             if (earliestStart == null || latestEnd == null || totalDuration == null || durationPhases == null
                     || energyUsedPerPhase == null) {
                 return Map.of();
             }
-            return ((EnergiDataServiceActions) actions).calculateCheapestPeriod(earliestStart, latestEnd, totalDuration,
-                    durationPhases, energyUsedPerPhase);
+            return serviceActions.calculateCheapestPeriod(earliestStart, latestEnd, totalDuration, durationPhases,
+                    energyUsedPerPhase);
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
         }
@@ -356,12 +355,11 @@ public class EnergiDataServiceActions implements ThingActions {
     public static Map<String, Object> calculateCheapestPeriod(@Nullable ThingActions actions,
             @Nullable Instant earliestStart, @Nullable Instant latestEnd, @Nullable List<Duration> durationPhases,
             @Nullable List<QuantityType<Power>> powerPhases) {
-        if (actions instanceof EnergiDataServiceActions) {
+        if (actions instanceof EnergiDataServiceActions serviceActions) {
             if (earliestStart == null || latestEnd == null || durationPhases == null || powerPhases == null) {
                 return Map.of();
             }
-            return ((EnergiDataServiceActions) actions).calculateCheapestPeriod(earliestStart, latestEnd,
-                    durationPhases, powerPhases);
+            return serviceActions.calculateCheapestPeriod(earliestStart, latestEnd, durationPhases, powerPhases);
         } else {
             throw new IllegalArgumentException("Instance is not an EnergiDataServiceActions class.");
         }
@@ -369,8 +367,8 @@ public class EnergiDataServiceActions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof EnergiDataServiceHandler) {
-            this.handler = (EnergiDataServiceHandler) handler;
+        if (handler instanceof EnergiDataServiceHandler serviceHandler) {
+            this.handler = serviceHandler;
         }
     }
 
index 98d78a0485a5f5148b01dd0ea397bc2c619c792e..999b5dbdc3f73a59774fe5d70b5c6c3483ef5980 100644 (file)
@@ -80,7 +80,6 @@ public class FixedTime implements RetryStrategy {
 
     @Override
     public final int hashCode() {
-        final int result = 1;
-        return result;
+        return 1;
     }
 }
index bab5f0aa69a7b18c63e974a297001700846ee943..29b4afa1d006037d5a5f56b3474aa71fc7617362 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.enigma2.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public class Enigma2BindingConstants {
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_DEVICE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_DEVICE);
 
     // List of all Channel ids
     public static final String CHANNEL_VOLUME = "volume";
index 002897341af24857fff6fea4dc8fbf14f0f10035..d5735fb0544373376188e7e70d5464a6be61ff0f 100644 (file)
@@ -16,8 +16,8 @@ import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.*;
 
 import java.time.LocalDateTime;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -155,10 +155,10 @@ public class Enigma2Handler extends BaseThingHandler {
         if (command instanceof RefreshType) {
             client.refreshVolume();
             updateState(channelUID, new PercentType(client.getVolume()));
-        } else if (command instanceof PercentType) {
-            client.setVolume(((PercentType) command).intValue());
-        } else if (command instanceof DecimalType) {
-            client.setVolume(((DecimalType) command).intValue());
+        } else if (command instanceof PercentType percentCommand) {
+            client.setVolume(percentCommand.intValue());
+        } else if (command instanceof DecimalType decimalCommand) {
+            client.setVolume(decimalCommand.intValue());
         } else {
             logger.info("Channel {} only accepts PercentType, DecimalType, RefreshType. Type was {}.", channelUID,
                     command.getClass());
@@ -293,7 +293,7 @@ public class Enigma2Handler extends BaseThingHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(Enigma2Actions.class);
+        return Set.of(Enigma2Actions.class);
     }
 
     /**
index 4cf3f5525ef5b69004de21e93dfe9541a72c969b..29cb958daff354785b96ddc4a764ebb2ae98b0bf 100644 (file)
@@ -312,13 +312,29 @@ public class Enigma2ClientTest {
     }
 
     private void whenAllServices() throws IOException {
-        when(enigma2HttpClient.get(HOST + Enigma2Client.PATH_ALL_SERVICES))
-                .thenReturn("<e2servicelistrecursive>" + "<e2bouquet>" + "<e2servicelist>" + "<e2service>"
-                        + "<e2servicereference>1</e2servicereference>" + "<e2servicename>Channel 1</e2servicename>"
-                        + "</e2service>" + "<e2service>" + "<e2servicereference>2</e2servicereference>"
-                        + "<e2servicename>Channel 2</e2servicename>" + "</e2service>" + "</e2servicelist>"
-                        + "</e2bouquet>" + "<e2bouquet>" + "<e2servicelist>" + "<e2service>"
-                        + "<e2servicereference>3</e2servicereference>" + "<e2servicename>Channel 3</e2servicename>"
-                        + "</e2service>" + "</e2servicelist>" + "</e2bouquet>" + "</e2servicelistrecursive>");
+        when(enigma2HttpClient.get(HOST + Enigma2Client.PATH_ALL_SERVICES)).thenReturn("""
+                <e2servicelistrecursive>\
+                <e2bouquet>\
+                <e2servicelist>\
+                <e2service>\
+                <e2servicereference>1</e2servicereference>\
+                <e2servicename>Channel 1</e2servicename>\
+                </e2service>\
+                <e2service>\
+                <e2servicereference>2</e2servicereference>\
+                <e2servicename>Channel 2</e2servicename>\
+                </e2service>\
+                </e2servicelist>\
+                </e2bouquet>\
+                <e2bouquet>\
+                <e2servicelist>\
+                <e2service>\
+                <e2servicereference>3</e2servicereference>\
+                <e2servicename>Channel 3</e2servicename>\
+                </e2service>\
+                </e2servicelist>\
+                </e2bouquet>\
+                </e2servicelistrecursive>\
+                """);
     }
 }
index 6d0af65ece358565a4b02b5e80c861a9a014412b..99fac21ca4e49f7d2fb3bed49f3466bac282cbfa 100644 (file)
@@ -132,7 +132,7 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
                         if (senderIdOffset == null) {
                             return;
                         }
-                    } else if ((eep instanceof _4BSMessage) && ((_4BSMessage) eep).isTeachInVariation3Supported()) {
+                    } else if (eep instanceof _4BSMessage message && message.isTeachInVariation3Supported()) {
                         // if 4BS teach in variation 3 => send response
                         logger.debug("Sending 4BS teach in variation 3 response to {}", enoceanId);
                         senderIdOffset = sendTeachInResponse(msg, enoceanId);
index 5924c7845a2afeb63f154be3b193e4a3f4d62201..9aa7bf154c2aff4418fa2bee81ac01506f99fc21 100644 (file)
@@ -60,7 +60,7 @@ public class A5_20_04 extends A5_20 {
     }
 
     private String getStatusRequestEvent() {
-        return Boolean.valueOf(getBit(getDB0Value(), 6)).toString();
+        return Boolean.toString(getBit(getDB0Value(), 6));
         // return getBit(getDB_0Value(), 6) ? "triggered" : null;
     }
 
index a48bb39afbbcd8186751a6de9660ef0353d1fcfb..be36533b80ee85e370b0e0f411a86c141cc9136c 100644 (file)
@@ -77,15 +77,15 @@ public class A5_38_08_Blinds extends _4BSMessage {
                 byte angle = 0; // for now, no angle configuration supported
                 boolean doStop = false;
 
-                if (outputCommand instanceof DecimalType) {
-                    position = ((DecimalType) outputCommand).byteValue();
-                } else if (outputCommand instanceof OnOffType) {
-                    position = (byte) (((OnOffType) outputCommand == OnOffType.ON) ? 0 : 100);
+                if (outputCommand instanceof DecimalType decimalCommand) {
+                    position = decimalCommand.byteValue();
+                } else if (outputCommand instanceof OnOffType onOffCommand) {
+                    position = (byte) ((onOffCommand == OnOffType.ON) ? 0 : 100);
                 } else if (outputCommand instanceof StopMoveType) {
                     position = ZERO;
                     doStop = true;
-                } else if (outputCommand instanceof UpDownType) {
-                    position = (byte) (((UpDownType) outputCommand == UpDownType.UP) ? 0 : 100);
+                } else if (outputCommand instanceof UpDownType upDownCommand) {
+                    position = (byte) ((upDownCommand == UpDownType.UP) ? 0 : 100);
                 } else {
                     logger.warn("Unknown command type {}", outputCommand.getClass().getCanonicalName());
                     return;
index 148b5fc70389b65396a235a89f805e874d6c69d2..2d5771c21af587836588c6e045ca89a7e7e6e7c5 100644 (file)
@@ -63,16 +63,14 @@ public class A5_38_08_Dimming extends _4BSMessage {
             case CHANNEL_DIMMER:
                 byte dimmValue;
 
-                if (outputCommand instanceof DecimalType) {
-                    dimmValue = ((DecimalType) outputCommand).byteValue();
-                } else if (outputCommand instanceof OnOffType) {
-                    dimmValue = ((OnOffType) outputCommand == OnOffType.ON) ? SWITCH_100_PERCENT : ZERO;
-                } else if (outputCommand instanceof IncreaseDecreaseType) {
-                    dimmValue = ((IncreaseDecreaseType) outputCommand == IncreaseDecreaseType.INCREASE)
-                            ? SWITCH_100_PERCENT
-                            : ZERO;
-                } else if (outputCommand instanceof UpDownType) {
-                    dimmValue = ((UpDownType) outputCommand == UpDownType.UP) ? SWITCH_100_PERCENT : ZERO;
+                if (outputCommand instanceof DecimalType decimalCommand) {
+                    dimmValue = decimalCommand.byteValue();
+                } else if (outputCommand instanceof OnOffType onOffCommand) {
+                    dimmValue = (onOffCommand == OnOffType.ON) ? SWITCH_100_PERCENT : ZERO;
+                } else if (outputCommand instanceof IncreaseDecreaseType increaseDecreaseCommand) {
+                    dimmValue = (increaseDecreaseCommand == IncreaseDecreaseType.INCREASE) ? SWITCH_100_PERCENT : ZERO;
+                } else if (outputCommand instanceof UpDownType upDownCommand) {
+                    dimmValue = (upDownCommand == UpDownType.UP) ? SWITCH_100_PERCENT : ZERO;
                 } else {
                     throw new IllegalArgumentException(outputCommand.toFullString() + " is no valid dimming command.");
                 }
index b10ba909675449022a8d691f418ccb61bb060f25..a4b9edb6695b230e1c38b2b6915353dfaf6510ea 100644 (file)
@@ -52,20 +52,19 @@ public class A5_3F_7F_EltakoFRM extends _4BSMessage {
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
             Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
-        if (command instanceof PercentType) {
-            PercentType target = (PercentType) command;
-            int rawPosition = Math.round(
-                    (PercentType.HUNDRED.floatValue() - target.floatValue()) * TOP / PercentType.HUNDRED.floatValue());
+        if (command instanceof PercentType percentCommand) {
+            int rawPosition = Math.round((PercentType.HUNDRED.floatValue() - percentCommand.floatValue()) * TOP
+                    / PercentType.HUNDRED.floatValue());
             int position = Math.min(TOP, Math.max(BOTTOM, rawPosition));
             setData((byte) position, ZERO, MOVE, TEACHIN_BIT);
-        } else if (command instanceof UpDownType) {
-            if ((UpDownType) command == UpDownType.UP) {
+        } else if (command instanceof UpDownType upDownCommand) {
+            if (upDownCommand == UpDownType.UP) {
                 setData((byte) TOP, ZERO, MOVE, TEACHIN_BIT); // => 0 percent
-            } else if ((UpDownType) command == UpDownType.DOWN) {
+            } else if (upDownCommand == UpDownType.DOWN) {
                 setData((byte) BOTTOM, ZERO, MOVE, TEACHIN_BIT); // => 100 percent
             }
-        } else if (command instanceof StopMoveType) {
-            if ((StopMoveType) command == StopMoveType.STOP) {
+        } else if (command instanceof StopMoveType stopMoveCommand) {
+            if (stopMoveCommand == StopMoveType.STOP) {
                 setData(ZERO, ZERO, STOP, TEACHIN_BIT);
             }
         }
index 3d6e55d0c7378a24b675f81d3183ea95087829fe..67f016f171cd9e2d086bcc5df7c06ea0bc1deeff 100644 (file)
@@ -61,21 +61,19 @@ public class A5_3F_7F_EltakoFSB extends _4BSMessage {
             shutTime = Math.min(255, config.as(EnOceanChannelRollershutterConfig.class).shutTime);
         }
 
-        if (command instanceof PercentType) {
+        if (command instanceof PercentType percentCommand) {
             State channelState = getCurrentStateFunc.apply(channelId);
-
-            PercentType target = (PercentType) command;
-            if (target.intValue() == PercentType.ZERO.intValue()) {
+            if (percentCommand.intValue() == PercentType.ZERO.intValue()) {
                 setData(ZERO, (byte) shutTime, MOVE_UP, TEACHIN_BIT); // => move completely up
-            } else if (target.intValue() == PercentType.HUNDRED.intValue()) {
+            } else if (percentCommand.intValue() == PercentType.HUNDRED.intValue()) {
                 setData(ZERO, (byte) shutTime, MOVE_DOWN, TEACHIN_BIT); // => move completely down
             } else if (channelState != null) {
                 PercentType current = channelState.as(PercentType.class);
                 if (current != null) {
-                    if (current.intValue() != target.intValue()) {
-                        byte direction = current.intValue() > target.intValue() ? MOVE_UP : MOVE_DOWN;
+                    if (current.intValue() != percentCommand.intValue()) {
+                        byte direction = current.intValue() > percentCommand.intValue() ? MOVE_UP : MOVE_DOWN;
                         byte duration = (byte) Math.min(255,
-                                (Math.abs(current.intValue() - target.intValue()) * shutTime)
+                                (Math.abs(current.intValue() - percentCommand.intValue()) * shutTime)
                                         / PercentType.HUNDRED.intValue());
 
                         setData(ZERO, duration, direction, TEACHIN_BIT);
@@ -83,14 +81,14 @@ public class A5_3F_7F_EltakoFSB extends _4BSMessage {
                 }
             }
 
-        } else if (command instanceof UpDownType) {
-            if ((UpDownType) command == UpDownType.UP) {
+        } else if (command instanceof UpDownType upDownCommand) {
+            if (upDownCommand == UpDownType.UP) {
                 setData(ZERO, (byte) shutTime, MOVE_UP, TEACHIN_BIT); // => 0 percent
-            } else if ((UpDownType) command == UpDownType.DOWN) {
+            } else if (upDownCommand == UpDownType.DOWN) {
                 setData(ZERO, (byte) shutTime, MOVE_DOWN, TEACHIN_BIT); // => 100 percent
             }
-        } else if (command instanceof StopMoveType) {
-            if ((StopMoveType) command == StopMoveType.STOP) {
+        } else if (command instanceof StopMoveType stopMoveCommand) {
+            if (stopMoveCommand == StopMoveType.STOP) {
                 setData(ZERO, (byte) 0xFF, STOP, TEACHIN_BIT);
             }
         }
index 074ba0af22bbb199d7106d62d0fa903f87dc4023..3775eff16d60ed6cd00f7f905e36c9029517b121 100644 (file)
@@ -107,11 +107,11 @@ public abstract class D2_01 extends _VLDMessage {
     protected void setDimmingData(Command command, byte outputChannel, Configuration config) {
         byte outputValue;
 
-        if (command instanceof DecimalType) {
-            if (((DecimalType) command).equals(DecimalType.ZERO)) {
+        if (command instanceof DecimalType decimalCommand) {
+            if (decimalCommand.equals(DecimalType.ZERO)) {
                 outputValue = STATUS_SWITCHING_OFF;
             } else {
-                outputValue = ((DecimalType) command).byteValue();
+                outputValue = decimalCommand.byteValue();
             }
         } else if ((OnOffType) command == OnOffType.ON) {
             outputValue = STATUS_DIMMING_100;
index 75bbde8fd48c733c439b19a8aa5c597585370734..9307d9d87e8fc0ca64c178c949bb9f89c2af6505 100644 (file)
@@ -58,8 +58,8 @@ public class D2_01_09_Permundo extends D2_01 {
     private void setRepeaterMode(Command command) {
         if (command == RefreshType.REFRESH) {
             senderId = new byte[0]; // make this message invalid as we do not support refresh of repeater status
-        } else if (command instanceof StringType) {
-            switch (((StringType) command).toString()) {
+        } else if (command instanceof StringType stringCommand) {
+            switch (stringCommand.toString()) {
                 case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
                     setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x01);
                     break;
@@ -75,8 +75,8 @@ public class D2_01_09_Permundo extends D2_01 {
     private void setEcoMode(Command command) {
         if (command == RefreshType.REFRESH) {
             senderId = new byte[0]; // make this message invalid as we do not support refresh of ecomode status
-        } else if (command instanceof OnOffType) {
-            if (((OnOffType) command) == OnOffType.ON) {
+        } else if (command instanceof OnOffType onOffCommand) {
+            if (onOffCommand == OnOffType.ON) {
                 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x01);
             } else {
                 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x00);
index dcea0e6f25ee27f71456c76e438ef42df58c9532..68522bdcb578837ffd050f5b127ff02b83ee818c 100644 (file)
@@ -48,8 +48,8 @@ public class D2_01_0F_NodON extends D2_01 {
         if (channelId.equalsIgnoreCase(CHANNEL_REPEATERMODE)) {
             if (command instanceof RefreshType) {
                 senderId = new byte[0]; // make this message invalid as we do not support refresh of repeter status
-            } else if (command instanceof StringType) {
-                switch (((StringType) command).toString()) {
+            } else if (command instanceof StringType stringCommand) {
+                switch (stringCommand.toString()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x01, (byte) 0x01);
                         break;
index 28af568f22d8a569f1e631854685bc3d01626ede..61df5f8ba85f450110029b46ae0de73fbd64a2f1 100644 (file)
@@ -48,8 +48,8 @@ public class D2_01_12_NodON extends D2_01 {
         if (channelId.equalsIgnoreCase(CHANNEL_REPEATERMODE)) {
             if (command instanceof RefreshType) {
                 senderId = new byte[0]; // make this message invalid as we do not support refresh of repeter status
-            } else if (command instanceof StringType) {
-                switch (((StringType) command).toString()) {
+            } else if (command instanceof StringType stringCommand) {
+                switch (stringCommand.toString()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x01, (byte) 0x01);
                         break;
index eeab198a8fb04bc3eda8a5aef5fb7dcb832f3d7f..107a7b79351766f72d07a36edc52d2f85a0442a9 100644 (file)
@@ -75,8 +75,8 @@ public class D2_05_00 extends _VLDMessage {
             if (command == StopMoveType.STOP) {
                 setData((byte) (outputChannel + CMD_ACTUATOR_STOP));
             }
-        } else if (command instanceof PercentType) {
-            setData((byte) (((PercentType) command).intValue()), (byte) 0x00, (byte) 0x00,
+        } else if (command instanceof PercentType percentCommand) {
+            setData((byte) (percentCommand.intValue()), (byte) 0x00, (byte) 0x00,
                     (byte) (outputChannel + CMD_ACTUATOR_SET_POSITION));
         }
     }
index a74dcba4eebf51c83d109e8b1a4b505d6c3d4b0f..6e5c048da40e13bf7234feb410ad233ea373a55e 100644 (file)
@@ -49,8 +49,8 @@ public class D2_05_00_NodON extends D2_05_00 {
         if (channelId.equals(CHANNEL_REPEATERMODE)) {
             if (command == RefreshType.REFRESH) {
                 senderId = new byte[0]; // make this message invalid as we do not support refresh of repeter status
-            } else if (command instanceof StringType) {
-                switch (((StringType) command).toString()) {
+            } else if (command instanceof StringType stringCommand) {
+                switch (stringCommand.toString()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x01, (byte) 0x01);
                         break;
index eb211b2f4ebabe1e6bc1032794e93ba77da075ab..b94cece7fa8383c4f15e8a988d4f74176c3cb312 100644 (file)
@@ -86,15 +86,15 @@ public class D2_50 extends _VLDMessage {
         } else {
             switch (channelId) {
                 case CHANNEL_VENTILATIONOPERATIONMODE:
-                    if (command instanceof StringType) {
-                        byte value = (byte) (Helper.tryParseInt(((StringType) command).toString(), 15) & 0x0f);
+                    if (command instanceof StringType stringCommand) {
+                        byte value = (byte) (Helper.tryParseInt(stringCommand.toString(), 15) & 0x0f);
                         setData((byte) (MT_CONTROL + value), CONTROL_NOACTION, TMOC_NOACTION, THRESHOLD_NOACTION,
                                 THRESHOLD_NOACTION, CONTROL_NOACTION);
                     }
                     break;
                 case CHANNEL_TIMEROPERATIONMODE:
-                    if (command instanceof OnOffType) {
-                        byte value = (OnOffType) command == OnOffType.ON ? TMOC_ACTIVATE : TMOC_NOACTION;
+                    if (command instanceof OnOffType onOffCommand) {
+                        byte value = onOffCommand == OnOffType.ON ? TMOC_ACTIVATE : TMOC_NOACTION;
                         setData((byte) (MT_CONTROL + DOMC_NOACTION), CONTROL_NOACTION, value, THRESHOLD_NOACTION,
                                 THRESHOLD_NOACTION, CONTROL_NOACTION);
                     }
index 59d9b95407d4433bc2b922737ad075a7dad2067d..ba23b7b99e3ba3d66d780744550653154d0997af 100644 (file)
@@ -95,7 +95,7 @@ public class EEPFactory {
     }
 
     public static @Nullable EEP buildEEPFromTeachInERP1(ERP1Message msg) {
-        if (!msg.getIsTeachIn() && !(msg.getRORG() == RORG.RPS)) {
+        if (!msg.getIsTeachIn() && msg.getRORG() != RORG.RPS) {
             return null;
         }
 
index 80e7db34960488a56beac1650ce5cd2fa301668a..7e604fde7883c3a23bedccccb421bafa197a3f2d 100644 (file)
@@ -74,8 +74,8 @@ public class F6_02_01 extends F6_02 {
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
             Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
-        if (command instanceof StringType) {
-            String s = ((StringType) command).toString();
+        if (command instanceof StringType stringCommand) {
+            String s = stringCommand.toString();
 
             if (s.equals(CommonTriggerEvents.DIR1_RELEASED) || s.equals(CommonTriggerEvents.DIR2_RELEASED)) {
                 setStatus(_RPSMessage.T21_FLAG);
index ed63201e81c2da842e753c947ed225102ff76dcb..d941275390bf53795b0d544fe408269d91595ae7 100644 (file)
@@ -73,8 +73,8 @@ public class F6_02_02 extends F6_02 {
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
             Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
-        if (command instanceof StringType) {
-            String s = ((StringType) command).toString();
+        if (command instanceof StringType stringCommand) {
+            String s = stringCommand.toString();
 
             if (s.equals(CommonTriggerEvents.DIR1_RELEASED) || s.equals(CommonTriggerEvents.DIR2_RELEASED)) {
                 setStatus(_RPSMessage.T21_FLAG);
index c598caa30776e538b6f02e54695d189dfc416777..974aa056e923b0c4bf350a9edc516fdb68c8f61a 100644 (file)
@@ -209,8 +209,8 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
                 return null;
             }
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof EnOceanBridgeHandler) {
-                this.gateway = (EnOceanBridgeHandler) handler;
+            if (handler instanceof EnOceanBridgeHandler bridgeHandler) {
+                this.gateway = bridgeHandler;
             } else {
                 return null;
             }
index 303936c1685ef161c23ecf3e7f5b9f20f4a277af..f75a774a4c7463d1831205d351f6f8ff361981cf 100644 (file)
@@ -116,13 +116,13 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
                                     }
                                 }
                             });
-                } else if (command instanceof StringType) {
-                    sendMessage(ESP3PacketFactory.CO_WR_REPEATER((StringType) command),
+                } else if (command instanceof StringType stringCommand) {
+                    sendMessage(ESP3PacketFactory.CO_WR_REPEATER(stringCommand),
                             new ResponseListenerIgnoringTimeouts<BaseResponse>() {
                                 @Override
                                 public void responseReceived(BaseResponse response) {
                                     if (response.isOK()) {
-                                        updateState(channelUID, (StringType) command);
+                                        updateState(channelUID, stringCommand);
                                     }
                                 }
                             });
@@ -130,9 +130,9 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
                 break;
 
             case CHANNEL_SETBASEID:
-                if (command instanceof StringType) {
+                if (command instanceof StringType stringCommand) {
                     try {
-                        byte[] id = HexUtils.hexToBytes(((StringType) command).toFullString());
+                        byte[] id = HexUtils.hexToBytes(stringCommand.toFullString());
 
                         sendMessage(ESP3PacketFactory.CO_WR_IDBASE(id),
                                 new ResponseListenerIgnoringTimeouts<BaseResponse>() {
index ae1ca731484f9d64c70dd4c88a2dc72020919585..6575684587fce692e2d23c68074c9c85ba2c1969 100644 (file)
@@ -180,8 +180,8 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
     }
 
     private @Nullable StringType convertToPressedCommand(Command command, SwitchMode switchMode) {
-        if (command instanceof StringType) {
-            return (StringType) command;
+        if (command instanceof StringType stringCommand) {
+            return stringCommand;
         } else if (command instanceof OnOffType) {
             switch (switchMode) {
                 case RockerSwitch:
index 3f0e277b415b6b9ba4b480747d905ba1f5ec6946..7c860bc81505f8eb89d80a468f66732ba5d3da28 100644 (file)
@@ -210,7 +210,7 @@ public class ESP2Packet {
         return ZERO;
     }
 
-    private byte calcCheckSum(byte data[], int offset, int length) {
+    private byte calcCheckSum(byte[] data, int offset, int length) {
         int checkSum = 0;
         for (int i = 0; i < length; i++) {
             checkSum += (data[offset + i] & 0xff);
@@ -251,7 +251,7 @@ public class ESP2Packet {
         }
     }
 
-    public static boolean validateCheckSum(byte data[], int length, byte checkSum) {
+    public static boolean validateCheckSum(byte[] data, int length, byte checkSum) {
         int sum = 0;
         for (int i = 0; i < length; i++) {
             sum += (data[i] & 0xff);
index b27a01f410919ecff225851f8e188acdd63035f7..011b33a9b96f0872b267ce6ae4012072a8db8d5b 100644 (file)
@@ -73,7 +73,7 @@ public class ESP3Packet {
         this.basePacket = basePacket;
     }
 
-    private byte calcCRC8(byte data[], int offset, int length) {
+    private byte calcCRC8(byte[] data, int offset, int length) {
         byte output = 0;
         for (int i = offset; i < offset + length; i++) {
             int index = (output ^ data[i]) & 0xff;
@@ -112,7 +112,7 @@ public class ESP3Packet {
         }
     }
 
-    public static boolean checkCRC8(byte data[], int length, byte crc8) {
+    public static boolean checkCRC8(byte[] data, int length, byte crc8) {
         byte output = 0;
         for (int i = 0; i < length; i++) {
             int index = (output ^ data[i]) & 0xff;
index 46a82fdac9400059d5265dfb6333c9dc6b627aae..bf664b17f95daf8df38daf7ca3249a874c37c174 100644 (file)
@@ -14,10 +14,10 @@ package org.openhab.binding.enphase.internal.discovery;
 
 import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 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;
@@ -52,13 +52,13 @@ public class EnphaseDevicesDiscoveryService extends AbstractDiscoveryService
     private @Nullable EnvoyBridgeHandler envoyHandler;
 
     public EnphaseDevicesDiscoveryService() {
-        super(Collections.singleton(THING_TYPE_ENPHASE_INVERTER), TIMEOUT_SECONDS, false);
+        super(Set.of(THING_TYPE_ENPHASE_INVERTER), TIMEOUT_SECONDS, false);
     }
 
     @Override
     public void setThingHandler(final @Nullable ThingHandler handler) {
-        if (handler instanceof EnvoyBridgeHandler) {
-            envoyHandler = (EnvoyBridgeHandler) handler;
+        if (handler instanceof EnvoyBridgeHandler bridgeHandler) {
+            envoyHandler = bridgeHandler;
         }
     }
 
index 9e99b2c6d05a57f61a60393a030f6d0396810df6..02fe022f20b2e9508f9941af041bfbdc9d3d1ba1 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.enphase.internal.discovery;
 import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.*;
 
 import java.net.Inet4Address;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -56,7 +55,7 @@ public class EnvoyDiscoveryParticipant implements MDNSDiscoveryParticipant, Envo
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(EnphaseBindingConstants.THING_TYPE_ENPHASE_ENVOY);
+        return Set.of(EnphaseBindingConstants.THING_TYPE_ENPHASE_ENVOY);
     }
 
     @Override
index be703b52673b8f73fcd992cd8479839bed80488f..4ebb1f6eca3243ed800aba84075248ffa7bea3a2 100644 (file)
@@ -22,8 +22,8 @@ import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY
 import java.time.Duration;
 import java.time.temporal.ChronoUnit;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
@@ -132,7 +132,7 @@ public class EnvoyBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(EnphaseDevicesDiscoveryService.class);
+        return Set.of(EnphaseDevicesDiscoveryService.class);
     }
 
     @Override
@@ -347,15 +347,14 @@ public class EnvoyBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(final ThingHandler childHandler, final Thing childThing) {
-        if (childHandler instanceof EnphaseInverterHandler) {
-            updateInverter(getInvertersData(false), (EnphaseInverterHandler) childHandler);
+        if (childHandler instanceof EnphaseInverterHandler handler) {
+            updateInverter(getInvertersData(false), handler);
         }
-        if (childHandler instanceof EnphaseDeviceHandler) {
+        if (childHandler instanceof EnphaseDeviceHandler handler) {
             final Map<String, @Nullable DeviceDTO> devices = getDevices(false);
 
             if (devices != null) {
-                ((EnphaseDeviceHandler) childHandler)
-                        .refreshDeviceState(devices.get(((EnphaseDeviceHandler) childHandler).getSerialNumber()));
+                handler.refreshDeviceState(devices.get(handler.getSerialNumber()));
             }
         }
     }
index cb5c3ed9324e826819c519319eec4399ec6f26fe..19575e2a93cca017e52b83a7b2f8c6e38854c7af 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.enturno.internal;
 
 import static org.openhab.binding.enturno.internal.EnturNoBindingConstants.LINESTOP;
 
-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.enturno", service = ThingHandlerFactory.class)
 public class EnturNoHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(LINESTOP);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(LINESTOP);
 
     private final HttpClient httpClient;
 
index a39eb8d1326405b48253a4704e8204c0164517d0..4ec1f40776a5251e32d2b3503ba6ca6d3ef916ba 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.etherrain.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -36,7 +35,7 @@ public class EtherRainBindingConstants {
     // List of all Thing Type UIDs
 
     public static final ThingTypeUID ETHERRAIN_THING = new ThingTypeUID(BINDING_ID, ETHERRAIN);
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(ETHERRAIN_THING);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(ETHERRAIN_THING);
 
     // List of internal default values
 
index 44a6855ac0dffe4148cd438882ef2ba1fc4c5f4c..b1d89950c3092261fd5fd460bc4e07ed71521d9b 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.etherrain.internal.config;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -31,7 +30,7 @@ public class EtherRainConfiguration {
 
     public static final ThingTypeUID ETHERRAIN_THING_TYPE = new ThingTypeUID(BINDING_ID, "etherrain");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(ETHERRAIN_THING_TYPE);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(ETHERRAIN_THING_TYPE);
 
     /**
      * Hostname of the EtherRain API.
index d59e3c3e2f4505c03d0856effaac89a4a5d9aee3..cb26e80d73c54536f84dc685c4e205dec2fe360f 100644 (file)
@@ -475,7 +475,7 @@ public class EvccHandler extends BaseThingHandler {
         updateState(channel, new QuantityType<>(targetSoC, Units.PERCENT));
 
         String targetTime = loadpoint.getTargetTime();
-        if (targetTime == null || targetTime.equals("0001-01-01T00:00:00Z")) {
+        if (targetTime == null || "0001-01-01T00:00:00Z".equals(targetTime)) {
             channel = new ChannelUID(uid, loadpointName, CHANNEL_LOADPOINT_TARGET_TIME_ENABLED);
             updateState(channel, OnOffType.OFF);
             targetTimeEnabled = false;
index e472ce968065c56cf0b0740b067d9d216b2cc21c..db292b03409b8a811567f2e48db43719ce72a6db 100644 (file)
@@ -296,13 +296,11 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler {
         for (Thing handler : getThing().getThings()) {
             ThingHandler thingHandler = handler.getHandler();
 
-            if (thingHandler instanceof EvohomeTemperatureControlSystemHandler) {
-                EvohomeTemperatureControlSystemHandler tcsHandler = (EvohomeTemperatureControlSystemHandler) thingHandler;
+            if (thingHandler instanceof EvohomeTemperatureControlSystemHandler tcsHandler) {
                 tcsHandler.update(tcsIdToGatewayMap.get(tcsHandler.getId()), idToTcsMap.get(tcsHandler.getId()));
                 idToTcsThingsStatusMap.put(tcsHandler.getId(), tcsHandler.getThing().getStatus());
             }
-            if (thingHandler instanceof EvohomeHeatingZoneHandler) {
-                EvohomeHeatingZoneHandler zoneHandler = (EvohomeHeatingZoneHandler) thingHandler;
+            if (thingHandler instanceof EvohomeHeatingZoneHandler zoneHandler) {
                 zoneHandler.update(idToTcsThingsStatusMap.get(zoneIdToTcsIdMap.get(zoneHandler.getId())),
                         idToZoneMap.get(zoneHandler.getId()));
             }
index 8dc6cbb3915ce3ce8f4b2f4a64c5c3bf0f2fe738..d15e067c0ed76eb44a9436395f608062a045ddc2 100644 (file)
@@ -86,8 +86,8 @@ public class EvohomeHeatingZoneHandler extends BaseEvohomeHandler {
             if (bridge != null) {
                 String channelId = channelUID.getId();
                 if (EvohomeBindingConstants.ZONE_SET_POINT_CHANNEL.equals(channelId)) {
-                    if (command instanceof QuantityType) {
-                        QuantityType<?> state = ((QuantityType<?>) command).toUnit(SIUnits.CELSIUS);
+                    if (command instanceof QuantityType quantityCommand) {
+                        QuantityType<?> state = quantityCommand.toUnit(SIUnits.CELSIUS);
                         double newTempInCelsius = state.doubleValue();
 
                         if (newTempInCelsius == CANCEL_SET_POINT_OVERRIDE) {
index 314725f223c3820fc8396a1df33d256963cafc84..47705820d542d1305188293ab446f25cc4c3c5ec 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.exec.internal;
 
 import static org.openhab.binding.exec.internal.ExecBindingConstants.THING_COMMAND;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -40,7 +39,7 @@ import org.slf4j.LoggerFactory;
 @NonNullByDefault
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.exec")
 public class ExecHandlerFactory extends BaseThingHandlerFactory {
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_COMMAND);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_COMMAND);
     private final Logger logger = LoggerFactory.getLogger(ExecHandlerFactory.class);
     private final ExecWhitelistWatchService execWhitelistWatchService;
 
index b86323f36ca3f3f8189f800626276a5ca935fe1b..9d93d2f9c625ea5b55eb95081fa9822c6c7e9bbb 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.feican.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -32,7 +31,7 @@ public final class FeicanBindingConstants {
     // List of all Thing Type UIDs
     public static final ThingTypeUID THING_TYPE_BULB = new ThingTypeUID(BINDING_ID, "bulb");
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_BULB);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_BULB);
 
     // List of all Channel ids
     public static final String CHANNEL_COLOR = "color";
index 4eb02edd3425838de2747f7600937f93b9a95a69..66a64a839299bd15bf0c4c8b5ecd8e98dd226bd9 100644 (file)
@@ -61,14 +61,14 @@ public class FeicanHandler extends BaseThingHandler {
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
         try {
-            if (command instanceof OnOffType) {
-                handleOnOff((OnOffType) command);
-            } else if (command instanceof HSBType) {
-                handleColor(channelUID, (HSBType) command);
-            } else if (command instanceof PercentType) {
-                handlePercentage(channelUID, (PercentType) command);
-            } else if (command instanceof StringType) {
-                handleString(channelUID, (StringType) command);
+            if (command instanceof OnOffType onOffCommand) {
+                handleOnOff(onOffCommand);
+            } else if (command instanceof HSBType hsbCommand) {
+                handleColor(channelUID, hsbCommand);
+            } else if (command instanceof PercentType percentCommand) {
+                handlePercentage(channelUID, percentCommand);
+            } else if (command instanceof StringType stringCommand) {
+                handleString(channelUID, stringCommand);
             }
         } catch (IOException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, e.getMessage());
index eec2be3fcc892b3f1f095bf0450c3ecea69f64d4..cde55cec069b4ae8821dc1c9224cb7b506277b23 100644 (file)
@@ -71,8 +71,8 @@ public class FineOffsetWeatherStationHandlerFactory extends BaseThingHandlerFact
     protected @Nullable ThingHandler createHandler(Thing thing) {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
-        if (THING_TYPE_GATEWAY.equals(thingTypeUID) && thing instanceof Bridge) {
-            return new FineOffsetGatewayHandler((Bridge) thing, gatewayDiscoveryService, channelTypeRegistry,
+        if (THING_TYPE_GATEWAY.equals(thingTypeUID) && thing instanceof Bridge bridge) {
+            return new FineOffsetGatewayHandler(bridge, gatewayDiscoveryService, channelTypeRegistry,
                     translationProvider, localeProvider, timeZoneProvider);
         }
         if (THING_TYPE_SENSOR.equals(thingTypeUID)) {
index 18e36712ee4280654ff24882cda469ecc8ea77aa..65a44dfebecc249a67a38f69acc7e3dc4a92957f 100644 (file)
@@ -24,9 +24,9 @@ import java.net.SocketException;
 import java.time.ZoneOffset;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -83,7 +83,7 @@ public class FineOffsetGatewayDiscoveryService extends AbstractDiscoveryService
     @Activate
     public FineOffsetGatewayDiscoveryService(@Reference TranslationProvider translationProvider,
             @Reference LocaleProvider localeProvider) throws IllegalArgumentException {
-        super(Collections.singleton(THING_TYPE_GATEWAY), DISCOVERY_TIME, true);
+        super(Set.of(THING_TYPE_GATEWAY), DISCOVERY_TIME, true);
         this.translationProvider = translationProvider;
         this.localeProvider = localeProvider;
         this.bundle = FrameworkUtil.getBundle(FineOffsetGatewayDiscoveryService.class);
index 786cc992ac965d4503c85c88f646bbaee355a30b..65d3f15f7ef8b3f15365a19261d9a5b3682ffeb1 100644 (file)
@@ -336,6 +336,7 @@ public enum Measurand {
             }
         }
 
+        @Override
         public int extractMeasuredValues(byte[] data, int offset, @Nullable Integer channel, ConversionContext context,
                 @Nullable ParserCustomizationType customizationType, List<MeasuredValue> result) {
             MeasureType measureType = getMeasureType(customizationType);
index 7cdcf011c9d5dc47688b10756e1c38a30306f2e4..f8ae06a1834dc781d4d2eafc28bb154f33e098a5 100644 (file)
@@ -26,7 +26,7 @@ abstract class CommandPacket {
         return res;
     }
 
-    abstract protected void write(OutputStream stream) throws IOException;
+    protected abstract void write(OutputStream stream) throws IOException;
 }
 
 class CmdGetInfo extends CommandPacket {
@@ -210,7 +210,7 @@ abstract class EventPacket {
         }
     }
 
-    abstract protected void parseInternal(InputStream stream) throws IOException;
+    protected abstract void parseInternal(InputStream stream) throws IOException;
 }
 
 class EvtAdvertisementPacket extends EventPacket {
@@ -366,7 +366,7 @@ class EvtGetButtonInfoResponse extends EventPacket {
             sb.append(String.format("%02x", uuidBytes[i]));
         }
         uuid = sb.toString();
-        if (uuid.equals("00000000000000000000000000000000")) {
+        if ("00000000000000000000000000000000".equals(uuid)) {
             uuid = null;
         }
         color = StreamUtils.getString(stream, 16);
index c1e06150f73fa57f5b6e87d383ce7f018356f101..f0f6f4d7b4025ae51d674e66eee17124715521ab 100644 (file)
@@ -36,8 +36,8 @@ public class FlicButtonBindingConstants {
     public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, "flicd-bridge");
     public static final ThingTypeUID FLICBUTTON_THING_TYPE = new ThingTypeUID(BINDING_ID, "button");
 
-    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(FLICBUTTON_THING_TYPE);
+    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(FLICBUTTON_THING_TYPE);
 
     // List of all configuration options
     public static final String CONFIG_HOST_NAME = "hostname";
index c42f2c4e14da595d6f9c47dd3997147a3c6836ce..277ea2908e21c608667d393d0044fd1b8d47a43f 100644 (file)
@@ -14,7 +14,7 @@
 package org.openhab.binding.flicbutton.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;
@@ -34,8 +34,7 @@ import org.openhab.core.thing.binding.BridgeHandler;
  */
 @NonNullByDefault
 public abstract class ChildThingHandler<BridgeHandlerType extends BridgeHandler> extends BaseThingHandler {
-    private static final Collection<ThingStatus> DEFAULT_TOLERATED_BRIDGE_STATUSES = Collections
-            .singleton(ThingStatus.ONLINE);
+    private static final Collection<ThingStatus> DEFAULT_TOLERATED_BRIDGE_STATUSES = Set.of(ThingStatus.ONLINE);
     protected boolean bridgeValid = false;
     protected @Nullable BridgeHandlerType bridgeHandler;
 
index 06965ff717074886bdf079eae60cea49aca4ba2c..7b4751832114a9db05ba8b7e3cdb433271cb0e84 100644 (file)
@@ -13,7 +13,6 @@
 package org.openhab.binding.fmiweather.internal.client;
 
 import java.util.AbstractMap;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -36,6 +35,6 @@ public class FMISID implements QueryParameter {
 
     @Override
     public List<Map.Entry<String, String>> toRequestParameters() {
-        return Collections.singletonList(new AbstractMap.SimpleImmutableEntry<>("fmisid", fmisid));
+        return List.of(new AbstractMap.SimpleImmutableEntry<>("fmisid", fmisid));
     }
 }
index d6e4836daa43ba643aab254834aea43193798db4..a00ae2ab30fdb04d83a7265a72f8e14caa914d3d 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.fmiweather.internal.client;
 
 import java.math.BigDecimal;
 import java.util.AbstractMap;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -37,6 +36,6 @@ public class LatLon implements QueryParameter {
 
     @Override
     public List<Map.Entry<String, String>> toRequestParameters() {
-        return Collections.singletonList(new AbstractMap.SimpleImmutableEntry<>("latlon", latlon));
+        return List.of(new AbstractMap.SimpleImmutableEntry<>("latlon", latlon));
     }
 }
index c96b8debbe0be6a0e6b4193284a1e6857f66dd6a..689790eb89aa77a507d29a8df749639f59738d30 100644 (file)
@@ -70,7 +70,7 @@ public class AbstractWeatherHandlerTest {
         }
     }
 
-    public static final List<Object[]> parametersForFloorToEvenMinutes() {
+    public static List<Object[]> parametersForFloorToEvenMinutes() {
         return Arrays.asList(new Object[][] { //
                 { 1626605128L /* 2021-07-18 10:45:28 */, 1, 1626605100 /* 10:45 */ }, //
                 { 1626605128L /* 2021-07-18 10:45:28 */, 5, 1626605100 /* 10:45 */ }, //
@@ -101,7 +101,7 @@ public class AbstractWeatherHandlerTest {
         assertEquals(expected, floorToEvenMinutes(epochSeconds, roundMinutes));
     }
 
-    public static final List<Object[]> parametersForCeilToEvenMinutes() {
+    public static List<Object[]> parametersForCeilToEvenMinutes() {
         return Arrays.asList(new Object[][] { //
                 { 1626605128L /* 2021-07-18 10:45:28 */, 1, 1626605160 /* 10:46 */ }, //
                 { 1626605128L /* 2021-07-18 10:45:28 */, 5, 1626605400 /* 10:50 */ }, //
@@ -117,7 +117,7 @@ public class AbstractWeatherHandlerTest {
         assertEquals(expected, ceilToEvenMinutes(epochSeconds, roundMinutes));
     }
 
-    public static final List<Object[]> parametersForLastValidIndex() {
+    public static List<Object[]> parametersForLastValidIndex() {
         return Arrays.asList(new Object[][] { //
                 { "no nulls", 1, new BigDecimal[] { bd(1), bd(2) } }, //
                 { "one null in beginning", 1, new BigDecimal[] { null, bd(2) } }, //
index 1aa631fc3484206eefe53c9ceac58dec70db2b60..5e2bc898c7c37a67df5879b44f02524862a15199 100644 (file)
@@ -40,20 +40,24 @@ public class FMIRequestTest {
     @Test
     public void testObservationRequestToUrl() {
         ObservationRequest request = new ObservationRequest(new FMISID("101023"), 1552215664L, 1552215665L, 61);
-        assertThat(request.toUrl(), is(
-                "https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::multipointcoverage"
-                        + "&starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&fmisid=101023"
-                        + "&parameters=t2m,rh,wd_10min,ws_10min,wg_10min,p_sea,r_1h,snow_aws,vis,n_man,wawa"));
+        assertThat(request.toUrl(),
+                is("""
+                        https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::multipointcoverage\
+                        &starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&fmisid=101023\
+                        &parameters=t2m,rh,wd_10min,ws_10min,wg_10min,p_sea,r_1h,snow_aws,vis,n_man,wawa\
+                        """));
     }
 
     @Test
     public void testForecastRequestToUrl() {
         ForecastRequest request = new ForecastRequest(new LatLon(new BigDecimal("9"), new BigDecimal("8")), 1552215664L,
                 1552215665L, 61);
-        assertThat(request.toUrl(), is(
-                "https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::forecast::harmonie::surface::point::multipointcoverage"
-                        + "&starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&latlon=9,8"
-                        + "&parameters=Temperature,Humidity,WindDirection,WindSpeedMS,WindGust,Pressure,Precipitation1h,TotalCloudCover,WeatherSymbol3"));
+        assertThat(request.toUrl(),
+                is("""
+                        https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::forecast::harmonie::surface::point::multipointcoverage\
+                        &starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&latlon=9,8\
+                        &parameters=Temperature,Humidity,WindDirection,WindSpeedMS,WindGust,Pressure,Precipitation1h,TotalCloudCover,WeatherSymbol3\
+                        """));
     }
 
     @Test
@@ -68,9 +72,11 @@ public class FMIRequestTest {
             }
         };
         ObservationRequest request = new ObservationRequest(location, 1552215664L, 1552215665L, 61);
-        assertThat(request.toUrl(), is(
-                "https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::multipointcoverage"
-                        + "&starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&lat=MYLAT&lon=FOO&special=x,y,z"
-                        + "&parameters=t2m,rh,wd_10min,ws_10min,wg_10min,p_sea,r_1h,snow_aws,vis,n_man,wawa"));
+        assertThat(request.toUrl(),
+                is("""
+                        https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::multipointcoverage\
+                        &starttime=2019-03-10T11:01:04Z&endtime=2019-03-10T11:01:05Z&timestep=61&lat=MYLAT&lon=FOO&special=x,y,z\
+                        &parameters=t2m,rh,wd_10min,ws_10min,wg_10min,p_sea,r_1h,snow_aws,vis,n_man,wawa\
+                        """));
     }
 }
index 131ac7f798e82d251e102ce687ab60e71d38d50a..2ba0fd5fe0aca48e52256311af3297ded2c624a1 100644 (file)
@@ -124,7 +124,7 @@ public class S3Actions {
 
         nameNodesList = doc.getElementsByTagName("IsTruncated");
         if (nameNodesList.getLength() > 0) {
-            if (nameNodesList.item(0).getFirstChild().getTextContent().equals("true")) {
+            if ("true".equals(nameNodesList.item(0).getFirstChild().getTextContent())) {
                 nameNodesList = doc.getElementsByTagName("NextContinuationToken");
                 if (nameNodesList.getLength() > 0) {
                     String continueToken = nameNodesList.item(0).getFirstChild().getTextContent();
index 53c8cacae26af8637f4f1b98bfb7d2a114f0071f..cd872a2fa31725bc890c8a0f6c5139c33657324f 100644 (file)
@@ -101,9 +101,8 @@ public abstract class AWS4SignerBase {
 
     protected static String getCanonicalRequest(URL endpoint, String httpMethod, String queryParameters,
             String canonicalizedHeaderNames, String canonicalizedHeaders, String bodyHash) {
-        String canonicalRequest = httpMethod + "\n" + getCanonicalizedResourcePath(endpoint) + "\n" + queryParameters
-                + "\n" + canonicalizedHeaders + "\n" + canonicalizedHeaderNames + "\n" + bodyHash;
-        return canonicalRequest;
+        return httpMethod + "\n" + getCanonicalizedResourcePath(endpoint) + "\n" + queryParameters + "\n"
+                + canonicalizedHeaders + "\n" + canonicalizedHeaderNames + "\n" + bodyHash;
     }
 
     protected static String getCanonicalizedResourcePath(URL endpoint) {
@@ -154,9 +153,8 @@ public abstract class AWS4SignerBase {
 
     protected static String getStringToSign(String scheme, String algorithm, String dateTime, String scope,
             String canonicalRequest) {
-        String stringToSign = scheme + "-" + algorithm + "\n" + dateTime + "\n" + scope + "\n"
+        return scheme + "-" + algorithm + "\n" + dateTime + "\n" + scope + "\n"
                 + BinaryUtils.toHex(hash(canonicalRequest));
-        return stringToSign;
     }
 
     public static byte[] hash(String text) {
index 17a73a831f045d57b9606e8f1e4b1ead940b33e0..db6b7cb260dc63d4fd993070825f3ba9f95a40a1 100644 (file)
@@ -63,8 +63,7 @@ public class AWS4SignerForAuthorizationHeader extends AWS4SignerBase {
         String credentialsAuthorizationHeader = "Credential=" + awsAccessKey + "/" + scope;
         String signedHeadersAuthorizationHeader = "SignedHeaders=" + canonicalizedHeaderNames;
         String signatureAuthorizationHeader = "Signature=" + BinaryUtils.toHex(signature);
-        String authorizationHeader = SCHEME + "-" + ALGORITHM + " " + credentialsAuthorizationHeader + ", "
-                + signedHeadersAuthorizationHeader + ", " + signatureAuthorizationHeader;
-        return authorizationHeader;
+        return SCHEME + "-" + ALGORITHM + " " + credentialsAuthorizationHeader + ", " + signedHeadersAuthorizationHeader
+                + ", " + signatureAuthorizationHeader;
     }
 }
index 88d9f668842c7a9d55ed6bce61f3343cf8049929..74a8bbe7c94e2b1888607f9a38b0cd763338dcf9 100644 (file)
@@ -129,7 +129,7 @@ public class FtpFolderWatcherHandler extends BaseThingHandler {
         Instant dateNow = Instant.now();
         for (FTPFile file : ftpClient.listFiles(dirPath)) {
             String currentFileName = file.getName();
-            if (currentFileName.equals(".") || currentFileName.equals("..")) {
+            if (".".equals(currentFileName) || "..".equals(currentFileName)) {
                 continue;
             }
             String filePath = dirPath + "/" + currentFileName;
index da7403ba4866c892badbb69f4dc856786853d334..793c4442cedefe4a1a3f0eef99a3e0cb7adba7b7 100644 (file)
@@ -12,9 +12,9 @@
  */
 package org.openhab.binding.folding.internal.discovery;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.openhab.binding.folding.internal.FoldingBindingConstants;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
@@ -37,7 +37,7 @@ import org.osgi.service.component.annotations.Component;
 public class FoldingSlotDiscoveryService extends AbstractDiscoveryService {
 
     public FoldingSlotDiscoveryService() {
-        super(Collections.singleton(FoldingBindingConstants.THING_TYPE_SLOT), 10, true);
+        super(Set.of(FoldingBindingConstants.THING_TYPE_SLOT), 10, true);
         FoldingDiscoveryProxy.getInstance().setService(this);
     }
 
index 5d672c83f3b9ee5a761d235426e44b3a1ad805a6..8641ba9f189d05152f0e9d64db3102137d2ff74e 100644 (file)
@@ -74,7 +74,7 @@ public class FoldingClientHandler extends BaseBridgeHandler {
         try {
             if (command instanceof RefreshType) {
                 refresh();
-            } else if (channelUID.getId().equals("run")) {
+            } else if ("run".equals(channelUID.getId())) {
                 if (command == OnOffType.ON) {
                     sendCommand("unpause");
                 } else if (command == OnOffType.OFF) {
@@ -82,7 +82,7 @@ public class FoldingClientHandler extends BaseBridgeHandler {
                 }
                 refresh();
                 delayedRefresh();
-            } else if (channelUID.getId().equals("finish")) {
+            } else if ("finish".equals(channelUID.getId())) {
                 if (command == OnOffType.ON) {
                     sendCommand("finish");
                 } else if (command == OnOffType.OFF) {
index 83a31ad088273864f3c067a6d680a1993e582dca..dc87c23ea49e6e4fc5a2d0ad3ac24303c564f2bd 100644 (file)
@@ -57,13 +57,13 @@ public class SlotHandler extends BaseThingHandler implements SlotUpdateListener
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
         try {
-            if (channelUID.getId().equals("run")) {
+            if ("run".equals(channelUID.getId())) {
                 if (command == OnOffType.ON) {
                     getBridgeHandler().sendCommand("unpause " + myId());
                 } else if (command == OnOffType.OFF) {
                     getBridgeHandler().sendCommand("pause " + myId());
                 }
-            } else if (channelUID.getId().equals("finish")) {
+            } else if ("finish".equals(channelUID.getId())) {
                 if (command == OnOffType.ON) {
                     getBridgeHandler().sendCommand("finish " + myId());
                 } else if (command == OnOffType.OFF) {
index cf7639a16239c40681e7f4a58d05872dbdacd041..c0de792df7eb90043ffff40211f39cf162a30687 100644 (file)
@@ -48,7 +48,7 @@ public class FoobotHandlerFactory extends BaseThingHandlerFactory {
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPE_UIDS = Collections
             .unmodifiableSet(Stream.of(BRIDGE_TYPE_FOOBOTACCOUNT, THING_TYPE_FOOBOT).collect(Collectors.toSet()));
 
-    public static final Set<ThingTypeUID> DISCOVERABLE_THING_TYPE_UIDS = Collections.singleton(THING_TYPE_FOOBOT);
+    public static final Set<ThingTypeUID> DISCOVERABLE_THING_TYPE_UIDS = Set.of(THING_TYPE_FOOBOT);
 
     private final FoobotApiConnector connector = new FoobotApiConnector();
 
index 2280f190db11d761462a525a25f0796ce0f21c5f..39f921e5256e1e201b0e78505cc19aca002d25e9 100644 (file)
@@ -98,8 +98,8 @@ public class FoobotAccountDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(@Nullable final ThingHandler handler) {
-        if (handler instanceof FoobotAccountHandler) {
-            this.handler = (FoobotAccountHandler) handler;
+        if (handler instanceof FoobotAccountHandler accountHandler) {
+            this.handler = accountHandler;
         }
     }
 
index bfc9a194a01dfa749d8ca8f5270b333d94e6f9b2..527fae562de541fddfb8f77db0a333ea956ef9d8 100644 (file)
@@ -17,8 +17,8 @@ import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
 import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -79,7 +79,7 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(FoobotAccountDiscoveryService.class);
+        return Set.of(FoobotAccountDiscoveryService.class);
     }
 
     public List<FoobotDevice> getDeviceList() throws FoobotApiException {
@@ -192,12 +192,12 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof FoobotDeviceHandler) {
-            final String uuid = ((FoobotDeviceHandler) childHandler).getUuid();
+        if (childHandler instanceof FoobotDeviceHandler handler) {
+            final String uuid = handler.getUuid();
 
             try {
                 getDeviceList().stream().filter(d -> d.getUuid().equals(uuid)).findAny()
-                        .ifPresent(fd -> ((FoobotDeviceHandler) childHandler).handleUpdateProperties(fd));
+                        .ifPresent(fd -> handler.handleUpdateProperties(fd));
             } catch (FoobotApiException e) {
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
             }
index 81bab765dfe3e2b79a35aa809aee39cc5162ecba..7f10dd73da19ef71b3cb1387613bba581a0782c6 100644 (file)
@@ -41,8 +41,7 @@ public class FreeboxBindingConstants {
     public static final ThingTypeUID FREEBOX_THING_TYPE_AIRPLAY = new ThingTypeUID(BINDING_ID, "airplay");
 
     // All supported Bridge types
-    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Collections
-            .singleton(FREEBOX_BRIDGE_TYPE_SERVER);
+    public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Set.of(FREEBOX_BRIDGE_TYPE_SERVER);
 
     // All supported Thing types
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
index e861c1f9073dcdd35a20c08f50ae5392d3392f30..13de1631159fc9568c6a4eb52059f2822bc0454f 100644 (file)
@@ -464,8 +464,7 @@ public class FreeboxApiManager {
         // Parse the full response in case of success
         T fullResponse = gson.fromJson(jsonResponse, responseClass);
         fullResponse.evaluate();
-        F result = fullResponse.getResult();
-        return result;
+        return fullResponse.getResult();
     }
 
     private String encodeUrl(String url) throws FreeboxException {
index 68e3104cf49996ecb77f08a7e49581d7b5b00e8a..21bdd1a6b307576e7690b99e870e317a316a03e2 100644 (file)
@@ -21,7 +21,7 @@ package org.openhab.binding.freebox.internal.api.model;
  */
 public class FreeboxAirMediaReceiverRequest {
 
-    private static enum MediaAction {
+    private enum MediaAction {
         START("start"),
         STOP("stop");
 
@@ -36,7 +36,7 @@ public class FreeboxAirMediaReceiverRequest {
         }
     }
 
-    private static enum MediaType {
+    private enum MediaType {
         VIDEO("video"),
         PHOTO("photo");
 
index 9cfd7aaf01aeaaba227762f03ff596c20c179291..5f91070b77a4b4381f86bdfd5dfb9dccd6604186 100644 (file)
@@ -21,7 +21,7 @@ package org.openhab.binding.freebox.internal.api.model;
  */
 public class FreeboxAuthorizationStatus {
 
-    private static enum AuthorizationStatus {
+    private enum AuthorizationStatus {
         UNKNOWN("unknown"),
         PENDING("pending"),
         TIMEOUT("timeout"),
index 1899d0521029ecd6798de5654b9a965570fb91c6..ab4f16caf78c3cd0f614428dfc5671e3166c298a 100644 (file)
@@ -62,8 +62,8 @@ public class FreeboxCommandExtension extends AbstractConsoleCommandExtension imp
             FreeboxHandler handler = null;
             if (thing != null) {
                 thingHandler = thing.getHandler();
-                if (thingHandler instanceof FreeboxHandler) {
-                    handler = (FreeboxHandler) thingHandler;
+                if (thingHandler instanceof FreeboxHandler freeboxHandler) {
+                    handler = freeboxHandler;
                 }
             }
             if (thing == null) {
index 0f034e4b5f7c15d7dd09aaebf0feeaa1b7e0e440..e794c2dc2e5642138a8716f6e7e5ef8374204cb9 100644 (file)
@@ -79,8 +79,8 @@ public class FreeboxDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void setThingHandler(ThingHandler handler) {
-        if (handler instanceof FreeboxHandler) {
-            bridgeHandler = (FreeboxHandler) handler;
+        if (handler instanceof FreeboxHandler freeboxHandler) {
+            bridgeHandler = freeboxHandler;
         }
     }
 
index da6fc3add74a29f6217c827fd47755d56592ca07..db210bfd20610baa218273b8a8d65a9d22363c6f 100644 (file)
@@ -16,9 +16,9 @@ import static org.openhab.binding.freebox.internal.FreeboxBindingConstants.*;
 
 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.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -92,7 +92,7 @@ public class FreeboxHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(FreeboxDiscoveryService.class);
+        return Set.of(FreeboxDiscoveryService.class);
     }
 
     @Override
@@ -494,8 +494,8 @@ public class FreeboxHandler extends BaseBridgeHandler {
                     continue;
                 }
                 ThingHandler handler = thing.getHandler();
-                if (handler instanceof FreeboxThingHandler) {
-                    ((FreeboxThingHandler) handler).updateNetInfo(hosts);
+                if (handler instanceof FreeboxThingHandler thingHandler) {
+                    thingHandler.updateNetInfo(hosts);
                 }
             }
 
@@ -519,8 +519,8 @@ public class FreeboxHandler extends BaseBridgeHandler {
                     continue;
                 }
                 ThingHandler handler = thing.getHandler();
-                if (handler instanceof FreeboxThingHandler) {
-                    ((FreeboxThingHandler) handler).updateAirPlayDevice(devices);
+                if (handler instanceof FreeboxThingHandler thingHandler) {
+                    thingHandler.updateAirPlayDevice(devices);
                 }
             }
 
@@ -542,12 +542,10 @@ public class FreeboxHandler extends BaseBridgeHandler {
             } else if (command instanceof OnOffType) {
                 updateChannelDecimalState(LCDBRIGHTNESS,
                         apiManager.setLcdBrightness((command == OnOffType.ON) ? 100 : 0));
-            } else if (command instanceof DecimalType) {
-                updateChannelDecimalState(LCDBRIGHTNESS,
-                        apiManager.setLcdBrightness(((DecimalType) command).intValue()));
-            } else if (command instanceof PercentType) {
-                updateChannelDecimalState(LCDBRIGHTNESS,
-                        apiManager.setLcdBrightness(((PercentType) command).intValue()));
+            } else if (command instanceof DecimalType decimalCommand) {
+                updateChannelDecimalState(LCDBRIGHTNESS, apiManager.setLcdBrightness(decimalCommand.intValue()));
+            } else if (command instanceof PercentType percentCommand) {
+                updateChannelDecimalState(LCDBRIGHTNESS, apiManager.setLcdBrightness(percentCommand.intValue()));
             } else {
                 logger.debug("Thing {}: invalid command {} from channel {}", getThing().getUID(), command,
                         channelUID.getId());
@@ -559,9 +557,9 @@ public class FreeboxHandler extends BaseBridgeHandler {
     }
 
     private void setOrientation(ChannelUID channelUID, Command command) {
-        if (command instanceof DecimalType) {
+        if (command instanceof DecimalType orientation) {
             try {
-                FreeboxLcdConfig config = apiManager.setLcdOrientation(((DecimalType) command).intValue());
+                FreeboxLcdConfig config = apiManager.setLcdOrientation(orientation.intValue());
                 updateChannelDecimalState(LCDORIENTATION, config.getOrientation());
                 updateChannelSwitchState(LCDFORCED, config.isOrientationForced());
             } catch (FreeboxException e) {
index 1b95cf408c9bae08ec7de222d2fc1d42e14d8d01..94645ce409e910fa3b7716d9e8c34bf1a6bd9aaa 100644 (file)
@@ -24,7 +24,7 @@ import org.openhab.binding.freeboxos.internal.api.rest.LoginManager;
  */
 @NonNullByDefault
 public class Response<ResultType> {
-    public static enum ErrorCode {
+    public enum ErrorCode {
         AUTH_REQUIRED,
         BAD_LOGIN,
         TOO_SHORT,
@@ -91,7 +91,7 @@ public class Response<ResultType> {
         ERR_030,
         ERR_031,
         NONE,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private ErrorCode errorCode = ErrorCode.NONE;
index 233046da0a82bfdcb738cece5eef7fa1e8b99dd9..db87b272142811e547894cd7df365c44481e0596 100644 (file)
@@ -57,10 +57,10 @@ public class APManager extends ListableRest<APManager.WifiAp, APManager.APRespon
         }
     }
 
-    private static enum State {
+    private enum State {
         ASSOCIATED,
         AUTHENTICATED,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Station(String id, MACAddress mac, String bssid, @Nullable String hostname, LanHost host,
@@ -83,7 +83,7 @@ public class APManager extends ListableRest<APManager.WifiAp, APManager.APRespon
 
     protected static record ApStatus(ApState state, int channelWidth, int primaryChannel, int secondaryChannel,
             int dfsCacRemainingTime, boolean dfsDisabled) {
-        private static enum ApState {
+        private enum ApState {
             SCANNING, // Ap is probing wifi channels
             NO_PARAM, // Ap is not configured
             BAD_PARAM, // Ap has an invalid configuration
@@ -96,7 +96,7 @@ public class APManager extends ListableRest<APManager.WifiAp, APManager.APRespon
             DFS, // Ap is performing dynamic frequency selection
             ACTIVE, // Ap is active
             FAILED, // Ap has failed to start
-            UNKNOWN;
+            UNKNOWN
         }
     }
 
index ed077efada41cc972c7017849e0707a9c338a0a2..9e0dce9cd0cd224b6f592aad6b92e46c8dc577e0 100644 (file)
@@ -33,7 +33,7 @@ public class AfpManager extends ConfigurableRest<AfpManager.Afp, AfpManager.Conf
 
     protected static record Afp(boolean enabled, boolean guestAllow, ServerType serverType, @Nullable String loginName,
             @Nullable String loginPassword) {
-        private static enum ServerType {
+        private enum ServerType {
             POWERBOOK,
             POWERMAC,
             MACMINI,
@@ -45,7 +45,7 @@ public class AfpManager extends ConfigurableRest<AfpManager.Afp, AfpManager.Conf
             APPLETV,
             AIRPORT,
             XSERVE,
-            UNKNOWN;
+            UNKNOWN
         }
     }
 
index 54444ba48faf306e526f70930d76735a455315ea..84914f403c2b839b5740e7e139df4d7fc9397b17 100644 (file)
@@ -37,12 +37,12 @@ public class CallManager extends RestManager {
     private static class Calls extends Response<Call> {
     }
 
-    public static enum Type {
+    public enum Type {
         ACCEPTED,
         MISSED,
         OUTGOING,
         INCOMING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Call(Type type, //
index c500847a6414b0744e643724d91973d841c68605..c8be49c48d172a15ce6fea92c96ab47fac416cf5 100644 (file)
@@ -35,27 +35,27 @@ public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status
     protected static class StatusResponse extends Response<Status> {
     }
 
-    private static enum State {
+    private enum State {
         GOING_UP,
         UP,
         GOING_DOWN,
         DOWN,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    private static enum Type {
+    private enum Type {
         ETHERNET,
         RFC2684,
         PPPOATM,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    private static enum Media {
+    private enum Media {
         FTTH,
         ETHERNET,
         XDSL,
         BACKUP_4G,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Status(State state, Type type, Media media, @Nullable List<Integer> ipv4PortRange,
index d67b3edc7e9b878c77ecfc4764ad869c8d66a664..f02553357c8e51f35037b7c0e0f9f752336c1582 100644 (file)
@@ -52,7 +52,7 @@ public class FreeboxOsSession {
     private @Nullable Session session;
     private String appToken = "";
 
-    public static enum BoxModel {
+    public enum BoxModel {
         FBXGW_R1_FULL, // Freebox Server (v6) revision 1
         FBXGW_R2_FULL, // Freebox Server (v6) revision 2
         FBXGW_R1_MINI, // Freebox Mini revision 1
@@ -60,7 +60,7 @@ public class FreeboxOsSession {
         FBXGW_R1_ONE, // Freebox One revision 1
         FBXGW_R2_ONE, // Freebox One revision 2
         FBXGW7_R1_FULL, // Freebox v7 revision 1
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record ApiVersion(String apiBaseUrl, @Nullable String apiDomain, String apiVersion, BoxModel boxModel,
@@ -156,8 +156,8 @@ public class FreeboxOsSession {
                 manager = addManager(clazz, managerConstructor.newInstance(this));
             } catch (InvocationTargetException e) {
                 Throwable cause = e.getCause();
-                if (cause instanceof PermissionException) {
-                    throw (PermissionException) cause;
+                if (cause instanceof PermissionException exception) {
+                    throw exception;
                 }
                 throw new FreeboxException(e, "Unable to call RestManager constructor for %s", clazz.getName());
             } catch (ReflectiveOperationException e) {
index 659904882c22b5ffbb4fa4a630eac1f6abd766a1..2f7fd291ca16f1b8a071099a6037a9bf5f9de143 100644 (file)
@@ -36,11 +36,11 @@ public class FreeplugManager extends RestManager {
     private static class Networks extends Response<Network> {
     }
 
-    public static enum NetRole {
+    public enum NetRole {
         STA, // Freeplug station
         PCO, // Freeplug proxy coordinator
         CCO, // Central Coordinator
-        UNKNOWN;
+        UNKNOWN
     }
 
     private enum Status {
index fbb64ecaf6dc24e9808296f28433e797f9674f2d..a14829616d81efdbd4911ef964dd8398cac9489c 100644 (file)
@@ -42,14 +42,14 @@ public class HomeManager extends RestManager {
     private static class HomeNodesResponse extends Response<HomeNode> {
     }
 
-    private static enum AccessType {
+    private enum AccessType {
         R,
         W,
         RW,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    private static enum DisplayType {
+    private enum DisplayType {
         TEXT,
         ICON,
         BUTTON,
@@ -57,7 +57,7 @@ public class HomeManager extends RestManager {
         TOGGLE,
         COLOR,
         WARNING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private static record EndpointValue<T> (T value) {
@@ -66,13 +66,13 @@ public class HomeManager extends RestManager {
     private static record EndpointUi(AccessType access, DisplayType display, String iconUrl, @Nullable String unit) {
     }
 
-    private static enum ValueType {
+    private enum ValueType {
         BOOL,
         INT,
         FLOAT,
         VOID,
         STRING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record EndpointState(@Nullable String value, ValueType valueType, long refresh) {
@@ -91,7 +91,7 @@ public class HomeManager extends RestManager {
         }
     }
 
-    public static enum EpType {
+    public enum EpType {
         SIGNAL,
         SLOT,
         UNKNOWN;
@@ -106,23 +106,23 @@ public class HomeManager extends RestManager {
 
     public static record Endpoint(int id, String name, String label, EpType epType, Visibility visibility, int refresh,
             ValueType valueType, EndpointUi ui, @Nullable String category, Object value, List<LogEntry> history) {
-        private static enum Visibility {
+        private enum Visibility {
             INTERNAL,
             NORMAL,
             DASHBOARD,
-            UNKNOWN;
+            UNKNOWN
         }
     }
 
-    private static enum Status {
+    private enum Status {
         UNREACHABLE,
         DISABLED,
         ACTIVE,
         UNPAIRED,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    public static enum Category {
+    public enum Category {
         BASIC_SHUTTER,
         SHUTTER,
         ALARM,
index ac4e44e7705c06815e6cdd59818785b6a7cb7b59..01eb82f5b205e093fc5ab7eda38adb2c0461902d 100644 (file)
@@ -50,14 +50,14 @@ public class LanBrowserManager extends ListableRest<LanBrowserManager.Interface,
     protected static class InterfacesResponse extends Response<Interface> {
     }
 
-    public static enum Source {
+    public enum Source {
         DHCP,
         NETBIOS,
         MDNS,
         MDNS_SRV,
         UPNP,
         WSD,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public record HostName(@Nullable String name, Source source) {
@@ -69,9 +69,9 @@ public class LanBrowserManager extends ListableRest<LanBrowserManager.Interface,
     private static record WakeOnLineData(String mac, String password) {
     }
 
-    private static enum Type {
+    private enum Type {
         MAC_ADDRESS,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private static record L2Ident(MACAddress id, Type type) {
@@ -80,10 +80,10 @@ public class LanBrowserManager extends ListableRest<LanBrowserManager.Interface,
     private static record L3Connectivity(String addr, Af af, boolean active, boolean reachable,
             ZonedDateTime lastActivity, ZonedDateTime lastTimeReachable, String model) {
 
-        private static enum Af {
+        private enum Af {
             IPV4,
             IPV6,
-            UNKNOWN;
+            UNKNOWN
         }
 
         public IPAddress getIPAddress() {
@@ -97,7 +97,7 @@ public class LanBrowserManager extends ListableRest<LanBrowserManager.Interface,
     public static record HostIntf(LanHost host, Interface intf) {
     }
 
-    private static enum HostType {
+    private enum HostType {
         WORKSTATION,
         LAPTOP,
         SMARTPHONE,
@@ -120,7 +120,7 @@ public class LanBrowserManager extends ListableRest<LanBrowserManager.Interface,
         MULTIMEDIA_DEVICE,
         CAR,
         OTHER,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record LanHost(String id, @Nullable String primaryName, HostType hostType, boolean primaryNameManual,
index e628cb2f2f83ab6ed02328a2c5bdd954682e1978..a25154bd7c8f867c2947098ad9ef586551edfe54 100644 (file)
@@ -31,10 +31,10 @@ public class LanManager extends ConfigurableRest<LanManager.LanConfig, LanManage
     protected static class Config extends Response<LanConfig> {
     }
 
-    private static enum Mode {
+    private enum Mode {
         ROUTER,
         BRIDGE,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record LanConfig(IPAddress ip, String name, String nameDns, String nameMdns, String nameNetbios,
index 41e38e235adb174e2720de4e5a23721e25b5e6d5..21ec0db9d9bb1a0e400a9599ddef4729c0539cc0 100644 (file)
@@ -44,12 +44,12 @@ public class LoginManager extends RestManager {
     private static final String AUTHORIZE_ACTION = "authorize";
     private static final String LOGOUT = "logout";
 
-    private static enum Status {
+    private enum Status {
         PENDING, // the user has not confirmed the autorization request yet
         TIMEOUT, // the user did not confirmed the authorization within the given time
         GRANTED, // the app_token is valid and can be used to open a session
         DENIED, // the user denied the authorization request
-        UNKNOWN; // the app_token is invalid or has been revoked
+        UNKNOWN // the app_token is invalid or has been revoked
     }
 
     private static record AuthorizationStatus(Status status, boolean loggedIn, String challenge,
@@ -65,7 +65,7 @@ public class LoginManager extends RestManager {
     private static class AuthResponse extends Response<Authorization> {
     }
 
-    public static enum Permission {
+    public enum Permission {
         PARENTAL,
         CONTACTS,
         EXPLORER,
@@ -81,7 +81,7 @@ public class LoginManager extends RestManager {
         VM,
         PLAYER,
         NONE,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Session(Map<LoginManager.Permission, @Nullable Boolean> permissions,
index da7849b9e3c687a1f451bb870a8c0a6ac4e2f757..f9ee9c71d6f444e50eb18a65b1fd137a41e77f7d 100644 (file)
@@ -40,18 +40,18 @@ public class MediaReceiverManager extends ListableRest<Receiver, MediaReceiverMa
     protected static class ReceiverResponse extends Response<Receiver> {
     }
 
-    public static enum Action {
+    public enum Action {
         START,
         STOP,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    public static enum MediaType {
+    public enum MediaType {
         VIDEO,
         PHOTO,
         AUDIO,
         SCREEN,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private static record Request(String password, Action action, MediaType mediaType, @Nullable String media,
index dc797a177d35dc169ca1fc0b7bbc6c3a0d059619..ed774ad07926b18400c672dfd5828435098a5510 100644 (file)
@@ -37,9 +37,9 @@ public class PhoneManager extends ConfigurableRest<PhoneManager.Config, PhoneMan
     protected class StatusResponse extends Response<Status> {
     }
 
-    private static enum NetworkStatus {
+    private enum NetworkStatus {
         WORKING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Config(NetworkStatus network, boolean dectEcoMode, String dectPin, int dectRingPattern,
@@ -49,7 +49,7 @@ public class PhoneManager extends ConfigurableRest<PhoneManager.Config, PhoneMan
     public enum Type {
         FXS,
         DECT,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Status(int id, boolean isRinging, boolean onHook, boolean hardwareDefect, Type type,
index 7ef7907ecde7d02cf099a8335797235a5aaa5718..0326c1e0ff8b4a95ca85624c9fea5183adb85bc6 100644 (file)
@@ -48,7 +48,7 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
     protected static class PlayerResponse extends Response<Player> {
     }
 
-    public static enum DeviceModel {
+    public enum DeviceModel {
         FBX7HD_DELTA, // Freebox Player Devialet
         TBX8AM, // Player Pop
         FBX6HD,
@@ -57,18 +57,18 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
         FBX7HD,
         FBX7HD_ONE,
         FBX8AM,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Player(MACAddress mac, StbType stbType, int id, ZonedDateTime lastTimeReachable,
             boolean apiAvailable, String deviceName, DeviceModel deviceModel, boolean reachable, String uid,
             @Nullable String apiVersion, List<String> lanGids) {
-        private static enum StbType {
+        private enum StbType {
             STB_ANDROID,
             STB_V6,
             STB_V7,
             STB_V8,
-            UNKNOWN;
+            UNKNOWN
         }
 
         /**
@@ -83,10 +83,10 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
     private static class StatusResponse extends Response<Status> {
     }
 
-    public static enum PowerState {
+    public enum PowerState {
         STANDBY,
         RUNNING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Status(PowerState powerState, StatusInformation player,
@@ -113,7 +113,7 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
 
     private enum MediaState {
         READY,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private static record AudioTrack(int bitrate, @SerializedName("channelCount") int channelCount,
@@ -121,10 +121,10 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
             @SerializedName("metadataId") @Nullable String metadataId, int pid, int samplerate, long uid) {
     }
 
-    private static enum Type {
+    private enum Type {
         NORMAL,
         HEARINGIMPAIRED,
-        UNKNOWN;
+        UNKNOWN
     }
 
     protected static record Metadata(@Nullable String album,
@@ -137,10 +137,10 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
             @Nullable String title, @SerializedName("trackNumber") int trackNumber,
             @SerializedName("trackTotal") int trackTotal, @Nullable String url) {
 
-        protected static enum PlaybackState {
+        protected enum PlaybackState {
             PLAY,
             PAUSE,
-            UNKNOWN;
+            UNKNOWN
         }
 
         protected static record SubtitleTrack(@Nullable String codec, @Nullable String language, @Nullable String pid,
@@ -164,14 +164,14 @@ public class PlayerManager extends ListableRest<PlayerManager.Player, PlayerMana
         }
     }
 
-    private static enum BouquetType {
+    private enum BouquetType {
         ADSL,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    private static enum ChannelType {
+    private enum ChannelType {
         REGULAR,
-        UNKNOWN;
+        UNKNOWN
     }
 
     private static record Service(long id, @Nullable String name,
index d76b4a646a89122a57ffed366ab1e8de52c318fe..add9ac45029c68c9fddbab6840e2b79e80fb7e89 100644 (file)
@@ -45,25 +45,25 @@ public class RepeaterManager extends ListableRest<RepeaterManager.Repeater, Repe
     public static record RepeaterLed(int id, boolean ledActivated) {
     }
 
-    private static enum Connection {
+    private enum Connection {
         CONNECTED,
         DISCONNECTED,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    private static enum Status {
+    private enum Status {
         STARTING,
         RUNNING,
         REBOOTING,
         UPDATING,
         REBOOT_FAILURE,
         UPDATE_FAILURE,
-        UNKNOWN;
+        UNKNOWN
     }
 
-    public static enum Model {
+    public enum Model {
         FBXWMR, // Répéteur Wifi
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record Repeater(int id, boolean ledActivated, boolean enabled, MACAddress mainMac,
index 2ed5b0a66368c736ed52aa72109b1f33da2d312a..2f04d82927b1693b6e5be908972f5d48f78ba0d2 100644 (file)
@@ -36,7 +36,7 @@ public class SystemManager extends ConfigurableRest<SystemManager.Config, System
         public enum SensorKind {
             FAN,
             TEMP,
-            UNKNOWN;
+            UNKNOWN
         }
 
         public SensorKind getKind() {
@@ -54,13 +54,13 @@ public class SystemManager extends ConfigurableRest<SystemManager.Config, System
 
     private static record Expansion(int slot, boolean probeDone, boolean present, boolean supported, String bundle,
             Type type) {
-        private static enum Type {
+        private enum Type {
             UNKNOWN, // unknown module
             DSL_LTE, // xDSL + LTE
             DSL_LTE_EXTERNAL_ANTENNAS, // xDSL + LTE with external antennas switch
             FTTH_P2P, // FTTH P2P
             FTTH_PON, // FTTH PON
-            SECURITY; // Security module
+            SECURITY // Security module
         }
     }
 
@@ -72,13 +72,13 @@ public class SystemManager extends ConfigurableRest<SystemManager.Config, System
     public static record Config(String firmwareVersion, MACAddress mac, String serial, String uptime, long uptimeVal,
             String boardName, boolean boxAuthenticated, DiskStatus diskStatus, String userMainStorage,
             List<Sensor> sensors, ModelInfo modelInfo, List<Sensor> fans, List<Expansion> expansions) {
-        private static enum DiskStatus {
+        private enum DiskStatus {
             NOT_DETECTED,
             DISABLED,
             INITIALIZING,
             ERROR,
             ACTIVE,
-            UNKNOWN;
+            UNKNOWN
         }
     }
 
index 07b75d6ac17d4a7990d6c205f3a2f586cb74c960..c27faa11f350ffeb9fccd1612cea776962604390 100644 (file)
@@ -31,10 +31,10 @@ public class VmManager extends ListableRest<VmManager.VirtualMachine, VmManager.
     protected class VirtualMachineResponse extends Response<VirtualMachine> {
     }
 
-    public static enum Status {
+    public enum Status {
         STOPPED,
         RUNNING,
-        UNKNOWN;
+        UNKNOWN
     }
 
     public static record VirtualMachine(int id, String name, MACAddress mac, Status status) {
index 3303d95b23646692ac1205ee7eac89004be4660b..ff3371e273ce85b92eb3034fac158d618826f4d6 100644 (file)
@@ -63,8 +63,8 @@ public class FreeboxOsCommandExtension extends AbstractConsoleCommandExtension {
             FreeboxOsHandler handler = null;
             if (thing != null) {
                 thingHandler = thing.getHandler();
-                if (thingHandler instanceof FreeboxOsHandler) {
-                    handler = (FreeboxOsHandler) thingHandler;
+                if (thingHandler instanceof FreeboxOsHandler osHandler) {
+                    handler = osHandler;
                 }
             }
             if (thing == null) {
index bc7d7812bb606a89cd67760c308615363a1470a8..52c8063664735ef0101898b3af15b2766343000e 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.freeboxos.internal.handler;
 import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -93,7 +93,7 @@ public class ActivePlayerHandler extends PlayerHandler implements FreeDeviceIntf
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(ActivePlayerActions.class);
+        return List.of(ActivePlayerActions.class);
     }
 
     @Override
index 780f9fab79e8db21777a4ec6e121963adfaf268e..03d3e9b4878c07870567363172b14b424129e731 100644 (file)
@@ -17,10 +17,10 @@ import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.*
 import java.time.ZonedDateTime;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.freeboxos.internal.action.CallActions;
@@ -103,6 +103,6 @@ public class CallHandler extends ApiConsumerHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(CallActions.class);
+        return Set.of(CallActions.class);
     }
 }
index ae89dc28df02e4b0c57ab10caabf7441aafe5cb0..d18ef19fb6ae3cb03b50c07ff106976bfb91067b 100644 (file)
@@ -66,15 +66,14 @@ public class DectHandler extends FxsHandler {
                 return true;
             }
         }
-        if (command instanceof PercentType) {
-            PercentType percent = (PercentType) command;
+        if (command instanceof PercentType percentCommand) {
             if (GAIN_RX.equals(channelId)) {
-                phoneManager.setGainRx(getClientId(), percent.intValue());
-                updateIfActive(GAIN_RX, percent);
+                phoneManager.setGainRx(getClientId(), percentCommand.intValue());
+                updateIfActive(GAIN_RX, percentCommand);
                 return true;
             } else if (GAIN_TX.equals(channelId)) {
-                phoneManager.setGainTx(getClientId(), percent.intValue());
-                updateIfActive(GAIN_RX, percent);
+                phoneManager.setGainTx(getClientId(), percentCommand.intValue());
+                updateIfActive(GAIN_RX, percentCommand);
                 return true;
             }
         }
index bb62c4f37b933143635055d5b94f087f276f72f4..a2395810f5bcbf23396699e106d85cf8e1cd76bf 100644 (file)
@@ -13,8 +13,8 @@
 package org.openhab.binding.freeboxos.internal.handler;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -126,7 +126,7 @@ public class FreeboxOsHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(FreeboxOsDiscoveryService.class);
+        return Set.of(FreeboxOsDiscoveryService.class);
     }
 
     @Override
index ba0693c302843568cf19a8e152901d6f9c7ed4dc..6967ba030a7e14b73cb4073c43e8da282c85277e 100644 (file)
@@ -54,8 +54,8 @@ public class FreeplugHandler extends ApiConsumerHandler {
             properties.put(ROLE, plug.netRole().name());
             properties.put(NET_ID, plug.netId());
             properties.put(ETHERNET_SPEED, "%d Mb/s".formatted(plug.ethSpeed()));
-            properties.put(LOCAL, Boolean.valueOf(plug.local()).toString());
-            properties.put(FULL_DUPLEX, Boolean.valueOf(plug.ethFullDuplex()).toString());
+            properties.put(LOCAL, Boolean.toString(plug.local()));
+            properties.put(FULL_DUPLEX, Boolean.toString(plug.ethFullDuplex()));
 
             if (plug.local()) { // Plug connected to the freebox does not provide rate up or down
                 List<Channel> channels = new ArrayList<>(getThing().getChannels());
index c4eb9594735686eaac13cf18de339a9064de1035..34c8ae7935eeb06a9de280f480ea90a35c3eb582 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.K
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -109,6 +108,6 @@ public class PlayerHandler extends HostHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(PlayerActions.class);
+        return List.of(PlayerActions.class);
     }
 }
index 6b345a88cb058526aaecf2475d452c9e557b8e6c..e4da9d985866f6e15eefe094ea0d7a707af57c1e 100644 (file)
@@ -15,9 +15,9 @@ package org.openhab.binding.freeboxos.internal.handler;
 import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.*;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.freeboxos.internal.action.RepeaterActions;
@@ -104,7 +104,7 @@ public class RepeaterHandler extends HostHandler implements FreeDeviceIntf {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(RepeaterActions.class);
+        return Set.of(RepeaterActions.class);
     }
 
     @Override
index 1771690febe4ac991485af143f2c14a63df8736a..6cf8ba3e5a26f6fab6a2391a9a3515f49f1d63cb 100644 (file)
@@ -73,8 +73,8 @@ public class RevolutionHandler extends ServerHandler {
     }
 
     private void setOrientation(LcdManager manager, Config config, Command command) throws FreeboxException {
-        if (command instanceof DecimalType) {
-            manager.setOrientation(((DecimalType) command).intValue());
+        if (command instanceof DecimalType orientation) {
+            manager.setOrientation(orientation.intValue());
         } else {
             logger.warn("Invalid command {} from channel {}", command, LCD_ORIENTATION);
         }
@@ -93,8 +93,8 @@ public class RevolutionHandler extends ServerHandler {
             manager.setBrightness(() -> config.brightness() + (command == IncreaseDecreaseType.INCREASE ? 1 : -1));
         } else if (command instanceof OnOffType) {
             manager.setBrightness(() -> command == OnOffType.ON ? 100 : 0);
-        } else if (command instanceof QuantityType) {
-            manager.setBrightness(() -> ((QuantityType<?>) command).intValue());
+        } else if (command instanceof QuantityType brightness) {
+            manager.setBrightness(() -> brightness.intValue());
         } else if (command instanceof DecimalType || command instanceof PercentType) {
             manager.setBrightness(() -> ((DecimalType) command).intValue());
         } else {
index f6d607efe286837b1a478f650abfa001ce2a62ff..8fbd24af65729a0289508b65d65b10e0a821839d 100644 (file)
@@ -18,9 +18,9 @@ import static org.openhab.core.library.unit.Units.*;
 import java.math.BigDecimal;
 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 org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.freeboxos.internal.action.ServerActions;
@@ -200,7 +200,7 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(ServerActions.class);
+        return Set.of(ServerActions.class);
     }
 
     @Override
index 50929b81409b5525b1364cdf2c872515c81faf0e..b2fd676b3fec73a30d369d77160f627d2cc62bda 100644 (file)
@@ -93,8 +93,8 @@ public class FroniusBridgeHandler extends BaseBridgeHandler {
 
     @Override
     public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
-        if (childHandler instanceof FroniusBaseThingHandler) {
-            this.services.add((FroniusBaseThingHandler) childHandler);
+        if (childHandler instanceof FroniusBaseThingHandler handler) {
+            this.services.add(handler);
             restartAutomaticRefresh();
         } else {
             logger.debug("Child handler {} not added because it is not an instance of FroniusBaseThingHandler",
index b73d8e9c93335d6201f062786d2a8587ddbb9169..276c75fb0acd4ccedbbe536805b1e101195eaec1 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.fsinternetradio.internal;
 
 import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants.*;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -141,7 +140,7 @@ public class FSInternetRadioDiscoveryParticipant implements UpnpDiscoveryPartici
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return Collections.singleton(THING_TYPE_RADIO);
+        return Set.of(THING_TYPE_RADIO);
     }
 
     @Override
index deb22628b5be6006dfe7c38a074274c3f2559840..f9a11d226e40f3ec58f3967eb0cdd37233f19980 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.fsinternetradio.internal;
 
 import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants.THING_TYPE_RADIO;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference;
 @NonNullByDefault
 public class FSInternetRadioHandlerFactory extends BaseThingHandlerFactory {
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RADIO);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RADIO);
 
     private final HttpClient httpClient;
 
index 161a30fa17a2441f288b10d1f71c90cc644c7ce6..ae0c0d715683e1be7f24c44c76e8811b6a5828dd 100644 (file)
@@ -200,8 +200,8 @@ public class FSInternetRadioHandler extends BaseThingHandler {
                         radio.increaseVolumeAbsolute();
                     } else if (IncreaseDecreaseType.DECREASE.equals(command) || UpDownType.DOWN.equals(command)) {
                         radio.decreaseVolumeAbsolute();
-                    } else if (command instanceof PercentType) {
-                        radio.setVolumePercent(((PercentType) command).intValue());
+                    } else if (command instanceof PercentType percentCommand) {
+                        radio.setVolumePercent(percentCommand.intValue());
                     }
                     // absolute value should also be updated now, so let's update all items
                     scheduler.schedule(updateRunnable, 1, SECONDS);
@@ -211,20 +211,20 @@ public class FSInternetRadioHandler extends BaseThingHandler {
                         radio.increaseVolumeAbsolute();
                     } else if (IncreaseDecreaseType.DECREASE.equals(command) || UpDownType.DOWN.equals(command)) {
                         radio.decreaseVolumeAbsolute();
-                    } else if (command instanceof DecimalType) {
-                        radio.setVolumeAbsolute(((DecimalType) command).intValue());
+                    } else if (command instanceof DecimalType decimalCommand) {
+                        radio.setVolumeAbsolute(decimalCommand.intValue());
                     }
                     // percent value should also be updated now, so let's update all items
                     scheduler.schedule(updateRunnable, 1, SECONDS);
                     break;
                 case CHANNEL_MODE:
-                    if (command instanceof DecimalType) {
-                        radio.setMode(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        radio.setMode(decimalCommand.intValue());
                     }
                     break;
                 case CHANNEL_PRESET:
-                    if (command instanceof DecimalType) {
-                        radio.setPreset(((DecimalType) command).intValue());
+                    if (command instanceof DecimalType decimalCommand) {
+                        radio.setPreset(decimalCommand.intValue());
                     }
                     break;
                 case CHANNEL_MUTE:
index 1451af23be9771fb6675b21bfc5df4f180e4a78e..0299f705a7147191477ce9f143729dc93d2e04b9 100644 (file)
@@ -69,8 +69,8 @@ public class FrontierSiliconRadioApiResult {
             logger.trace("converting to XML failed: '{}' with {}: {}", requestResultString, e.getClass().getName(),
                     e.getMessage());
             logger.debug("converting to XML failed with {}: {}", e.getClass().getName(), e.getMessage());
-            if (e instanceof IOException) {
-                throw (IOException) e;
+            if (e instanceof IOException exception) {
+                throw exception;
             }
             throw new IOException(e);
         }
@@ -192,8 +192,7 @@ public class FrontierSiliconRadioApiResult {
      */
     public String getSessionId() {
         final NodeList sessionIdTagList = xmlDoc.getElementsByTagName("sessionId");
-        final String givenSessId = getCharacterDataFromElement((Element) sessionIdTagList.item(0));
-        return givenSessId;
+        return getCharacterDataFromElement((Element) sessionIdTagList.item(0));
     }
 
     /**
@@ -216,8 +215,7 @@ public class FrontierSiliconRadioApiResult {
         factory.setXIncludeAware(false);
         factory.setExpandEntityReferences(false);
         final DocumentBuilder builder = factory.newDocumentBuilder();
-        final Document xmlDocument = builder.parse(new InputSource(new StringReader(xmlString)));
-        return xmlDocument;
+        return builder.parse(new InputSource(new StringReader(xmlString)));
     }
 
     /**
@@ -229,8 +227,7 @@ public class FrontierSiliconRadioApiResult {
      */
     private static String getCharacterDataFromElement(Element e) {
         final Node child = e.getFirstChild();
-        if (child instanceof CharacterData) {
-            final CharacterData cd = (CharacterData) child;
+        if (child instanceof CharacterData cd) {
             return cd.getData();
         }
         return "";
index 7b4b9a1cda77ef54d51bbedb5568b921cce13cea..5f08b267d77a72f12aa3ecf1c140efedecef2c33 100644 (file)
@@ -818,8 +818,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
 
     private boolean isConfigurationComplete(Configuration config) {
         String ip = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_IP);
-        BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString());
-        String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.toString());
+        BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT);
+        String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN);
 
         return !(ip == null || port.compareTo(BigDecimal.ZERO) == 0 || pin == null || pin.isEmpty());
     }
index d2788d0f67c94ae33fc854f10c58739db6948a53..bce18648cea4883e57569a7e09f05b5cb1330cad 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.ftpupload.internal;
 
 import static org.openhab.binding.ftpupload.internal.FtpUploadBindingConstants.THING_TYPE_IMAGERECEIVER;
 
-import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Set;
 
@@ -46,7 +45,7 @@ import org.slf4j.LoggerFactory;
 public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
     private final Logger logger = LoggerFactory.getLogger(FtpUploadHandlerFactory.class);
 
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_IMAGERECEIVER);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_IMAGERECEIVER);
 
     private final int DEFAULT_PORT = 2121;
     private final int DEFAULT_IDLE_TIMEOUT = 60;
index 7f6896b2d855f7a2ca1a45834af8a199df31079c..f0fcad349b50266f01e5a37ae345486d0e76527c 100644 (file)
@@ -21,8 +21,8 @@ import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.time.format.FormatStyle;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -262,7 +262,7 @@ public class GardenaAccountHandler extends BaseBridgeHandler implements GardenaS
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(GardenaDeviceDiscoveryService.class);
+        return Set.of(GardenaDeviceDiscoveryService.class);
     }
 
     @Override
index 1a47ca3fee82549f302c720dadd15c64487c047d..b90b29d50ce64c95a8761f7b560c7cddbb1c346e 100644 (file)
@@ -231,7 +231,7 @@ public class GardenaThingHandler extends BaseThingHandler {
     public void handleCommand(ChannelUID channelUID, Command command) {
         logger.debug("Command received: {}", command);
         try {
-            boolean isOnCommand = command instanceof OnOffType && ((OnOffType) command) == OnOffType.ON;
+            boolean isOnCommand = command instanceof OnOffType onOffCommand && onOffCommand == OnOffType.ON;
             String dataItemProperty = getDeviceDataItemProperty(channelUID);
             if (RefreshType.REFRESH == command) {
                 logger.debug("Refreshing Gardena connection");
index 2eeccf8b7c79e7f254219964ecd56519a4bb6bcf..61b25b3feda5673007cbd42c241b57f4fbffb33f 100644 (file)
@@ -20,7 +20,7 @@ package org.openhab.binding.gardena.internal.model.dto.command;
 public class ValveCommand extends GardenaCommand {
     private static final String COMMAND_TYPE = "VALVE_CONTROL";
 
-    public static enum ValveControl {
+    public enum ValveControl {
         START_SECONDS_TO_OVERRIDE,
         STOP_UNTIL_NEXT_TASK,
         PAUSE,
index 8fd9574c781c6a31507a1772a6ee183e180b1299..e1100de97b9e5cc6e3ba9e0cc09a0726108dc465 100644 (file)
@@ -41,8 +41,8 @@ public class Ipx800Actions implements ThingActions {
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof Ipx800v3Handler) {
-            this.handler = (Ipx800v3Handler) handler;
+        if (handler instanceof Ipx800v3Handler ipx800v3Handler) {
+            this.handler = ipx800v3Handler;
         }
     }
 
index b31e2afb3ffba8af20878a63c52132999e90f95f..79a0217fef23648a2e2a574e1e678a5b527efe9a 100644 (file)
@@ -20,7 +20,6 @@ import java.time.ZonedDateTime;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -327,11 +326,11 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
         if (channel == null || groupId == null) {
             return;
         }
-        if (command instanceof OnOffType && isValidPortId(channelUID)
+        if (command instanceof OnOffType onOffCommand && isValidPortId(channelUID)
                 && PortDefinition.fromGroupId(groupId) == PortDefinition.RELAY) {
             RelayOutputConfiguration config = channel.getConfiguration().as(RelayOutputConfiguration.class);
             String id = channelUID.getIdWithoutGroup();
-            parser.ifPresent(p -> p.setOutput(id, (OnOffType) command == OnOffType.ON ? 1 : 0, config.pulse));
+            parser.ifPresent(p -> p.setOutput(id, onOffCommand == OnOffType.ON ? 1 : 0, config.pulse));
             return;
         }
         logger.debug("Can not handle command '{}' on channel '{}'", command, channelUID);
@@ -351,6 +350,6 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singletonList(Ipx800Actions.class);
+        return List.of(Ipx800Actions.class);
     }
 }
index e8a257d18c28401b38d82e00b2a4d22428fbf0a8..38dbf809aedcf3e69739a03bb0731014b5643113 100644 (file)
@@ -54,7 +54,7 @@ public class M2MMessageParser {
             decodeDataLine(portDefinition, data);
         } else if (VALIDATION_PATTERN.matcher(data).matches()) {
             for (String status : data.split("&")) {
-                String statusPart[] = status.split("=");
+                String[] statusPart = status.split("=");
                 int portNumShift = 1;
                 PortDefinition portDefinition = PortDefinition.fromPortName(statusPart[0].substring(0, 1));
                 switch (portDefinition) {
index f1a636d7cd5d26e5681a935cd6cb5a8dac824eca..421a5cc69678bb95454a60c4d19e462f365f88b7 100644 (file)
@@ -52,9 +52,9 @@ public class StatusFileInterpreter {
 
     private Optional<Document> doc = Optional.empty();
 
-    public static enum StatusEntry {
+    public enum StatusEntry {
         VERSION,
-        CONFIG_MAC;
+        CONFIG_MAC
     }
 
     public StatusFileInterpreter(String hostname, Ipx800EventListener listener) {
index 78c9c55677ce22c6699cec711b08c557fabcd0f4..ce91144df093e9e2b8edcf298cbc908ca7e81c80 100644 (file)
@@ -56,7 +56,7 @@ public class GeneracMobileLinkDiscoveryService extends AbstractDiscoveryService
         DiscoveryResult result = DiscoveryResultBuilder
                 .create(new ThingUID(THING_TYPE_GENERATOR, bridgeUID, String.valueOf(apparatus.apparatusId)))
                 .withLabel("MobileLink Generator " + apparatus.name)
-                .withProperty(Thing.PROPERTY_SERIAL_NUMBER, String.valueOf(apparatus.serialNumber))
+                .withProperty(Thing.PROPERTY_SERIAL_NUMBER, apparatus.serialNumber)
                 .withProperty(PROPERTY_GENERATOR_ID, String.valueOf(apparatus.apparatusId))
                 .withRepresentationProperty(PROPERTY_GENERATOR_ID).withBridge(bridgeUID).build();
         thingDiscovered(result);
index a18c0a2183f853df2005e6043e9fc3144fff782d..09ca46d44e607dd9096147bcd72ffd3c2444b64b 100644 (file)
@@ -73,10 +73,10 @@ public class GeneracMobileLinkAccountHandler extends BaseBridgeHandler {
     private static final String API_BASE = "https://app.mobilelinkgen.com/api";
     private static final String LOGIN_BASE = "https://generacconnectivity.b2clogin.com/generacconnectivity.onmicrosoft.com/B2C_1A_MobileLink_SignIn";
     private static final Pattern SETTINGS_PATTERN = Pattern.compile("^var SETTINGS = (.*);$", Pattern.MULTILINE);
-    private static final Gson GSON = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class,
-            (JsonDeserializer<ZonedDateTime>) (json, type, jsonDeserializationContext) -> {
-                return ZonedDateTime.parse(json.getAsJsonPrimitive().getAsString());
-            }).create();
+    private static final Gson GSON = new GsonBuilder()
+            .registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>) (json, type,
+                    jsonDeserializationContext) -> ZonedDateTime.parse(json.getAsJsonPrimitive().getAsString()))
+            .create();
     private HttpClient httpClient;
     private GeneracMobileLinkDiscoveryService discoveryService;
     private Map<String, Apparatus> apparatusesCache = new HashMap<String, Apparatus>();
@@ -201,7 +201,7 @@ public class GeneracMobileLinkAccountHandler extends BaseBridgeHandler {
             Optional<Thing> thing = getThing().getThings().stream().filter(
                     t -> t.getConfiguration().as(GeneracMobileLinkGeneratorConfiguration.class).generatorId.equals(id))
                     .findFirst();
-            if (!thing.isPresent()) {
+            if (thing.isEmpty()) {
                 discoveryService.generatorDiscovered(apparatus, getThing().getUID());
             } else {
                 ThingHandler handler = thing.get().getHandler();
index a02fbf91a5c8bc6b2642610d28952dc7510d5356..d60993c8de396067a92b9fee0696976f5c1254dd 100644 (file)
@@ -122,7 +122,7 @@ public class GeneracMobileLinkGeneratorHandler extends BaseThingHandler {
             try {
                 if (p.value.signalStrength != null) {
                     updateState(CHANNEL_SIGNAL_STRENGH, new QuantityType<Dimensionless>(
-                            Integer.parseInt(p.value.signalStrength.replaceAll("%", "")), Units.PERCENT));
+                            Integer.parseInt(p.value.signalStrength.replace("%", "")), Units.PERCENT));
                 }
             } catch (NumberFormatException e) {
                 logger.debug("Could not parse signalStrength {}", p.value.signalStrength);
index 314abb1a836e5442f434cedfaf8e61cd8327e183..625bd531142aa4c9180084c88e00cfd65c01302d 100644 (file)
@@ -54,7 +54,7 @@ public class CommandGetserial extends AbstractCommand {
             return;
         }
 
-        String fields[] = deviceReply.split(",");
+        String[] fields = deviceReply.split(",");
         if (fields.length != 5) {
             return;
         }
index aed0f493fff54291ce9f02e9a339caa49816a1db..515be914c98bc201929a1f72a0941d7a56687330 100644 (file)
@@ -38,7 +38,7 @@ public class CommandSendir extends AbstractCommand {
         super(thing, queue, "sendir", CommandType.COMMAND);
 
         this.command = command;
-        deviceCommand = "sendir," + mod + ":" + con + "," + String.valueOf(sendCounter) + "," + code;
+        deviceCommand = "sendir," + mod + ":" + con + "," + sendCounter + "," + code;
     }
 
     @Override
index 02b90ddd31bb729163932d9cc99d692e40a70563..bd284a4b4b487f01a704cc760f6ee8ef44c26938 100644 (file)
@@ -34,7 +34,7 @@ public class CommandSendserial extends AbstractCommand {
             String con, String code) {
         super(thing, queue, "sendserial", CommandType.SERIAL1);
         // Check to see if this is for the second serial port on a GC-100-12
-        if (isGC100Model12() && mod.equals("2")) {
+        if (isGC100Model12() && "2".equals(mod)) {
             setCommandType(CommandType.SERIAL2);
         }
         this.command = command;
index 55ec19c2de652e539162e74b2b09a538e2c50a02..237971565a0b76b675454380e76d81d128792877 100644 (file)
@@ -55,7 +55,7 @@ public class CommandSetserial extends AbstractCommand {
             return;
         }
 
-        String fields[] = deviceReply.split(",");
+        String[] fields = deviceReply.split(",");
         if (fields.length != 5) {
             return;
         }
index eaf5ee7f0400f09b5422d801ea19f58cfaed4d78..07fc4045bfc1140de7c3e6cfe971c799beb49ca5 100644 (file)
@@ -69,7 +69,7 @@ public class CommandSetstate extends AbstractCommand {
             if (m.groupCount() == 4) {
                 setModule(m.group(2));
                 setConnector(m.group(3));
-                setState(m.group(4).equals("0") ? OnOffType.OFF : OnOffType.ON);
+                setState("0".equals(m.group(4)) ? OnOffType.OFF : OnOffType.ON);
                 return true;
             }
         }
index a56c65c3946b9c23739f0dd9b90f8deb47b83eec..051eb041a1035a11a8a74a66052c71fbc0177161 100644 (file)
@@ -310,7 +310,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
             throw new HexCodeConversionException("Hex code is too short");
         }
 
-        if (!hexCodeArray[0].equals("0000")) {
+        if (!"0000".equals(hexCodeArray[0])) {
             throw new HexCodeConversionException("Illegal hex code element 0, should be 0000");
         }
 
index c7d80ac9f2d60be9e7d6c6d3f45cd448c1685d47..b12faee0a79f60be2eaf85deee8f51994fe4d539 100644 (file)
@@ -14,7 +14,6 @@ package org.openhab.binding.goecharger.internal;
 
 import static org.openhab.binding.goecharger.internal.GoEChargerBindingConstants.*;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference;
 @NonNullByDefault
 @Component(configurationPid = "binding.goecharger", service = ThingHandlerFactory.class)
 public class GoEChargerHandlerFactory extends BaseThingHandlerFactory {
-    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_GOE);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_GOE);
     private final HttpClient httpClient;
 
     @Activate
index 1ec1bb9cd8b68fd2b5bce239b9b7d42cca0816c4..6d2bdb26972857a5d0e255edff12320c0cfb07dc 100644 (file)
@@ -254,16 +254,16 @@ public class GoEChargerHandler extends GoEChargerBaseHandler {
         switch (channelUID.getId()) {
             case MAX_CURRENT:
                 key = "amp";
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue());
                 } else if (command instanceof QuantityType<?>) {
                     value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
                 }
                 break;
             case MAX_CURRENT_TEMPORARY:
                 key = "amx";
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue());
                 } else if (command instanceof QuantityType<?>) {
                     value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
                 }
@@ -271,8 +271,8 @@ public class GoEChargerHandler extends GoEChargerBaseHandler {
             case SESSION_CHARGE_CONSUMPTION_LIMIT:
                 key = "dwo";
                 var multiplier = 10;
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue() * multiplier);
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue() * multiplier);
                 } else if (command instanceof QuantityType<?>) {
                     value = String.valueOf(
                             ((QuantityType<Energy>) command).toUnit(Units.KILOWATT_HOUR).intValue() * multiplier);
index 1056663cf6f9a0df24df39acf5d419b3728c22ed..b48a93fbf13e95c7519ca39dc70bc3d727a5b954 100644 (file)
@@ -143,7 +143,7 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
                 }
                 return new DecimalType(goeResponse.transaction);
             case ALLOW_CHARGING:
-                return goeResponse.allowCharging == true ? OnOffType.ON : OnOffType.OFF;
+                return goeResponse.allowCharging ? OnOffType.ON : OnOffType.OFF;
             case TEMPERATURE_TYPE2_PORT:
                 // It was reported that the temperature is invalid when only one value is returned
                 // That's why it is checked that at least 2 values are returned
@@ -244,8 +244,8 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
         switch (channelUID.getId()) {
             case MAX_CURRENT:
                 key = "amp";
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue());
                 } else if (command instanceof QuantityType<?>) {
                     value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
                 }
@@ -253,8 +253,8 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
             case SESSION_CHARGE_CONSUMPTION_LIMIT:
                 key = "dwo";
                 var multiplier = 1000;
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue() * multiplier);
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue() * multiplier);
                 } else if (command instanceof QuantityType<?>) {
                     value = String.valueOf(
                             ((QuantityType<Energy>) command).toUnit(Units.KILOWATT_HOUR).intValue() * multiplier);
@@ -262,10 +262,9 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
                 break;
             case PHASES:
                 key = "psm";
-                if (command instanceof DecimalType) {
+                if (command instanceof DecimalType decimalCommand) {
                     var phases = 1;
-                    var help = (DecimalType) command;
-                    if (help.intValue() == 3) {
+                    if (decimalCommand.intValue() == 3) {
                         // set value 2 for 3 phases
                         phases = 2;
                     }
@@ -274,14 +273,14 @@ public class GoEChargerV2Handler extends GoEChargerBaseHandler {
                 break;
             case FORCE_STATE:
                 key = "frc";
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue());
                 }
                 break;
             case TRANSACTION:
                 key = "trx";
-                if (command instanceof DecimalType) {
-                    value = String.valueOf(((DecimalType) command).intValue());
+                if (command instanceof DecimalType decimalCommand) {
+                    value = String.valueOf(decimalCommand.intValue());
                 }
                 break;
         }
index 446ebd626e60573ab0844022c258ab660c754be2..c1c83af761ff5b569ff9efa2b8e48f7ceabc19a8 100644 (file)
@@ -48,11 +48,11 @@ public class NotificationHandler {
     public void handleNotification(LocationMessage msg) {
         synchronized (this) {
             String trackerId = msg.getTrackerId();
-            if (msg instanceof TransitionMessage) {
+            if (msg instanceof TransitionMessage message) {
                 List<TransitionMessage> transitionMessages = transitionNotifications.computeIfAbsent(trackerId,
                         k -> new ArrayList<>());
                 if (transitionMessages != null) {
-                    transitionMessages.add((TransitionMessage) msg);
+                    transitionMessages.add(message);
                 }
             } else {
                 locationNotifications.put(trackerId, msg);
index c92b75fca0a92bdc137e47459e330dce46b0906f..a5aee9df6f21e5b0239cbcc64c1b3f844bfecb4d 100644 (file)
@@ -120,9 +120,8 @@ public abstract class AbstractCallbackServlet extends HttpServlet {
         if (!trackerId.isEmpty()) {
             TrackerHandler recorder = getHandlerById(trackerId);
             if (recorder != null) {
-                if (message instanceof TransitionMessage) {
-                    TransitionMessage tm = (TransitionMessage) message;
-                    recorder.doTransition(tm);
+                if (message instanceof TransitionMessage transitionMessage) {
+                    recorder.doTransition(transitionMessage);
                 } else {
                     recorder.updateLocation(message);
                 }
index 43421f98fa26b5d2d6639c9079d4fb4e16c961d7..acd0a1e701d7bd6aebb19f49a14228f204f8fcde 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.gree.internal;
 
-import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -31,7 +30,7 @@ public class GreeBindingConstants {
     public static final String BINDING_ID = "gree";
 
     public static final ThingTypeUID THING_TYPE_GREEAIRCON = new ThingTypeUID(BINDING_ID, "airconditioner");
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_GREEAIRCON);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_GREEAIRCON);
 
     // List of all Thing Type UIDs
     public static final ThingTypeUID GREE_THING_TYPE = new ThingTypeUID(BINDING_ID, "airconditioner");
index d3906679363e4749e6ec1812c00cb16cb29a828e..bdcc415dc54a2fa3a584249a916100614bc52c79 100644 (file)
@@ -111,7 +111,7 @@ public class GreeDeviceFinder {
                     scanResponseGson.packJson = GSON.fromJson(decryptedMsg, GreeScanReponsePackDTO.class);
 
                     // Now make sure the device is reported as a Gree device
-                    if (scanResponseGson.packJson.brand.equalsIgnoreCase("gree")) {
+                    if ("gree".equalsIgnoreCase(scanResponseGson.packJson.brand)) {
                         // Create a new GreeDevice
                         logger.debug("Discovered device at {}:{}", remoteAddress.getHostAddress(), remotePort);
                         GreeAirDevice newDevice = new GreeAirDevice(remoteAddress, remotePort, scanResponseGson);
index 66dc1e69bdd8179620b75325a735658591a0e277..621f31af4f066b89ab5f44ae21e3b30e86698ade 100644 (file)
@@ -21,7 +21,6 @@ import java.net.InetAddress;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -370,8 +369,7 @@ public class GreeAirDevice {
             int valueArrayposition = colList.indexOf(valueName);
             if (valueArrayposition != -1) {
                 // get the Corresponding value
-                Integer value = valList.get(valueArrayposition);
-                return value;
+                return valList.get(valueArrayposition);
             }
         }
 
@@ -384,7 +382,7 @@ public class GreeAirDevice {
     }
 
     public boolean hasStatusValChanged(String valueName) throws GreeException {
-        if (!prevStatusResponsePackGson.isPresent()) {
+        if (prevStatusResponsePackGson.isEmpty()) {
             return true; // update value if there is no previous one
         }
         // Find the valueName in the Current Status object
@@ -442,7 +440,7 @@ public class GreeAirDevice {
     }
 
     private void setCommandValue(DatagramSocket clientSocket, String command, int value) throws GreeException {
-        executeCommand(clientSocket, Collections.singletonMap(command, value));
+        executeCommand(clientSocket, Map.of(command, value));
     }
 
     private void setCommandValue(DatagramSocket clientSocket, String command, int value, int min, int max)
@@ -450,7 +448,7 @@ public class GreeAirDevice {
         if ((value < min) || (value > max)) {
             throw new GreeException("Command value out of range!");
         }
-        executeCommand(clientSocket, Collections.singletonMap(command, value));
+        executeCommand(clientSocket, Map.of(command, value));
     }
 
     private DatagramPacket createPackRequest(int i, String pack) {
@@ -462,8 +460,7 @@ public class GreeAirDevice {
         request.tcid = getId();
         request.pack = pack;
         byte[] sendData = GSON.toJson(request).getBytes(StandardCharsets.UTF_8);
-        DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, ipAddress, port);
-        return sendPacket;
+        return new DatagramPacket(sendData, sendData.length, ipAddress, port);
     }
 
     private <T> T receiveResponse(DatagramSocket clientSocket, Class<T> classOfT)
index ca364da209589db093763be0c048df1e7954bb02..6e809b4efd11c742d314e329fec05c30eac99fed 100644 (file)
@@ -103,7 +103,7 @@ public class GreeHandler extends BaseThingHandler {
     private void initializeThing() {
         String message = "";
         try {
-            if (!clientSocket.isPresent()) {
+            if (clientSocket.isEmpty()) {
                 clientSocket = Optional.of(new DatagramSocket());
                 clientSocket.get().setSoTimeout(DATAGRAM_SOCKET_TIMEOUT);
             }
@@ -224,9 +224,9 @@ public class GreeHandler extends BaseThingHandler {
         int mode = -1;
         String modeStr = "";
         boolean isNumber = false;
-        if (command instanceof DecimalType) {
+        if (command instanceof DecimalType decimalCommand) {
             // backward compatibility when channel was Number
-            mode = ((DecimalType) command).intValue();
+            mode = decimalCommand.intValue();
         } else if (command instanceof OnOffType) {
             // Switch
             logger.debug("{}: Send Power-{}", thingId, command);
@@ -295,8 +295,8 @@ public class GreeHandler extends BaseThingHandler {
 
     private void handleQuietCommand(DatagramSocket socket, Command command) throws GreeException {
         int mode = -1;
-        if (command instanceof DecimalType) {
-            mode = ((DecimalType) command).intValue();
+        if (command instanceof DecimalType decimalCommand) {
+            mode = decimalCommand.intValue();
         } else if (command instanceof StringType) {
             switch (command.toString().toLowerCase()) {
                 case QUIET_OFF:
@@ -321,8 +321,8 @@ public class GreeHandler extends BaseThingHandler {
         if (command instanceof OnOffType) {
             return command == OnOffType.ON ? 1 : 0;
         }
-        if (command instanceof DecimalType) {
-            int value = ((DecimalType) command).intValue();
+        if (command instanceof DecimalType decimalCommand) {
+            int value = decimalCommand.intValue();
             if ((value == 0) || (value == 1)) {
                 return value;
             }
@@ -331,22 +331,22 @@ public class GreeHandler extends BaseThingHandler {
     }
 
     private int getNumber(Command command) {
-        if (command instanceof DecimalType) {
-            return ((DecimalType) command).intValue();
+        if (command instanceof DecimalType decimalCommand) {
+            return decimalCommand.intValue();
         }
         throw new IllegalArgumentException("Invalid Number type");
     }
 
     private QuantityType<?> convertTemp(Command command) {
-        if (command instanceof DecimalType) {
+        if (command instanceof DecimalType temperature) {
             // The Number alone doesn't specify the temp unit
             // for this get current setting from the A/C unit
             int unit = device.getIntStatusVal(GREE_PROP_TEMPUNIT);
-            return toQuantityType((DecimalType) command, DIGITS_TEMP,
+            return toQuantityType(temperature, DIGITS_TEMP,
                     unit == TEMP_UNIT_CELSIUS ? SIUnits.CELSIUS : ImperialUnits.FAHRENHEIT);
         }
-        if (command instanceof QuantityType) {
-            return (QuantityType<?>) command;
+        if (command instanceof QuantityType quantityCommand) {
+            return quantityCommand;
         }
         throw new IllegalArgumentException("Invalud Temp type");
     }
index 1a9ae66ed3c9690e5043e7329d1a19ae6613404d..5d4b342ae6b3a00740dd025b90cb6149a33d5efd 100644 (file)
@@ -153,7 +153,7 @@ public class GroheOndusSenseGuardHandler<T, M> extends GroheOndusBaseHandler<App
             logger.debug("Could not get appliance command", e);
             return null;
         }
-        if (!commandOptional.isPresent()) {
+        if (commandOptional.isEmpty()) {
             return null;
         }
         if (commandOptional.get().getType() != Appliance.TYPE) {
index 624257ae9d71769e2e1926c2687af42be2649ad7..8d982ee39c50db6ed9586a78af28065599e3ff70 100644 (file)
@@ -130,7 +130,7 @@ public class GroheOndusSenseHandler<T, M> extends GroheOndusBaseHandler<Applianc
         Optional<ApplianceStatus> applianceStatusOptional;
         try {
             applianceStatusOptional = ondusService.applianceStatus(appliance);
-            if (!applianceStatusOptional.isPresent()) {
+            if (applianceStatusOptional.isEmpty()) {
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "@text/error.empty.response");
                 return null;
             }
index 5a830e158935cd1d8d92c3f2a29b56d24bd26936..9f0decd6a484d5b0dfaa9feaab5cc65aa95305b2 100644 (file)
@@ -16,7 +16,6 @@ import static org.openhab.binding.groupepsa.internal.GroupePSABindingConstants.T
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
@@ -53,7 +52,7 @@ import org.openhab.core.types.Command;
  */
 @NonNullByDefault
 public class GroupePSABridgeHandler 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 long DEFAULT_POLLING_INTERVAL_M = TimeUnit.HOURS.toMinutes(1);
 
     private final OAuthFactory oAuthFactory;
@@ -229,6 +228,6 @@ public class GroupePSABridgeHandler extends BaseBridgeHandler {
 
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
-        return Collections.singleton(GroupePSADiscoveryService.class);
+        return Set.of(GroupePSADiscoveryService.class);
     }
 }
index ae0a0cbdd9f0a7b9be288aac800da65af4c1daab..ee42a5836dbe91e0ee6baf307d3ae7d03dd8ab4b 100644 (file)
@@ -14,10 +14,10 @@ package org.openhab.binding.groupepsa.internal.discovery;
 
 import static org.openhab.binding.groupepsa.internal.GroupePSABindingConstants.THING_TYPE_VEHICLE;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -50,13 +50,13 @@ public class GroupePSADiscoveryService extends AbstractDiscoveryService implemen
     private @Nullable GroupePSABridgeHandler bridgeHandler;
 
     public GroupePSADiscoveryService() {
-        super(Collections.singleton(THING_TYPE_VEHICLE), 10, false);
+        super(Set.of(THING_TYPE_VEHICLE), 10, false);
     }
 
     @Override
     public void setThingHandler(@Nullable ThingHandler handler) {
-        if (handler instanceof GroupePSABridgeHandler) {
-            bridgeHandler = (GroupePSABridgeHandler) handler;
+        if (handler instanceof GroupePSABridgeHandler bridgeHandler) {
+            this.bridgeHandler = bridgeHandler;
         }
     }
 
index 06b9d21f10323449f4c40c6fd566756d5d424c8f..3eb3d558f83368d80a408b1b93e799891d119e40 100644 (file)
@@ -196,8 +196,6 @@ public class GroupePSAConnectApi {
 
     public @Nullable VehicleStatus getVehicleStatus(String vin) throws GroupePSACommunicationException {
         ContentResponse responseOdometer = executeRequest(getBaseUrl() + "/user/vehicles/" + vin + "/status");
-        VehicleStatus status = parseResponse(responseOdometer, VehicleStatus.class);
-
-        return status;
+        return parseResponse(responseOdometer, VehicleStatus.class);
     }
 }
index e3dc71b2ebc4a2099fc23c9e9e9410309c1382d3..8fe61bab4db3e1be1ac1c201af630d30290da4ac 100644 (file)
@@ -165,8 +165,8 @@ public class GroupePSAHandler extends BaseThingHandler {
         Bridge bridge = getBridge();
         if (bridge != null) {
             ThingHandler handler = bridge.getHandler();
-            if (handler instanceof GroupePSABridgeHandler) {
-                return (GroupePSABridgeHandler) handler;
+            if (handler instanceof GroupePSABridgeHandler bridgeHandler) {
+                return bridgeHandler;
             }
         }
         return null;