]> git.basschouten.com Git - openhab-addons.git/commitdiff
[enocean] Add null annotations (#14023)
authorlsiepel <leosiepel@gmail.com>
Tue, 28 Mar 2023 09:05:37 +0000 (11:05 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 09:05:37 +0000 (11:05 +0200)
* mainly null annotations

Signed-off-by: lsiepel <leosiepel@gmail.com>
* checkstyle fixes

Signed-off-by: lsiepel <leosiepel@gmail.com>
* another checkstyle pass

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Fix review comments

Signed-off-by: lsiepel <leosiepel@gmail.com>
* fix  most review comments

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Generic => temp_generic

Signed-off-by: lsiepel <leosiepel@gmail.com>
* temp_generic => generic

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Generic fix try 2

Signed-off-by: lsiepel <leosiepel@gmail.com>
* another generic commit

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Final pass for changing generic packages/folder

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Mised comment

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Conflict folder change trial 1

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Conflict folder change final

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Conflict folder change trial 2

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Move folder

Signed-off-by: lsiepel <leosiepel@gmail.com>
* Review comment

Signed-off-by: lsiepel <leosiepel@gmail.com>
---------

Signed-off-by: lsiepel <leosiepel@gmail.com>
212 files changed:
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanBindingConstants.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanChannelDescription.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanConfigStatusMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanException.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanHandlerFactory.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/Helper.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanActuatorConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanBridgeConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelContactConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelDimmerConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelRockerSwitchConfigBase.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelRockerSwitchListenerConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelRollershutterConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelTariffInfoConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelTeachInConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelTotalusageConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelTransformationConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanChannelVirtualRockerSwitchConfig.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/config/EnOceanProfileRockerSwitchActionConfig.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/discovery/EnOceanUsbSerialDiscoveryParticipant.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_05.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_06.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_07.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_08.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_09.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_0A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_0B.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_10.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_11.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_12.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_13.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_14.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_15.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_16.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_17.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_18.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_19.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_1A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_1B.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_20.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_02/A5_02_30.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_04/A5_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_04/A5_04_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_04/A5_04_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_04/A5_04_02_Eltako.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_04/A5_04_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_06/A5_06_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_06/A5_06_01_ELTAKO.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_07/A5_07.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_07/A5_07_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_07/A5_07_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_07/A5_07_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_08/A5_08.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_08/A5_08_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_08/A5_08_01_FXBH.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_08/A5_08_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_08/A5_08_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_05.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_06.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_07.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_08.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_09.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_0A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_0B.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_0C.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_0D.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_10.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_11.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_12.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_13.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_14.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_15.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_16.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_17.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_18.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_19.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1B.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1C.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1D.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1E.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_1F.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_20.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_21.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_22.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10_23.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_11/A5_11_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_11/A5_11_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_12/A5_12.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_12/A5_12_00.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_12/A5_12_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_12/A5_12_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_12/A5_12_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_13/A5_13.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_13/A5_13_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_14/A5_14.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_14/A5_14_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_14/A5_14_01_ELTAKO.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_14/A5_14_09.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_14/A5_14_0A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_20/A5_20.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_30/A5_30_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/A5_30/A5_30_03_ELTAKO.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_38/A5_38_08_Switching.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/A5_3F/A5_3F_7F_Universal.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/PTM200Message.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/UTEResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_1BSMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_4BSMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_4BSTeachInVariation3Response.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_RPSMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_SIGMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Base/_VLDMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D0/D0_06.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_00.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_03.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_04.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_05.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_06.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_07.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_08.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_09.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_0A.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0B.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0C.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0D.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0E.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0F.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_11.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_12.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_03/D2_03_0A.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_06/D2_06_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_06/D2_06_50.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_14/D2_14_30.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/D5_00/D5_00_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEP.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/EEPHelper.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_01/F6_01_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_02/F6_02.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/eep/F6_05/F6_05_02.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_10/F6_10_00.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_10/F6_10_00_EltakoFPE.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/F6_10/F6_10_01.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/Generic4BS.java [deleted file]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericEEP.java [deleted file]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericRPS.java [deleted file]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericVLD.java [deleted file]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/Generic4BS.java [new file with mode: 0644]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericEEP.java [new file with mode: 0644]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericRPS.java [new file with mode: 0644]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericVLD.java [new file with mode: 0644]
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseActuatorHandler.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/handler/EnOceanBaseSensorHandler.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/BasePacket.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/CCMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/ERP1Message.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/ESP2PacketConverter.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/ESP3Packet.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/ESP3PacketFactory.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/EventMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Response.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/BaseResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/RDBaseIdResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/RDLearnedClientsResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/RDRepeaterResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/RDVersionResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/Responses/SMACKTeachInResponse.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/messages/SAMessage.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/profiles/EnOceanProfileFactory.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/profiles/RockerSwitchActionBaseProfile.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/EnOceanESP2Transceiver.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/EnOceanESP3Transceiver.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/EnOceanTransceiver.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/EventListener.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/PacketListener.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/ResponseListener.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/ResponseListenerIgnoringTimeouts.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/TeachInListener.java
bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/transceiver/TransceiverErrorListener.java

index 77f6a3b0dfd50bb26b184c27e72cec897b125a06..5bcae336afdb08a0979133d373976b59bfec1728 100644 (file)
@@ -576,7 +576,7 @@ public class EnOceanBindingConstants {
 
     // Bridge properties
     public static final String PROPERTY_BASE_ID = "Base ID";
-    public static final String PROPERTY_REMAINING_WRITE_CYCLES_Base_ID = "Remaining Base ID Write Cycles";
+    public static final String PROPERTY_REMAINING_WRITE_CYCLES_BASE_ID = "Remaining Base ID Write Cycles";
     public static final String PROPERTY_APP_VERSION = "APP Version";
     public static final String PROPERTY_API_VERSION = "API Version";
     public static final String PROPERTY_CHIP_ID = "Chip ID";
@@ -594,9 +594,9 @@ public class EnOceanBindingConstants {
     public static final String PARAMETER_ENOCEANID = "enoceanId";
 
     // Channel config parameter
-    public static final String PARAMETER_CHANNEL_TeachInMSG = "teachInMSG";
-    public static final String PARAMETER_CHANNEL_Duration = "duration";
-    public static final String PARAMETER_CHANNEL_SwitchMode = "switchMode";
+    public static final String PARAMETER_CHANNEL_TEACHINMSG = "teachInMSG";
+    public static final String PARAMETER_CHANNEL_DURATION = "duration";
+    public static final String PARAMETER_CHANNEL_SWITCHMODE = "switchMode";
 
     // Manufacturer Ids - used to recognize special EEPs during auto discovery
     public static final int ELTAKOID = 0x00d;
index dcbaa2cfdf161b7a6a195dce281bc771c7f10aea..ca06c0cd07a5375ea698c687ac8d4b8fd6dd46c0 100644 (file)
@@ -12,7 +12,8 @@
  */
 package org.openhab.binding.enocean.internal;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.thing.type.ChannelTypeUID;
 
 /**
@@ -21,10 +22,10 @@ import org.openhab.core.thing.type.ChannelTypeUID;
  *         This class holds information for creating a channel of an EnOcean thing like acceptedItemType and
  *         channelTypeUID
  */
+@NonNullByDefault
 public class EnOceanChannelDescription {
     public final ChannelTypeUID channelTypeUID;
     public final String acceptedItemType;
-    @NonNull
     public final String label;
     public final boolean isStateChannel;
     public final boolean autoCreate;
@@ -49,15 +50,11 @@ public class EnOceanChannelDescription {
      * @param autoCreate create channel during thing initialization, otherwise channel is created
      *            manually/predefined
      */
-    public EnOceanChannelDescription(ChannelTypeUID channelTypeUID, String itemType, String label,
+    public EnOceanChannelDescription(ChannelTypeUID channelTypeUID, @Nullable String itemType, @Nullable String label,
             boolean isStateChannel, boolean autoCreate) {
         this.channelTypeUID = channelTypeUID;
-        this.acceptedItemType = itemType;
-        if (label != null) {
-            this.label = label;
-        } else {
-            this.label = "";
-        }
+        this.acceptedItemType = itemType != null ? itemType : "";
+        this.label = label != null ? label : "";
 
         this.isStateChannel = isStateChannel;
         this.autoCreate = autoCreate;
index d9d755e97d251923ab3884ba5b2f53edd1df82e2..f877090a48aa94d81428e46852a8f9c2a914caa8 100644 (file)
  */
 package org.openhab.binding.enocean.internal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public enum EnOceanConfigStatusMessage {
     PORT_MISSING("missing-port-configuration"),
     SENDERID_MISSING("missing-senderId-configuration"),
index bbff240cf4e059dc5e5e4b09508211ae2f5fb6b8..1faca0043d38fe7e9906fbad2d9ab1b34f1816ef 100644 (file)
  */
 package org.openhab.binding.enocean.internal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanException extends Exception {
 
     /**
@@ -23,7 +27,7 @@ public class EnOceanException extends Exception {
      */
     private static final long serialVersionUID = 1L;
 
-    public EnOceanException(String msg) {
+    public EnOceanException(@Nullable String msg) {
         super(msg);
     }
 }
index 11364186498e927491d3cb15d6a2f35086a81a05..48aa03cfa0fed26be8d6c504e3e0d0f835f92fda 100644 (file)
@@ -19,6 +19,8 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.discovery.EnOceanDeviceDiscoveryService;
 import org.openhab.binding.enocean.internal.handler.EnOceanBaseActuatorHandler;
 import org.openhab.binding.enocean.internal.handler.EnOceanBaseSensorHandler;
@@ -36,6 +38,7 @@ import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.thing.binding.ThingHandlerFactory;
 import org.openhab.core.thing.link.ItemChannelLinkRegistry;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 
@@ -45,6 +48,7 @@ import org.osgi.service.component.annotations.Reference;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.enocean")
 public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
 
@@ -55,14 +59,19 @@ public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
 
     private Map<ThingUID, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>();
 
-    @Reference
-    SerialPortManager serialPortManager;
+    private final SerialPortManager serialPortManager;
+    private final ThingManager thingManager;
+    private final ItemChannelLinkRegistry itemChannelLinkRegistry;
 
-    @Reference
-    ItemChannelLinkRegistry itemChannelLinkRegistry;
-
-    @Reference
-    ThingManager thingManager;
+    @Activate
+    public EnOceanHandlerFactory(final @Reference SerialPortManager serialPortManager,
+            final @Reference ThingManager thingManager,
+            final @Reference ItemChannelLinkRegistry itemChannelLinkRegistry) {
+        // Obtain references to thes service using an OSGi reference
+        this.serialPortManager = serialPortManager;
+        this.thingManager = thingManager;
+        this.itemChannelLinkRegistry = itemChannelLinkRegistry;
+    }
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
@@ -70,9 +79,8 @@ public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
     }
 
     @Override
-    protected ThingHandler createHandler(Thing thing) {
+    protected @Nullable ThingHandler createHandler(Thing thing) {
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
-
         if (EnOceanBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
             EnOceanBridgeHandler bridgeHandler = new EnOceanBridgeHandler((Bridge) thing, serialPortManager);
             registerDeviceDiscoveryService(bridgeHandler);
@@ -90,12 +98,10 @@ public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected void removeHandler(ThingHandler thingHandler) {
-        if (this.discoveryServiceRegs != null) {
-            ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
-            if (serviceReg != null) {
-                serviceReg.unregister();
-                discoveryServiceRegs.remove(thingHandler.getThing().getUID());
-            }
+        ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
+        if (serviceReg != null) {
+            serviceReg.unregister();
+            discoveryServiceRegs.remove(thingHandler.getThing().getUID());
         }
     }
 
index be93505c6da7635ec92550a495306fc1301ea270..6420e8d6874c6ca923b9b77f0b589b13a9312e0d 100644 (file)
@@ -14,14 +14,17 @@ package org.openhab.binding.enocean.internal;
 
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class Helper {
 
     public static byte[] concatAll(byte[] a, byte[]... rest) {
-        if (rest == null) {
+        if (rest.length == 0) {
             return a;
         }
 
@@ -40,7 +43,7 @@ public class Helper {
                 offset += array.length;
             }
         }
-        return result;
+        return result != null ? result : new byte[0];
     }
 
     public static int tryParseInt(String value, int defaultValue) {
index 942962d0f7951d698c4560f4abcc510231fe0538..4b528e1f47a6a382fc0ed866614761a0e6940970 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanActuatorConfig extends EnOceanBaseConfig {
 
     public int channel;
-    public Integer senderIdOffset = null;
-    public String manufacturerId;
-    public String teachInType;
+    public @Nullable Integer senderIdOffset = null;
+    public String manufacturerId = "";
+    public String teachInType = "";
 
-    public String sendingEEPId;
+    public String sendingEEPId = "";
 
     public int pollingInterval;
 
index d8f37866a709d8bfe57ccef4cad8fe4d84bd0509..565954a8a6d18430cc3958de435a8b718c05e639 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanBridgeConfig {
 
     public enum ESPVersion {
@@ -40,24 +44,17 @@ public class EnOceanBridgeConfig {
         }
     }
 
-    public String path;
+    public String path = "";
 
-    public String espVersion;
+    public String espVersion = "ESP3";
     public boolean rs485;
-    public String rs485BaseId;
+    public String rs485BaseId = "";
 
-    public Integer nextSenderId;
+    public @Nullable Integer nextSenderId;
 
-    public boolean enableSmack;
+    public boolean enableSmack = true;
     public boolean sendTeachOuts;
 
-    public EnOceanBridgeConfig() {
-        espVersion = "ESP3";
-        sendTeachOuts = false;
-        enableSmack = true;
-        nextSenderId = null;
-    }
-
     public ESPVersion getESPVersion() {
         return ESPVersion.getESPVersion(espVersion);
     }
index 45fb2723976d04d9f60feff2c63e758722ca2a18..e500dbfa9b291098e9408e6c8401021976cab3ae 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Holger Englert - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelContactConfig {
     // Swap Open/Closed value, e.g.
     // Eltako FPE-1: false, Eltako FPE-2: true
index d6b77d46fa5926003b47d86cadd24c8429cff1b9..26517cc7dcaedae8eb22153f4f0397b464db6c98 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelDimmerConfig {
 
     public int rampingTime = 0;
index e86b8b18fdfbf7ea78525f3109ad3c3ae50ba404..99da566e0a403ddd3ab965b62556207256cdd4a8 100644 (file)
@@ -14,10 +14,14 @@ package org.openhab.binding.enocean.internal.config;
 
 import java.security.InvalidParameterException;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelRockerSwitchConfigBase {
 
     public String switchMode;
@@ -39,7 +43,7 @@ public class EnOceanChannelRockerSwitchConfigBase {
             return value;
         }
 
-        public static SwitchMode getSwitchMode(String value) {
+        public static SwitchMode getSwitchMode(@Nullable String value) {
             if (value == null) {
                 return SwitchMode.Unkown;
             }
@@ -65,7 +69,7 @@ public class EnOceanChannelRockerSwitchConfigBase {
             this.value = value;
         }
 
-        public static Channel getChannel(String value) {
+        public static Channel getChannel(@Nullable String value) {
             if (value == null) {
                 return Channel.Unkown;
             }
index d18c31a89b3e822e396b3af34efd21e267492b88..0e834d49c14fe1825cbeae9e2a0b3536b0a20aed 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelRockerSwitchListenerConfig extends EnOceanChannelRockerSwitchConfigBase {
 
-    public String enoceanId;
-    public boolean handleSecondAction;
+    public String enoceanId = "";
+    public boolean handleSecondAction = false;
 
     public EnOceanChannelRockerSwitchListenerConfig() {
         super();
-        enoceanId = null;
-        handleSecondAction = false;
     }
 }
index 6fb521d67390a96782569a09112f1be582718c43..39753ff2375c71e5fb0949d5c095cffca5e47ffd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelRollershutterConfig {
 
     public int shutTime;
index 9362de2918f8ddd1951f3483cf24df9dd831e9b0..fcea43c6c99ef0bd556cb17a378329038ab1a77b 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelTariffInfoConfig {
     public int tariff = 0;
 }
index 59a33974d124a5c3dcb78a46346c5646b09d4aa5..145ace49a5f8150b4a45dd4292a6ecd2090cb7cb 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelTeachInConfig {
 
-    public String teachInMSG;
-    public String manufacturerId;
+    public String teachInMSG = "";
+    public String manufacturerId = "";
 }
index 3145172655f7913c4f11dba649f2982f2fc880ba..d68c3dfb94e05da4f6589fe9becce3a68b7db2da 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Dominik Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelTotalusageConfig {
     public boolean validateValue = false;
 }
index eb7712e29bdfc3dd2c4010f8f478f866adeca190..5628e6f0e6c4950cd2c9ca4b001390c9c3f9cb06 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.config.core.Configuration;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelTransformationConfig extends Configuration {
 
-    public String transformationType;
-    public String transformationFunction;
+    public String transformationType = "";
+    public String transformationFunction = "";
 
     public EnOceanChannelTransformationConfig() {
-        put("transformationType", "");
-        put("transformationFunction", "");
+        put("transformationType", transformationType);
+        put("transformationFunction", transformationFunction);
     }
 }
index b4a5bf1fb18b6efeefe47764edd7bcb82ea52d2e..880b01cff950d76daad6c16f388adc4ddaf16506 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanChannelVirtualRockerSwitchConfig extends EnOceanChannelRockerSwitchConfigBase {
 
     public Integer duration;
index 6985fc29e537fe175e7dfc5e86c98e88531740a1..5f125ab505c0c7fab00d16dcfb90136d8c3d475f 100644 (file)
  */
 package org.openhab.binding.enocean.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * This {@link EnOceanProfileRockerSwitchActionConfig} config class is used for rockerSwitchAction profiles to define in
  * which case it should react.
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanProfileRockerSwitchActionConfig {
 
     public String channelAFilter;
index 52546501aca8a64de61ee6f62ca94361c58fe087..6d0af65ece358565a4b02b5e80c861a9a014412b 100644 (file)
@@ -17,6 +17,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base.UTEResponse;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.eep.EEP;
@@ -27,7 +29,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
 import org.openhab.binding.enocean.internal.messages.EventMessage;
 import org.openhab.binding.enocean.internal.messages.EventMessage.EventMessageType;
-import org.openhab.binding.enocean.internal.messages.Responses.SMACKTeachInResponse;
+import org.openhab.binding.enocean.internal.messages.responses.SMACKTeachInResponse;
 import org.openhab.binding.enocean.internal.transceiver.TeachInListener;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
@@ -44,6 +46,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService implements TeachInListener {
     private final Logger logger = LoggerFactory.getLogger(EnOceanDeviceDiscoveryService.class);
 
@@ -70,20 +73,12 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
 
     @Override
     protected void startScan() {
-        if (bridgeHandler == null) {
-            return;
-        }
-
         logger.info("Starting EnOcean discovery and accepting teach in requests");
         bridgeHandler.startDiscovery(this);
     }
 
     @Override
     public synchronized void stopScan() {
-        if (bridgeHandler == null) {
-            return;
-        }
-
         logger.info("Stopping EnOcean discovery scan");
         bridgeHandler.stopDiscovery();
         super.stopScan();
@@ -125,11 +120,12 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
 
                     // check for bidirectional communication => do not use broadcast in this case
                     if (msg.getRORG() == RORG.UTE && (msg.getPayload(1, 1)[0]
-                            & UTEResponse.CommunicationType_MASK) == UTEResponse.CommunicationType_MASK) {
+                            & UTEResponse.COMMUNICATION_TYPE_MASK) == UTEResponse.COMMUNICATION_TYPE_MASK) {
                         broadcastMessages = false;
                     }
 
-                    if (msg.getRORG() == RORG.UTE && (msg.getPayload(1, 1)[0] & UTEResponse.ResponseNeeded_MASK) == 0) {
+                    if (msg.getRORG() == RORG.UTE
+                            && (msg.getPayload(1, 1)[0] & UTEResponse.RESPONSE_NEEDED_MASK) == 0) {
                         // if ute => send response if needed
                         logger.debug("Sending UTE response to {}", enoceanId);
                         senderIdOffset = sendTeachInResponse(msg, enoceanId);
@@ -183,7 +179,7 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
         }
     }
 
-    private Integer sendTeachInResponse(ERP1Message msg, String enoceanId) {
+    private @Nullable Integer sendTeachInResponse(ERP1Message msg, String enoceanId) {
         // get new sender Id
         Integer offset = bridgeHandler.getNextSenderId(enoceanId);
         if (offset != null) {
@@ -193,9 +189,12 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
             // send response
             EEP response = EEPFactory.buildResponseEEPFromTeachInERP1(msg, newSenderId, true);
             if (response != null) {
-                bridgeHandler.sendMessage(response.getERP1Message(), null);
-                logger.debug("Teach in response for {} with new senderId {} (= offset {}) sent", enoceanId,
-                        HexUtils.bytesToHex(newSenderId), offset);
+                BasePacket bPacket = response.getERP1Message();
+                if (bPacket != null) {
+                    bridgeHandler.sendMessage(bPacket, null);
+                    logger.debug("Teach in response for {} with new senderId {} (= offset {}) sent", enoceanId,
+                            HexUtils.bytesToHex(newSenderId), offset);
+                }
             } else {
                 logger.warn("Teach in response for enoceanId {} not supported!", enoceanId);
             }
@@ -212,16 +211,24 @@ public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService impl
         // send response
         EEP response = EEPFactory.buildResponseEEPFromTeachInERP1(msg, senderId, false);
         if (response != null) {
-            bridgeHandler.sendMessage(response.getERP1Message(), null);
-            logger.debug("Teach out response for thing {} with EnOceanId {} sent", thing.getUID().getId(), enoceanId);
+            ERP1Message message = response.getERP1Message();
+            if (message != null) {
+                bridgeHandler.sendMessage(message, null);
+                logger.debug("Teach out response for thing {} with EnOceanId {} sent", thing.getUID().getId(),
+                        enoceanId);
+            }
         } else {
             logger.warn("Teach out response for enoceanId {} not supported!", enoceanId);
         }
     }
 
-    protected void createDiscoveryResult(EEP eep, boolean broadcastMessages, Integer senderIdOffset) {
+    protected void createDiscoveryResult(EEP eep, boolean broadcastMessages, @Nullable Integer senderIdOffset) {
         String enoceanId = HexUtils.bytesToHex(eep.getSenderId());
         ThingTypeUID thingTypeUID = eep.getThingTypeUID();
+        if (thingTypeUID == null) {
+            logger.debug("Discovery failed, could not get ThingTypeUID for EnOceanId {}", enoceanId);
+            return;
+        }
         ThingUID thingUID = new ThingUID(thingTypeUID, bridgeHandler.getThing().getUID(), enoceanId);
 
         DiscoveryResultBuilder discoveryResultBuilder = DiscoveryResultBuilder.create(thingUID)
index f5969984da6c8932edd21b796704940e539883ca..337e4f7df144bfe77a296065943ec7984bfd4cd4 100644 (file)
@@ -18,6 +18,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.config.discovery.DiscoveryResult;
 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
@@ -35,6 +36,7 @@ import org.osgi.service.component.annotations.Component;
  *
  * @author Aitor Iturrioz - initial contribution
  */
+@NonNullByDefault
 @Component(service = UsbSerialDiscoveryParticipant.class)
 public class EnOceanUsbSerialDiscoveryParticipant implements UsbSerialDiscoveryParticipant {
 
index 8cc55741f17234fd3dd24544f2218352a7be7cf2..dabf2d1783eff19a865fdea329be1d3ea0de0104 100644 (file)
@@ -14,6 +14,8 @@ package org.openhab.binding.enocean.internal.eep.A5_02;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -25,6 +27,7 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_02 extends _4BSMessage {
 
     public A5_02(ERP1Message packet) {
@@ -44,13 +47,12 @@ public abstract class A5_02 extends _4BSMessage {
     protected abstract double getScaledMax();
 
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value();
+        return getDB1Value();
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         double scaledTemp = getScaledMin()
                 - (((getUnscaledMin() - getUnscaledTemperatureValue()) * (getScaledMin() - getScaledMax()))
                         / getUnscaledMin());
index 5c5bdf33fae258906a0848ccefc6247543f498b3..96800ea0806e9413a989f212a537d5523a282a50 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_01 extends A5_02 {
 
     public A5_02_01(ERP1Message packet) {
index 214f5db007eac3a698f3019fc85c59187d7d192d..033d2044b4c0a5e4101e67e307ed99c3d437e1b5 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_02 extends A5_02 {
 
     public A5_02_02(ERP1Message packet) {
index 3d62bdffdf1233a8635845d17fd3d6847f1f5cde..49bb0df20318df20a1ffb286f28e9a47bd9930f9 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_03 extends A5_02 {
 
     public A5_02_03(ERP1Message packet) {
index 558164d666ac784368ec900aab26ee442768ba60..057c3b596f9da0eeeec3cf254c8fc7d8f1ab6855 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_04 extends A5_02 {
 
     public A5_02_04(ERP1Message packet) {
index 586b5ec61d26d9b585c2651dd8b43ebd45fda4be..1349b133aacc7e2d8ed9fe3ff2d5110213800ad1 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_05 extends A5_02 {
 
     public A5_02_05(ERP1Message packet) {
index 323cb9c439c68e252962ce13c8a628eeba4df85d..49d8c8ef5b9d761da5b34d3c875d34045f5c5b25 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_06 extends A5_02 {
 
     public A5_02_06(ERP1Message packet) {
index c47851477bba64b56aadd9c848465c5f0bd82310..d1ee5ee46b7fe2100e1b6bb81244a02c5e8b72bd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_07 extends A5_02 {
 
     public A5_02_07(ERP1Message packet) {
index b1069526926fdd6ba6226671cb6153bef1346937..51f8271a29ab428b5eb4d41bf34b96705a8b0a75 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_08 extends A5_02 {
 
     public A5_02_08(ERP1Message packet) {
index 4b57d5eb9ca5a79c959d545442435a402448dd89..a4465925b152773f75c6ceb03c3c55e6ec3ef014 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_09 extends A5_02 {
 
     public A5_02_09(ERP1Message packet) {
index 74af8c2009cec88a65a67c853f88d0cdb36d6281..1f44e818e391e8b539231955b2e568cdd421f3b6 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_0A extends A5_02 {
 
     public A5_02_0A(ERP1Message packet) {
index 7e624bd05a84035c389e0809a9796565510cd90f..a74484ff4f057986c558b8ea660f46d7a6967c91 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_0B extends A5_02 {
 
     public A5_02_0B(ERP1Message packet) {
index 0eef55bd85a53587e5c0910ad5ec5e1cfe9a3724..76ca31f3d9b6355d6f57204d54afa9e2188d9f88 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_10 extends A5_02 {
 
     public A5_02_10(ERP1Message packet) {
index 640d228379f281faec939f381d6afdb6644e3557..97d77faab3b3c0d25d29ab12c3308b087801df34 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_11 extends A5_02 {
 
     public A5_02_11(ERP1Message packet) {
index 681e26025e6befbc9e24c02208ef21b08a38fc93..c22dc4c16cf71938465490dc2e6893fc86c9d3d0 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_12 extends A5_02 {
 
     public A5_02_12(ERP1Message packet) {
index e156d8eeff56d6d1950e8273b6b18798e7d85de0..99538d9540cc15a5b550ffca22894f23f92c5365 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_13 extends A5_02 {
 
     public A5_02_13(ERP1Message packet) {
index d003a9327762d2f5c6efd3e519b34a4f51dc1aac..0901ae6187653df82311e45f88fd648cd2387d43 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_14 extends A5_02 {
 
     public A5_02_14(ERP1Message packet) {
index 0f2cbc229a7fb4e6a1a5e06f51e9ba059a910b47..97f331991cf25b7da4b58c5d2ddb26dc03f79f85 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_15 extends A5_02 {
 
     public A5_02_15(ERP1Message packet) {
index 82c5d2d5659b9dee1104dd3d9e4d3e2db27e832d..1a3028bc92b801bdeb6f8d1afcbb95577e709d36 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_16 extends A5_02 {
 
     public A5_02_16(ERP1Message packet) {
index 85916e271d907e4b8dac410794bf53c79313f22b..dbcfa599bffa70bd0655e43649cc9456202c721a 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_17 extends A5_02 {
 
     public A5_02_17(ERP1Message packet) {
index 26ad46c675e97d768aad2f2158a4b0f4fe921203..96a7a5bd402ac8277c1e8a8bd734e89727c4702e 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_18 extends A5_02 {
 
     public A5_02_18(ERP1Message packet) {
index 31496faca0e2cfef54761f8e9e79e8b4541da689..5c03c17ee7bdf68556ff2247768d2174c825454d 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_19 extends A5_02 {
 
     public A5_02_19(ERP1Message packet) {
index 0c67197f01a91026d91b0c9dffaf2ad6bc92324e..772080ed9fb2cad8e9cb06f6eb3154308bd523c7 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_1A extends A5_02 {
 
     public A5_02_1A(ERP1Message packet) {
index 8e3ed6dcf362569f046d748b123ead675b3fb1db..6e4505c1aaa7f8e76a964c7eeb1184095294f3c7 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_1B extends A5_02 {
 
     public A5_02_1B(ERP1Message packet) {
index d76349e57c936816a2f2eeb5e562d8766a9a02e4..5d614fbe845ddc9039947bc1fecf7daa2a16e61e 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_20 extends A5_02 {
 
     public A5_02_20(ERP1Message packet) {
@@ -46,6 +48,6 @@ public class A5_02_20 extends A5_02 {
 
     @Override
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
+        return getDB1Value() + ((getDB2Value() & 0b11) << 8);
     }
 }
index 30861effe9aab26cee43a59253d958834f1ca0f2..99ee411f6fdd2b3a1aafea3459873b46607480ab 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_02;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_02_30 extends A5_02 {
 
     public A5_02_30(ERP1Message packet) {
@@ -46,6 +48,6 @@ public class A5_02_30 extends A5_02 {
 
     @Override
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
+        return getDB1Value() + ((getDB2Value() & 0b11) << 8);
     }
 }
index cc8983330fe1bc5572f0d04ce171c109fdd96e8e..a63242bda1971672a6e98d80e541a42197bf27f8 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -29,6 +31,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_04 extends _4BSMessage {
 
     public A5_04(ERP1Message packet) {
@@ -48,7 +51,7 @@ public abstract class A5_04 extends _4BSMessage {
     protected abstract double getScaledTemperatureMax();
 
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value();
+        return getDB1Value();
     }
 
     protected double getUnscaledHumidityMax() {
@@ -56,13 +59,12 @@ public abstract class A5_04 extends _4BSMessage {
     }
 
     protected int getUnscaledHumidityValue() {
-        return getDB_2Value();
+        return getDB2Value();
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_TEMPERATURE)) {
             double scaledTemp = getScaledTemperatureMin()
                     + ((getUnscaledTemperatureValue() * (getScaledTemperatureMax() - getScaledTemperatureMin()))
index 834bbcfe34dbdf0b71c298c97be459b8141651d4..e19634b3d4b18ee0dca7126bb4c93a8299430c10 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_04;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_04_01 extends A5_04 {
 
     public A5_04_01(ERP1Message packet) {
index eca1cfe0338057a93c01e930bede4bb573a0041c..f9da35cf77b28dd0cc66edb0598e483751a7c766 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_04;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_04_02 extends A5_04 {
 
     public A5_04_02(ERP1Message packet) {
index 47a30b204e72a305769c8c581e088a6be77c180b..0d661d0ab00b8f861973d3928ad34ae55bd6d02f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.QuantityType;
@@ -26,6 +28,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_04_02_Eltako extends A5_04_02 {
 
     public A5_04_02_Eltako(ERP1Message packet) {
@@ -34,9 +37,9 @@ public class A5_04_02_Eltako extends A5_04_02 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_BATTERY_VOLTAGE)) {
-            double voltage = getDB_3Value() * 6.58 / 255.0; // not sure if this is right
+            double voltage = getDB3Value() * 6.58 / 255.0; // not sure if this is right
             return new QuantityType<>(voltage, Units.VOLT);
         }
 
index 9e39ed10ec4409799d1ea31f1c6e6567fdc7588f..fcfe7e981ace3ecba94470d7576046e92586fa52 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_04;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_04_03 extends A5_04 {
 
     public A5_04_03(ERP1Message packet) {
@@ -41,7 +43,7 @@ public class A5_04_03 extends A5_04 {
 
     @Override
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
+        return getDB1Value() + ((getDB2Value() & 0b11) << 8);
     }
 
     @Override
@@ -51,6 +53,6 @@ public class A5_04_03 extends A5_04 {
 
     @Override
     protected int getUnscaledHumidityValue() {
-        return getDB_3Value();
+        return getDB3Value();
     }
 }
index 5ca5977be8e39e896f760fc6d863888f99ec52a4..242da8c6012997c07897d82eae595fa6e684768a 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_06_01 extends _4BSMessage {
 
     public A5_06_01(ERP1Message packet) {
@@ -35,7 +38,7 @@ public class A5_06_01 extends _4BSMessage {
     }
 
     private State getBatteryVoltage() {
-        int db3 = getDB_3Value();
+        int db3 = getDB3Value();
 
         double voltage = db3 / 50.0; // 0..255 = 0.0..5.1V
 
@@ -43,16 +46,16 @@ public class A5_06_01 extends _4BSMessage {
     }
 
     private State getIllumination() {
-        boolean rs = getBit(getDB_0(), 0);
+        boolean rs = getBit(getDB0(), 0);
 
-        double illumination = rs ? getDB_2Value() * 116.48 + 300.0 : getDB_1Value() * 232.94 + 600.0;
+        double illumination = rs ? getDB2Value() * 116.48 + 300.0 : getDB1Value() * 232.94 + 600.0;
 
         return new QuantityType<>(illumination, Units.LUX);
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_BATTERY_VOLTAGE:
                 return getBatteryVoltage();
index 7729bc1cfe2b8e12c5e3080cdcafdaed054da66c..dd84840d523ab48a5e8951f1086e7b3113b5e6b4 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_06_01_ELTAKO extends _4BSMessage {
 
     public A5_06_01_ELTAKO(ERP1Message packet) {
@@ -35,10 +38,10 @@ public class A5_06_01_ELTAKO extends _4BSMessage {
     }
 
     private State getIllumination() {
-        int db2 = getDB_2Value();
+        int db2 = getDB2Value();
 
         if (db2 == 0) {
-            int db3 = getDB_3Value();
+            int db3 = getDB3Value();
             return new QuantityType<>(db3 * 0.5, Units.LUX);
         } else {
             return new QuantityType<>(db2 * 116.48 + 300.0, Units.LUX);
@@ -47,7 +50,7 @@ public class A5_06_01_ELTAKO extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_ILLUMINATION:
                 return getIllumination();
index 94cb44b6cc93d006c2ccc15d9896feaa0f4e8897..1dc8a24e2f465a34010f55cf9a53ac74d0b9863d 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_07 extends _4BSMessage {
 
     public A5_07(ERP1Message packet) {
@@ -52,8 +55,7 @@ public abstract class A5_07 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_ILLUMINATION)) {
             return getIllumination();
         } else if (channelId.equals(CHANNEL_MOTIONDETECTION)) {
index f78afde675bc2e4e4b2a820a417f2e3fafd23b66..3555d6438e895738ad16d72e7ebe78a593f85601 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_07;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.State;
@@ -21,9 +22,10 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_07_01 extends A5_07 {
 
-    private final int PIR_OFF = 0x7f;
+    private static final int PIR_OFF = 0x7f;
 
     public A5_07_01(ERP1Message packet) {
         super(packet);
@@ -36,15 +38,15 @@ public class A5_07_01 extends A5_07 {
 
     @Override
     protected State getMotion() {
-        return getDB_1Value() <= PIR_OFF ? OnOffType.OFF : OnOffType.ON;
+        return getDB1Value() <= PIR_OFF ? OnOffType.OFF : OnOffType.ON;
     }
 
     @Override
     protected State getSupplyVoltage() {
-        if (!getBit(getDB_0Value(), 0)) {
+        if (!getBit(getDB0Value(), 0)) {
             return UnDefType.UNDEF;
         }
 
-        return getSupplyVoltage(getDB_3Value());
+        return getSupplyVoltage(getDB3Value());
     }
 }
index 6f9e15ed89fbd0d2ff900fae25cf9fd792c18528..98b0723574bcdc5a08e96c4f5539b78c45da33a5 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_07;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.types.State;
@@ -21,6 +22,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_07_02 extends A5_07 {
 
     public A5_07_02(ERP1Message packet) {
@@ -34,11 +36,11 @@ public class A5_07_02 extends A5_07 {
 
     @Override
     protected State getMotion() {
-        return getBit(getDB_0Value(), 7) ? OnOffType.ON : OnOffType.OFF;
+        return getBit(getDB0Value(), 7) ? OnOffType.ON : OnOffType.OFF;
     }
 
     @Override
     protected State getSupplyVoltage() {
-        return getSupplyVoltage(getDB_3Value());
+        return getSupplyVoltage(getDB3Value());
     }
 }
index 4a996b1c6d4504199dc2241854880535616c830f..89f743663ef78afe7ca565a08c748c04674f2b0f 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_07;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.unit.Units;
@@ -21,6 +22,7 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_07_03 extends A5_07_02 {
 
     public A5_07_03(ERP1Message packet) {
@@ -29,6 +31,6 @@ public class A5_07_03 extends A5_07_02 {
 
     @Override
     protected State getIllumination() {
-        return new QuantityType<>((getDB_2Value() << 8) + ((getDB_1Value() & 0b11000000) >>> 6), Units.LUX);
+        return new QuantityType<>((getDB2Value() << 8) + ((getDB1Value() & 0b11000000) >>> 6), Units.LUX);
     }
 }
index a8eb2b25d22f7883ba641f5a9b489cf80f7391be..13630dc2f353993ef27976c5413284e6d816c643 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -30,6 +32,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_08 extends _4BSMessage {
 
     public A5_08(ERP1Message packet) {
@@ -61,17 +64,16 @@ public abstract class A5_08 extends _4BSMessage {
     protected abstract double getScaledIlluminationMax();
 
     protected int getUnscaledTemperatureValue() {
-        return getDB_1Value();
+        return getDB1Value();
     }
 
     protected int getUnscaledIlluminationValue() {
-        return getDB_2Value();
+        return getDB2Value();
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_TEMPERATURE)) {
             double scaledTemp = getScaledTemperatureMin()
                     + ((getUnscaledTemperatureValue() * (getScaledTemperatureMax() - getScaledTemperatureMin()))
@@ -83,9 +85,9 @@ public abstract class A5_08 extends _4BSMessage {
                             / (getUnscaledIlluminationMax() - getUnscaledIlluminationMin()));
             return new QuantityType<>(scaledIllumination, Units.LUX);
         } else if (channelId.equals(CHANNEL_MOTIONDETECTION)) {
-            return getBit(getDB_0(), 1) ? OnOffType.OFF : OnOffType.ON;
+            return getBit(getDB0(), 1) ? OnOffType.OFF : OnOffType.ON;
         } else if (channelId.equals(CHANNEL_OCCUPANCY)) {
-            return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;
+            return getBit(getDB0(), 0) ? OnOffType.OFF : OnOffType.ON;
         }
 
         return UnDefType.UNDEF;
index b0f45aab2e2c6c41c080f6ab782abca1e3357df9..adfd2fac8169fc90a43ccbd4d7dfd5e2c544a103 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_08;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_08_01 extends A5_08 {
 
     public A5_08_01(ERP1Message packet) {
index d5862f2557a23794f983c1d0492a6e2ae967683e..358316d2a1c4e4c038061fb10f52815061a08c9d 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_08;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_08_01_FXBH extends A5_08 {
 
     public A5_08_01_FXBH(ERP1Message packet) {
index 7dd7090580460f55f2f48e1a86e505d1a14e3730..43f96ea528a1e7013db58f84b3f725450d4053fd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_08;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_08_02 extends A5_08 {
 
     public A5_08_02(ERP1Message packet) {
index fd972ca3f2cbf06a14bb42668b66133ea1c936eb..0c838287bc548d573a6393aaddab71b3f9c22f31 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_08;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_08_03 extends A5_08 {
 
     public A5_08_03(ERP1Message packet) {
index 1df6cae43ee0a479f21784f1028bc2bd97e4ae6a..a78169252681d065c3944f03ce9288fc08f905e6 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -31,6 +33,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_10 extends _4BSMessage {
 
     public A5_10(ERP1Message packet) {
@@ -39,31 +42,30 @@ public abstract class A5_10 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_FANSPEEDSTAGE:
-                if (getDB_3Value() > 209) {
+                if (getDB3Value() > 209) {
                     return new StringType("-1");
-                } else if (getDB_3Value() > 189) {
+                } else if (getDB3Value() > 189) {
                     return new StringType("0");
-                } else if (getDB_3Value() > 164) {
+                } else if (getDB3Value() > 164) {
                     return new StringType("1");
-                } else if (getDB_3Value() > 144) {
+                } else if (getDB3Value() > 144) {
                     return new StringType("2");
                 } else {
                     return new StringType("3");
                 }
 
             case CHANNEL_SETPOINT:
-                return new DecimalType(getDB_2Value());
+                return new DecimalType(getDB2Value());
 
             case CHANNEL_TEMPERATURE:
-                double temp = (getDB_1Value() - 255) / -6.375;
+                double temp = (getDB1Value() - 255) / -6.375;
                 return new QuantityType<>(temp, SIUnits.CELSIUS);
 
             case CHANNEL_OCCUPANCY:
-                return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;
+                return getBit(getDB0(), 0) ? OnOffType.OFF : OnOffType.ON;
         }
 
         return UnDefType.UNDEF;
index f22b2a9bd688a90e60b10facd5ba964dacf45bde..225cfb6b94304cd93f20ebc201c81644ccef78d5 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_01 extends A5_10 {
 
     public A5_10_01(ERP1Message packet) {
index 40b0b8c97fd0830de80ff8600596e4f0dd7b1859..f470b678b8d0ac78c3e8ecd2e9b1c545d7f34b45 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_02 extends A5_10 {
 
     public A5_10_02(ERP1Message packet) {
index bdfab5b1d86bd77bbdc8055b9457ea83f67adb7a..372a6bbd27fca990c3c335d720f4dca3b466e594 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_03 extends A5_10 {
 
     public A5_10_03(ERP1Message packet) {
index d93f9e7994040c6c24a69272d3b53bd77a90947b..69da5b525945f2ea185a6ae11f29feadd8789870 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_04 extends A5_10 {
 
     public A5_10_04(ERP1Message packet) {
index 8dfc26a3455dc6f34fa1d252419db3789040f184..96785ec1fd2d2c3871254ba4b835648f070132a3 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_05 extends A5_10 {
 
     public A5_10_05(ERP1Message packet) {
index 8c169236e7a64db09029c7d2c4690189f0e69c82..42e8a21022fcb8bdc8073f001f38cd30c38262ad 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_06 extends A5_10 {
 
     public A5_10_06(ERP1Message packet) {
index 8c6ebd9192aefbe2b91fbf1bca1b7a86312efaa3..c08e65ee918184770b166b6be99ff66d925dd4d9 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_07 extends A5_10 {
 
     public A5_10_07(ERP1Message packet) {
index 03877a410f7889a3f12b73214fa733cace4b48cd..a38cc7281297f9d8973069e00650242810543a94 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_08 extends A5_10 {
 
     public A5_10_08(ERP1Message packet) {
index 8aa3b61fb85ff073dbaeb715f103675814a93bb3..3f683e553008dd2abd4493615da564fd88d20f75 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_09 extends A5_10 {
 
     public A5_10_09(ERP1Message packet) {
index ce16dc5bc670655ec399399689d5a1a65314a615..029799044f9ceef9e7bbc3e25e4496eb2374d302 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_0A extends A5_10 {
 
     public A5_10_0A(ERP1Message packet) {
index a59106119ed1b6d967fb7ca9868859d641da5ef5..5649ae8ee77558e12ee458fb114abdba46d08411 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_0B extends A5_10 {
 
     public A5_10_0B(ERP1Message packet) {
index 0deb7539b1e0a339f8fcf66130e19ecfbbccd653..7c47e6af64f8c6e723586e5ccb7cee0e4e782acd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_0C extends A5_10 {
 
     public A5_10_0C(ERP1Message packet) {
index a028be3215acd64456c70ccb3147786b52d5d158..fd9fd87006fcad7eec13171ed5e737ce85eafa3c 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_0D extends A5_10 {
 
     public A5_10_0D(ERP1Message packet) {
index 917438795c91dabd35f20d3e8ec7aab5700521ca..e6e98a1a31ff29abf58ae769c9a79d1dea1eb8ee 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_10 extends A5_10 {
 
     public A5_10_10(ERP1Message packet) {
index 4d8f90b919614559b328237859fda936a6a5365f..78f53cd4c06e7b31a1eb93a5d3ed9a3e36e795e1 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_11 extends A5_10 {
 
     public A5_10_11(ERP1Message packet) {
index b3c1e0c89a8ff8d546993ffba26ec5ec71e7c2e4..e9a8b66653cc1f05289337bc7cefe01e8dd8c259 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_12 extends A5_10 {
 
     public A5_10_12(ERP1Message packet) {
index 454c9d42cb04827b6185a189d63e43e7ee76748c..f647693e4e9ec83c5c439fd58e6846bcb96716bc 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_13 extends A5_10 {
 
     public A5_10_13(ERP1Message packet) {
index 73f669ef74389736de7e5c40ace5dba5ea2d5dd4..7085dac6263dece120e20176c61f1cf7e5db9169 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_14 extends A5_10 {
 
     public A5_10_14(ERP1Message packet) {
index 17fa58c45e731face8fd8cc29b274e5243fd227f..2cb138589fd46bd90036169a67d2a7915a62f15c 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_15 extends A5_10 {
 
     public A5_10_15(ERP1Message packet) {
index d83d8d0837d86e348ff504976bf4ace321a0fdf1..af61d6b21139dd9767c59cb0f4c56fd1e6e3a6dd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_16 extends A5_10 {
 
     public A5_10_16(ERP1Message packet) {
index 8fa706c9ef8349da35345b88a01511934c24b823..544a625a6eae0de8c217b6c44a238d92c7630e5a 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_17 extends A5_10 {
 
     public A5_10_17(ERP1Message packet) {
index 76d82ad0a74e65b2bbb4bbdbf26bdca2e1009f17..519177ade7e6cdfdff551bc650c5be4368092537 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_18 extends A5_10 {
 
     public A5_10_18(ERP1Message packet) {
index 9dd5387d9f1d61d6206225d1b36dda5a3c121fc1..9cef98b3dcf3eb9a4ce71a2100222e5b1f08c63d 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_19 extends A5_10 {
 
     public A5_10_19(ERP1Message packet) {
index 489e19df064e5df0c895232508da5aa286cf7843..e3552cbafe80bcd5aefe4a538ed0074ca1cbac51 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1A extends A5_10 {
 
     public A5_10_1A(ERP1Message packet) {
index 95484747a3dc629464917f04a450f947366a2d46..bcf8d06f8d91903ea08cdc3fd198713e1ce93307 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1B extends A5_10 {
 
     public A5_10_1B(ERP1Message packet) {
index 40dc181fcb212a64e0617e46c0a2dcb789751984..e0d53831ac890de6b41d97f85a6be59df53cf885 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1C extends A5_10 {
 
     public A5_10_1C(ERP1Message packet) {
index 841a963322dcb7d17c7b7ff02d553f1fa87946a0..462e7798f5143a2c711ae99122f64715c3926c4d 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1D extends A5_10 {
 
     public A5_10_1D(ERP1Message packet) {
index 719f3bb243aeff934d338b21b989d96d89bfff3b..9e38b33c16660f5b2424aa5f5bba5074ab8a25cd 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1E extends A5_10 {
 
     public A5_10_1E(ERP1Message packet) {
index 14b015df7454071be9503396709fe2ed0549a66d..f23d5a7df745467dc2b586e30a10e7fdac009a8c 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_1F extends A5_10 {
 
     public A5_10_1F(ERP1Message packet) {
index c312d5cd61f9736891a05bd002e67845ded24d83..36b66763dc8f7644d868c11ebd70deec1af11d9e 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_20 extends A5_10 {
 
     public A5_10_20(ERP1Message packet) {
index 90c992f75bdb92dce4d86916b73dc148aa73a6ca..4fa75dcc8b6975454a3a7719f999745340a1280c 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_21 extends A5_10 {
 
     public A5_10_21(ERP1Message packet) {
index 92609d1fdd23033a91921de60a3b594231aeeccf..1a8d62a1706ced8a4ab25f3efdc0fc10821af0e5 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_22 extends A5_10 {
 
     public A5_10_22(ERP1Message packet) {
index b4b57fb95e88c23d89aef9970b47c25defe9d678..b29dc6327000f612759d731373a55f069985f9b2 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.A5_10;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_10_23 extends A5_10 {
 
     public A5_10_23(ERP1Message packet) {
index 7ae30eeea5c6e4177f1365f2a8baf9b25919008c..e00d9dac70cd165d88414cc27aa832d6b31577a9 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -29,6 +31,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_11_03 extends _4BSMessage {
 
     public A5_11_03(ERP1Message packet) {
@@ -36,7 +39,7 @@ public class A5_11_03 extends _4BSMessage {
     }
 
     protected boolean isErrorState() {
-        byte db1 = getDB_1();
+        byte db1 = getDB1();
 
         int state = (db1 >> 4) & 0x03;
 
@@ -45,14 +48,14 @@ public class A5_11_03 extends _4BSMessage {
     }
 
     protected State getPositionData() {
-        byte db1 = getDB_1();
+        byte db1 = getDB1();
         boolean pvf = getBit(db1, 7);
 
         if (pvf) {
-            byte db0 = getDB_0();
+            byte db0 = getDB0();
 
             boolean motp = getBit(db0, 6);
-            int bsp = getDB_3Value();
+            int bsp = getDB3Value();
 
             if ((bsp >= 0) && (bsp <= 100)) {
                 return new PercentType(motp ? 100 - bsp : bsp);
@@ -63,11 +66,11 @@ public class A5_11_03 extends _4BSMessage {
     }
 
     protected State getAngleData() {
-        byte db1 = getDB_1();
+        byte db1 = getDB1();
         boolean avf = getBit(db1, 6);
 
         if (avf) {
-            byte db2 = getDB_2();
+            byte db2 = getDB2();
 
             boolean as = getBit(db2, 7);
             int an = (db2 & 0x7F) * 2;
@@ -82,7 +85,7 @@ public class A5_11_03 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (isErrorState()) {
             return UnDefType.UNDEF;
         }
index 7306976dcf4af92de8bd83ffac3afeef76e65017..05b5297180ebb55bbc622bbf71b56f0b1f8c842f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.eep.EEPHelper;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -35,7 +37,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Vincent Bakker - Initial contribution
  */
-
+@NonNullByDefault
 public class A5_11_04 extends _4BSMessage {
 
     private enum Error {
@@ -64,14 +66,14 @@ public class A5_11_04 extends _4BSMessage {
         NOT_SUPPORTED
     }
 
-    private static Logger logger = LoggerFactory.getLogger(A5_11_04.class);
+    private Logger logger = LoggerFactory.getLogger(A5_11_04.class);
 
     public A5_11_04(ERP1Message packet) {
         super(packet);
     }
 
     protected boolean isErrorState() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
 
         int state = (db0 >> 4) & 0x03;
 
@@ -85,12 +87,12 @@ public class A5_11_04 extends _4BSMessage {
     }
 
     protected ParameterMode getParameterMode() {
-        int pm = (getDB_0() >> 1) & 0x03;
+        int pm = (getDB0() >> 1) & 0x03;
         return ParameterMode.values()[pm];
     }
 
     protected EnergyUnit getEnergyUnit() {
-        int unit = getDB_1();
+        int unit = getDB1();
         if (unit < 8) {
             return EnergyUnit.values()[unit];
         }
@@ -99,7 +101,7 @@ public class A5_11_04 extends _4BSMessage {
     }
 
     protected State getLightingStatus() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
         boolean lightOn = getBit(db0, 0);
 
         return lightOn ? OnOffType.ON : OnOffType.OFF;
@@ -107,7 +109,7 @@ public class A5_11_04 extends _4BSMessage {
 
     protected State getDimmerStatus() {
         if (getParameterMode() == ParameterMode.EIGHT_BIT_DIMMER_VALUE_AND_LAMP_OPERATING_HOURS) {
-            return new PercentType(getDB_3Value() * 100 / 255);
+            return new PercentType(getDB3Value() * 100 / 255);
         }
         return UnDefType.UNDEF;
     }
@@ -134,7 +136,7 @@ public class A5_11_04 extends _4BSMessage {
             }
 
             return new QuantityType<>(
-                    Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
+                    Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB3(), getDB2() }), 16) * factor,
                     Units.KILOWATT_HOUR);
         }
 
@@ -163,7 +165,7 @@ public class A5_11_04 extends _4BSMessage {
             }
 
             return new QuantityType<>(
-                    Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor, Units.WATT);
+                    Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB3(), getDB2() }), 16) * factor, Units.WATT);
         }
 
         return UnDefType.UNDEF;
@@ -171,7 +173,7 @@ public class A5_11_04 extends _4BSMessage {
 
     protected State getOperatingHours() {
         if (getParameterMode() == ParameterMode.EIGHT_BIT_DIMMER_VALUE_AND_LAMP_OPERATING_HOURS) {
-            return new DecimalType(getDB_2Value() << 8 + getDB_1Value());
+            return new DecimalType(getDB2Value() << 8 + getDB1Value());
         }
 
         return UnDefType.UNDEF;
@@ -179,7 +181,7 @@ public class A5_11_04 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (isErrorState()) {
             return UnDefType.UNDEF;
         }
index 5b75806bfc2422a8092187e020cdb6edb5e6b68e..539bd24f73d1569662de2ee893502027b704ab57 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelTariffInfoConfig;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.eep.EEPHelper;
@@ -31,6 +33,7 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_12 extends _4BSMessage {
     public A5_12(ERP1Message packet) {
         super(packet);
@@ -45,7 +48,7 @@ public abstract class A5_12 extends _4BSMessage {
     }
 
     protected State getCumulativeValue() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
         boolean dt = getBit(db0, 2);
 
         if (!dt) {
@@ -70,8 +73,8 @@ public abstract class A5_12 extends _4BSMessage {
                     return UnDefType.UNDEF;
             }
 
-            float cumulativeValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2(), getDB_1() }),
-                    16) * factor;
+            float cumulativeValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB3(), getDB2(), getDB1() }), 16)
+                    * factor;
             return calcCumulativeValue(cumulativeValue);
         }
 
@@ -79,7 +82,7 @@ public abstract class A5_12 extends _4BSMessage {
     }
 
     protected State getCurrentValue() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
         boolean dt = getBit(db0, 2);
 
         if (dt) {
@@ -104,7 +107,7 @@ public abstract class A5_12 extends _4BSMessage {
                     return UnDefType.UNDEF;
             }
 
-            float currentValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2(), getDB_1() }), 16)
+            float currentValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB3(), getDB2(), getDB1() }), 16)
                     * factor;
 
             return calcCurrentValue(currentValue);
@@ -114,13 +117,12 @@ public abstract class A5_12 extends _4BSMessage {
     }
 
     protected int getTariffInfo() {
-        return ((getDB_0() >>> 4) & 0xff);
+        return ((getDB0() >>> 4) & 0xff);
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         EnOceanChannelTariffInfoConfig c = config.as(EnOceanChannelTariffInfoConfig.class);
         if (c.tariff != getTariffInfo()) {
             return UnDefType.UNDEF;
index c6742c8e5928dc1c890de5b2a8168acb1e3c2817..7739afed900f75af8535d331fb48cc4b1c0ac72b 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_12;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.unit.Units;
@@ -21,6 +22,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_12_00 extends A5_12 {
 
     public A5_12_00(ERP1Message packet) {
index 1061a68cf51e6139a9a3673adbe2fec4e6a3ab91..052f711a26031136c7453a52fda0ab0a44876c9f 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_12;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.unit.Units;
@@ -21,6 +22,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_12_01 extends A5_12 {
 
     public A5_12_01(ERP1Message packet) {
index d58b5e6dcd1995d120f63e751a1105ec15d03ecf..312d7f0cc6e76ce05997a7200cb0918212b40c4d 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_12;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.unit.SIUnits;
@@ -22,6 +23,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_12_02 extends A5_12 {
 
     public A5_12_02(ERP1Message packet) {
index 8b88985b34ab848275f7e95c17361440197729fe..46cb12c548621a27c1c6f6272d39537f182bb188 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_12;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.unit.SIUnits;
@@ -22,6 +23,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_12_03 extends A5_12 {
 
     public A5_12_03(ERP1Message packet) {
index 2be92f29683c8a82fd3ddc9e0c0812fd7ce98a03..d1821d59a6f3ae79a10fde3c7a3e5ead152faea0 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_13;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -20,16 +21,17 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  * 
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_13 extends _4BSMessage {
     public A5_13(ERP1Message packet) {
         super(packet);
     }
 
-    protected final int PARTONE = 0x10;
-    protected final int PARTTWO = 0x20;
+    protected static final int PARTONE = 0x10;
+    protected static final int PARTTWO = 0x20;
 
     protected int getMessageIdentifier() {
-        return getDB_0Value() & 0xF0;
+        return getDB0Value() & 0xF0;
     }
 
     protected boolean isPartOne() {
index c31985851baa49a696696d1bf5f62cd889f77e34..d86109c62a348a4dd366c9ec2431377b950b1a0c 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
@@ -30,6 +32,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_13_01 extends A5_13 {
 
     public A5_13_01(ERP1Message packet) {
@@ -37,7 +40,7 @@ public class A5_13_01 extends A5_13 {
     }
 
     protected State getIllumination() {
-        return new QuantityType<>(((getDB_3Value() * 1000.0) / 255.0), Units.LUX);
+        return new QuantityType<>(((getDB3Value() * 1000.0) / 255.0), Units.LUX);
     }
 
     protected State getIllumination(double value) {
@@ -45,32 +48,32 @@ public class A5_13_01 extends A5_13 {
     }
 
     protected State getIlluminationWest() {
-        return getIllumination(getDB_3Value());
+        return getIllumination(getDB3Value());
     }
 
     protected State getIlluminationSouthNorth() {
-        return getIllumination(getDB_2Value());
+        return getIllumination(getDB2Value());
     }
 
     protected State getIlluminationEast() {
-        return getIllumination(getDB_1Value());
+        return getIllumination(getDB1Value());
     }
 
     protected State getTemperature() {
-        return new QuantityType<>(-40.0 + ((getDB_2Value() * 120.0) / 255.0), SIUnits.CELSIUS);
+        return new QuantityType<>(-40.0 + ((getDB2Value() * 120.0) / 255.0), SIUnits.CELSIUS);
     }
 
     protected State getWindSpeed() {
-        return new QuantityType<>(((getDB_1Value() * 70.0) / 255.0), Units.METRE_PER_SECOND);
+        return new QuantityType<>(((getDB1Value() * 70.0) / 255.0), Units.METRE_PER_SECOND);
     }
 
     protected State getRainStatus() {
-        return getBit(getDB_0Value(), 1) ? OnOffType.ON : OnOffType.OFF;
+        return getBit(getDB0Value(), 1) ? OnOffType.ON : OnOffType.OFF;
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (isPartOne()) {
             switch (channelId) {
                 case CHANNEL_ILLUMINATION:
index c7e66a0f5eb529d0c558d80f155720eac509a0a4..99e9c6148fe5be97e7b8178bfa709739c524007b 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,13 +30,14 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public abstract class A5_14 extends _4BSMessage {
     public A5_14(ERP1Message packet) {
         super(packet);
     }
 
     private State getBatteryVoltage() {
-        int db3 = getDB_3Value();
+        int db3 = getDB3Value();
 
         if (db3 > 250) {
             logger.warn("EEP A5-14 error code {}", db3);
@@ -48,7 +51,7 @@ public abstract class A5_14 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_BATTERY_VOLTAGE:
                 return getBatteryVoltage();
index b839ceb1bf4e40a2826cbab8176548418f166bfc..1f2d6f5c3f64b5ad3e6b0d1f0896d82f20d9aa81 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -27,6 +29,7 @@ import org.openhab.core.types.State;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_14_01 extends A5_14 {
 
     public A5_14_01(ERP1Message packet) {
@@ -34,7 +37,7 @@ public class A5_14_01 extends A5_14 {
     }
 
     private State getContact(boolean inverted) {
-        boolean ct = getBit(getDB_0(), 0);
+        boolean ct = getBit(getDB0(), 0);
 
         if (inverted) {
             return ct ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
@@ -45,7 +48,7 @@ public class A5_14_01 extends A5_14 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_CONTACT:
                 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
index 995f10cebc070afb4ea8336a6fd3a117ef392295..c8618197924d0a4ca052214d834dc730050e9ddd 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_14_01_ELTAKO extends _4BSMessage {
 
     public A5_14_01_ELTAKO(ERP1Message packet) {
@@ -35,7 +38,7 @@ public class A5_14_01_ELTAKO extends _4BSMessage {
     }
 
     private State getEnergyStorage() {
-        int db3 = getDB_3Value();
+        int db3 = getDB3Value();
 
         double voltage = db3 / 51.0; // 0..255 = 0.0..5.0V
 
@@ -43,7 +46,7 @@ public class A5_14_01_ELTAKO extends _4BSMessage {
     }
 
     private State getBatteryVoltage() {
-        int db2 = getDB_2Value();
+        int db2 = getDB2Value();
 
         double voltage = db2 / 51.0; // 0..255 = 0.0..5.0V
 
@@ -52,7 +55,7 @@ public class A5_14_01_ELTAKO extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_ENERGY_STORAGE:
                 return getEnergyStorage();
index 92207d8199aad54d0a810505b84b54c30b58ef6e..50c1511accfe159ccfd0279e9a9773c5ce11ba70 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -29,17 +31,18 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Krickl-Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_14_09 extends A5_14 {
-    public final byte CLOSED = (byte) 0x00;
-    public final byte TILTED = (byte) 0x01;
-    public final byte OPEN = (byte) 0x03;
+    public static final byte CLOSED = (byte) 0x00;
+    public static final byte TILTED = (byte) 0x01;
+    public static final byte OPEN = (byte) 0x03;
 
     public A5_14_09(ERP1Message packet) {
         super(packet);
     }
 
     private State getWindowhandleState() {
-        byte ct = (byte) ((getDB_0() & 0x06) >> 1);
+        byte ct = (byte) ((getDB0() & 0x06) >> 1);
 
         switch (ct) {
             case CLOSED:
@@ -54,7 +57,7 @@ public class A5_14_09 extends A5_14 {
     }
 
     private State getContact(boolean inverted) {
-        byte ct = (byte) ((getDB_0() & 0x06) >> 1);
+        byte ct = (byte) ((getDB0() & 0x06) >> 1);
 
         switch (ct) {
             case CLOSED:
@@ -69,7 +72,7 @@ public class A5_14_09 extends A5_14 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_WINDOWHANDLESTATE:
                 return getWindowhandleState();
index ebcac43e9cfd841e7553bebfb1fa2ee74d3f91b2..c52e3d5efa88289d9fd3639315c0479a3ad149b7 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
@@ -27,19 +29,20 @@ import org.openhab.core.types.State;
  *
  * @author Stefan Schimanski - Initial contribution
  */
+@NonNullByDefault
 public class A5_14_0A extends A5_14_09 {
     public A5_14_0A(ERP1Message packet) {
         super(packet);
     }
 
     private State getVibration() {
-        boolean alarm = getBit(getDB_0(), 0);
+        boolean alarm = getBit(getDB0(), 0);
         return alarm ? OnOffType.ON : OnOffType.OFF;
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_VIBRATION)) {
             return getVibration();
         }
index 52bc8303bc022cf581939b20b7f041233b703d4d..0f3954b97ba5055b5afeb5ec7498fbe46136233c 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.A5_20;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -21,6 +22,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  *
  * @author Dominik Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_20 extends _4BSMessage {
 
     public A5_20() {
index 63df82925bad6e6da125fc182c16734be1294c49..d79601dc3968a27fc580d46a3c2877b787e0c465 100644 (file)
@@ -18,6 +18,8 @@ import java.util.function.Function;
 
 import javax.measure.quantity.Temperature;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.DecimalType;
@@ -35,6 +37,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Dominik Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class A5_20_04 extends A5_20 {
 
     public A5_20_04() {
@@ -46,7 +49,7 @@ public class A5_20_04 extends A5_20 {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
         switch (channelId) {
             case CHANNEL_STATUS_REQUEST_EVENT:
@@ -57,14 +60,14 @@ public class A5_20_04 extends A5_20 {
     }
 
     private String getStatusRequestEvent() {
-        return Boolean.valueOf(getBit(getDB_0Value(), 6)).toString();
+        return Boolean.valueOf(getBit(getDB0Value(), 6)).toString();
         // return getBit(getDB_0Value(), 6) ? "triggered" : null;
     }
 
     private byte getPos(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_VALVE_POSITION);
 
-        if ((current != null) && (current instanceof DecimalType)) {
+        if (current instanceof DecimalType) {
             DecimalType state = current.as(DecimalType.class);
 
             if (state != null) {
@@ -80,7 +83,7 @@ public class A5_20_04 extends A5_20 {
 
         double value = 20.0; // 20 Â°C
 
-        if ((current != null) && (current instanceof QuantityType)) {
+        if (current instanceof QuantityType) {
             @SuppressWarnings("unchecked")
             QuantityType<Temperature> raw = current.as(QuantityType.class);
 
@@ -99,7 +102,7 @@ public class A5_20_04 extends A5_20 {
     private byte getMc(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_MEASUREMENT_CONTROL);
 
-        if ((current != null) && (current instanceof OnOffType)) {
+        if (current instanceof OnOffType) {
             OnOffType state = current.as(OnOffType.class);
 
             if (state != null) {
@@ -113,7 +116,7 @@ public class A5_20_04 extends A5_20 {
     private byte getWuc(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_WAKEUPCYCLE);
 
-        if ((current != null) && (current instanceof DecimalType)) {
+        if (current instanceof DecimalType) {
             DecimalType state = current.as(DecimalType.class);
 
             if (state != null) {
@@ -127,7 +130,7 @@ public class A5_20_04 extends A5_20 {
     private byte getDso(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_DISPLAY_ORIENTATION);
 
-        if ((current != null) && (current instanceof DecimalType)) {
+        if (current instanceof DecimalType) {
             DecimalType state = current.as(DecimalType.class);
 
             if (state != null) {
@@ -141,7 +144,7 @@ public class A5_20_04 extends A5_20 {
     private byte getBlc(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_BUTTON_LOCK);
 
-        if ((current != null) && (current instanceof OnOffType)) {
+        if (current instanceof OnOffType) {
             OnOffType state = current.as(OnOffType.class);
 
             if (state != null) {
@@ -155,7 +158,7 @@ public class A5_20_04 extends A5_20 {
     private byte getSer(Function<String, State> getCurrentStateFunc) {
         State current = getCurrentStateFunc.apply(CHANNEL_SERVICECOMMAND);
 
-        if ((current != null) && (current instanceof DecimalType)) {
+        if (current instanceof DecimalType) {
             DecimalType state = current.as(DecimalType.class);
 
             if (state != null) {
@@ -168,12 +171,12 @@ public class A5_20_04 extends A5_20 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (VIRTUALCHANNEL_SEND_COMMAND.equals(channelId)) {
             byte db3 = getPos(getCurrentStateFunc);
             byte db2 = getTsp(getCurrentStateFunc);
             byte db1 = (byte) (0x00 | getMc(getCurrentStateFunc) | getWuc(getCurrentStateFunc));
-            byte db0 = (byte) (0x00 | getDso(getCurrentStateFunc) | TeachInBit | getBlc(getCurrentStateFunc)
+            byte db0 = (byte) (0x00 | getDso(getCurrentStateFunc) | TEACHIN_BIT | getBlc(getCurrentStateFunc)
                     | getSer(getCurrentStateFunc));
 
             setData(db3, db2, db1, db0);
@@ -184,7 +187,7 @@ public class A5_20_04 extends A5_20 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_VALVE_POSITION:
                 return getValvePosition();
@@ -206,62 +209,62 @@ public class A5_20_04 extends A5_20 {
     }
 
     private State getTemperature() {
-        boolean fl = getBit(getDB_0Value(), 0);
-        boolean mst = getBit(getDB_0Value(), 7);
+        boolean fl = getBit(getDB0Value(), 0);
+        boolean mst = getBit(getDB0Value(), 7);
 
         if (fl || mst) {
             return UnDefType.UNDEF;
         }
 
-        double value = getDB_1Value() * (20.0 / 255.0) + 10.0;
+        double value = getDB1Value() * (20.0 / 255.0) + 10.0;
 
         return new QuantityType<>(value, SIUnits.CELSIUS);
     }
 
     private State getFailureCode() {
-        boolean fl = getBit(getDB_0Value(), 0);
+        boolean fl = getBit(getDB0Value(), 0);
 
         if (!fl) {
             return new QuantityType<>(-1, Units.ONE);
         }
 
-        return new QuantityType<>(getDB_1Value(), Units.ONE);
+        return new QuantityType<>(getDB1Value(), Units.ONE);
     }
 
     private State getMeasurementControl() {
-        return getBit(getDB_0Value(), 7) ? OnOffType.OFF : OnOffType.ON;
+        return getBit(getDB0Value(), 7) ? OnOffType.OFF : OnOffType.ON;
     }
 
     private State getFeedTemperature() {
-        boolean ts = getBit(getDB_0Value(), 1);
-        boolean mst = getBit(getDB_0Value(), 7);
+        boolean ts = getBit(getDB0Value(), 1);
+        boolean mst = getBit(getDB0Value(), 7);
 
         if (ts || mst) {
             return UnDefType.UNDEF;
         }
 
-        double value = getDB_2Value() * (60.0 / 255.0) + 20.0;
+        double value = getDB2Value() * (60.0 / 255.0) + 20.0;
 
         return new QuantityType<>(value, SIUnits.CELSIUS);
     }
 
     private State getTemperatureSetpoint() {
-        boolean ts = getBit(getDB_0Value(), 1);
+        boolean ts = getBit(getDB0Value(), 1);
 
         if (!ts) {
             return UnDefType.UNDEF;
         }
 
-        double value = getDB_2Value() * (20.0 / 255.0) + 10.0;
+        double value = getDB2Value() * (20.0 / 255.0) + 10.0;
 
         return new QuantityType<>(value, SIUnits.CELSIUS);
     }
 
     private State getButtonLock() {
-        return getBit(getDB_0Value(), 2) ? OnOffType.ON : OnOffType.OFF;
+        return getBit(getDB0Value(), 2) ? OnOffType.ON : OnOffType.OFF;
     }
 
     private State getValvePosition() {
-        return new QuantityType<>(getDB_3Value(), Units.PERCENT);
+        return new QuantityType<>(getDB3Value(), Units.PERCENT);
     }
 }
index 820adc147407e3715dd844186a8cd72b3ebaf27f..8c1646b7e0c257081931169f17956308ac5e7596 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_30_03 extends _4BSMessage {
 
     protected static final byte ALL_DIGITALPINS_HIGH = 0x0F;
@@ -47,10 +50,10 @@ public class A5_30_03 extends _4BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_TEMPERATURE:
-                double temp = (getDB_2Value() - 255) / -6.375;
+                double temp = (getDB2Value() - 255) / -6.375;
                 return new QuantityType<>(temp, SIUnits.CELSIUS);
         }
 
index f199ff2ed485de628f20154e575acf282bb95d13..44869c9acc6613c1cfa32251eedaefa7bd2e02e7 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.OnOffType;
@@ -27,6 +29,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_30_03_ELTAKO extends A5_30_03 {
 
     protected static final byte ALARM_ON = 0x0F;
@@ -46,8 +49,8 @@ public class A5_30_03_ELTAKO extends A5_30_03 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-        byte db1 = getDB_1();
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
+        byte db1 = getDB1();
         switch (channelId) {
             case CHANNEL_SMOKEDETECTION:
                 return db1 == ALARM_ON ? OnOffType.ON : (db1 == ALARM_OFF ? OnOffType.OFF : UnDefType.UNDEF);
index 42ddcf1cc4f98984139fe9b1691313141c7b1cf6..a48bb39afbbcd8186751a6de9660ef0353d1fcfb 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -34,6 +36,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_38_08_Blinds extends _4BSMessage {
 
     static final byte COMMAND_ID = 0x07;
@@ -63,10 +66,10 @@ public class A5_38_08_Blinds extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command outputCommand,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         switch (channelId) {
             case CHANNEL_ROLLERSHUTTER:
-                byte db0 = ZERO | SEND_NEW_STATE | TeachInBit;
+                byte db0 = ZERO | SEND_NEW_STATE | TEACHIN_BIT;
                 byte db1 = ZERO;
                 byte db2 = ZERO;
 
@@ -114,11 +117,11 @@ public class A5_38_08_Blinds extends _4BSMessage {
     }
 
     protected State getPositionData() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
         boolean paf = getBit(db0, 1);
 
         if (paf) {
-            int bsp = getDB_2Value();
+            int bsp = getDB2Value();
 
             if ((bsp >= 0) && (bsp <= 100)) {
                 return new PercentType(bsp);
@@ -129,11 +132,11 @@ public class A5_38_08_Blinds extends _4BSMessage {
     }
 
     protected State getAngleData() {
-        byte db0 = getDB_0();
+        byte db0 = getDB0();
         boolean paf = getBit(db0, 1);
 
         if (paf) {
-            byte db1 = getDB_1();
+            byte db1 = getDB1();
 
             boolean as = getBit(db1, 7);
             int an = (db1 & 0x7F) * 2;
@@ -147,8 +150,8 @@ public class A5_38_08_Blinds extends _4BSMessage {
     }
 
     @Override
-    public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
-            Configuration config) {
+    public State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_ROLLERSHUTTER:
                 return getPositionData();
index 058291541fa5b98b52c67fdf5c9133cadd32b5a3..148b5fc70389b65396a235a89f805e874d6c69d2 100644 (file)
@@ -17,6 +17,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.ZERO;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelDimmerConfig;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -38,12 +40,13 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_38_08_Dimming extends _4BSMessage {
 
-    static final byte CommandId = 0x02;
-    static final byte SwitchOff = 0x00;
-    static final byte SwitchOn = 0x01;
-    static final byte Switch100Percent = 0x64;
+    static final byte COMMAND_ID = 0x02;
+    static final byte SWITCH_OFF = 0x00;
+    static final byte SWITCH_ON = 0x01;
+    static final byte SWITCH_100_PERCENT = 0x64;
 
     public A5_38_08_Dimming() {
         super();
@@ -55,7 +58,7 @@ public class A5_38_08_Dimming extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command outputCommand,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         switch (channelId) {
             case CHANNEL_DIMMER:
                 byte dimmValue;
@@ -63,58 +66,61 @@ public class A5_38_08_Dimming extends _4BSMessage {
                 if (outputCommand instanceof DecimalType) {
                     dimmValue = ((DecimalType) outputCommand).byteValue();
                 } else if (outputCommand instanceof OnOffType) {
-                    dimmValue = ((OnOffType) outputCommand == OnOffType.ON) ? Switch100Percent : ZERO;
+                    dimmValue = ((OnOffType) outputCommand == OnOffType.ON) ? SWITCH_100_PERCENT : ZERO;
                 } else if (outputCommand instanceof IncreaseDecreaseType) {
                     dimmValue = ((IncreaseDecreaseType) outputCommand == IncreaseDecreaseType.INCREASE)
-                            ? Switch100Percent
+                            ? SWITCH_100_PERCENT
                             : ZERO;
                 } else if (outputCommand instanceof UpDownType) {
-                    dimmValue = ((UpDownType) outputCommand == UpDownType.UP) ? Switch100Percent : ZERO;
+                    dimmValue = ((UpDownType) outputCommand == UpDownType.UP) ? SWITCH_100_PERCENT : ZERO;
                 } else {
                     throw new IllegalArgumentException(outputCommand.toFullString() + " is no valid dimming command.");
                 }
+                if (config != null) {
+                    EnOceanChannelDimmerConfig c = config.as(EnOceanChannelDimmerConfig.class);
 
-                EnOceanChannelDimmerConfig c = config.as(EnOceanChannelDimmerConfig.class);
-
-                byte storeByte = ZERO; // "Store final value" (standard) vs. "block value" (Eltako)
+                    byte storeByte = ZERO; // "Store final value" (standard) vs. "block value" (Eltako)
 
-                if (!c.eltakoDimmer) {
-                    dimmValue *= 2.55; // 0-100% = 0-255
+                    if (!c.eltakoDimmer) {
+                        dimmValue *= 2.55; // 0-100% = 0-255
 
-                    if (c.storeValue) {
-                        storeByte = 0x02; // set DB0.1
-                    }
-                } else {
-                    if (c.storeValue) {
-                        storeByte = 0x04; // set DB0.2
+                        if (c.storeValue) {
+                            storeByte = 0x02; // set DB0.1
+                        }
+                    } else {
+                        if (c.storeValue) {
+                            storeByte = 0x04; // set DB0.2
+                        }
                     }
-                }
 
-                byte rampingTime = Integer.valueOf(c.rampingTime).byteValue();
-                byte switchingCommand = (dimmValue == ZERO) ? SwitchOff : SwitchOn;
+                    byte rampingTime = Integer.valueOf(c.rampingTime).byteValue();
+                    byte switchingCommand = (dimmValue == ZERO) ? SWITCH_OFF : SWITCH_ON;
 
-                setData(CommandId, dimmValue, rampingTime, (byte) (TeachInBit | storeByte | switchingCommand));
+                    setData(COMMAND_ID, dimmValue, rampingTime, (byte) (TEACHIN_BIT | storeByte | switchingCommand));
+                } else {
+                    logger.error("Cannot handle command {}, when configuration is null", outputCommand.toFullString());
+                }
 
                 break;
         }
     }
 
     @Override
-    public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
-            Configuration config) {
+    public State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_DIMMER:
-                if (!getBit(getDB_0(), 0)) {
+                if (!getBit(getDB0(), 0)) {
                     // Switching Command is OFF (DB0.0==0), return 0%
                     return new PercentType(0);
                 } else {
                     // DB2 contains the Dimming value (absolute[0...255] or relative/Eltako [0...100])
-                    int dimmValue = getDB_2Value();
+                    int dimmValue = getDB2Value();
 
                     EnOceanChannelDimmerConfig c = config.as(EnOceanChannelDimmerConfig.class);
 
                     // if Standard dimmer and Dimming Range is absolute (DB0.2==0),
-                    if (!c.eltakoDimmer && !getBit(getDB_0(), 2)) {
+                    if (!c.eltakoDimmer && !getBit(getDB0(), 2)) {
                         // map range [0...255] to [0%...100%]
                         dimmValue /= 2.55;
                     }
index a45dca4d67293cede29b12f0efb25e7d47d5d8d2..da79e73d8699e3dd66b0a5bb126ad59b4e6ff42a 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.ZERO;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -27,11 +29,12 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_38_08_Switching extends _4BSMessage {
 
-    static final byte CommandId = 0x01;
-    static final byte SwitchOff = 0x00;
-    static final byte SwitchOn = 0x01;
+    static final byte COMMAND_ID = 0x01;
+    static final byte SWITCH_OFF = 0x00;
+    static final byte SWITCH_ON = 0x01;
 
     public A5_38_08_Switching() {
         super();
@@ -43,11 +46,11 @@ public class A5_38_08_Switching extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command outputCommand,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if ((OnOffType) outputCommand == OnOffType.ON) {
-            setData(CommandId, ZERO, ZERO, (byte) (TeachInBit | SwitchOn));
+            setData(COMMAND_ID, ZERO, ZERO, (byte) (TEACHIN_BIT | SWITCH_ON));
         } else {
-            setData(CommandId, ZERO, ZERO, (byte) (TeachInBit | SwitchOff));
+            setData(COMMAND_ID, ZERO, ZERO, (byte) (TEACHIN_BIT | SWITCH_OFF));
         }
     }
 }
index 4823f91e33065bf4a4611b58bad51dfe1e59ef3d..b10ba909675449022a8d691f418ccb61bb060f25 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.ZERO;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,15 +30,16 @@ import org.openhab.core.types.UnDefType;
 
 /**
  *
- * @author Andreas Hofinger
+ * @author Andreas Hofinger - Initial contribution
  */
+@NonNullByDefault
 public class A5_3F_7F_EltakoFRM extends _4BSMessage {
 
-    static final byte Stop = 0x00;
-    static final byte Move = 0x03;
+    static final byte STOP = 0x00;
+    static final byte MOVE = 0x03;
 
-    static final int Top = 0xC8;
-    static final int Bottom = 0x00;
+    static final int TOP = 0xC8;
+    static final int BOTTOM = 0x00;
 
     public A5_3F_7F_EltakoFRM() {
         super();
@@ -48,36 +51,34 @@ public class A5_3F_7F_EltakoFRM extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            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());
-            int position = Math.min(Top, Math.max(Bottom, rawPosition));
-            setData((byte) position, ZERO, Move, TeachInBit);
+                    (PercentType.HUNDRED.floatValue() - target.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) {
-                setData((byte) Top, ZERO, Move, TeachInBit); // => 0 percent
+                setData((byte) TOP, ZERO, MOVE, TEACHIN_BIT); // => 0 percent
             } else if ((UpDownType) command == UpDownType.DOWN) {
-                setData((byte) Bottom, ZERO, Move, TeachInBit); // => 100 percent
+                setData((byte) BOTTOM, ZERO, MOVE, TEACHIN_BIT); // => 100 percent
             }
         } else if (command instanceof StopMoveType) {
             if ((StopMoveType) command == StopMoveType.STOP) {
-                setData(ZERO, ZERO, Stop, TeachInBit);
+                setData(ZERO, ZERO, STOP, TEACHIN_BIT);
             }
         }
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         // 0x0A.. Move was locked for switch
         // 0x0E.. Move was not locked
-        if (getDB_2() == ZERO && getDB_1() == Move && (getDB_0() == 0x0A || getDB_0() == 0x0E)) {
-            int position = getDB_3Value();
-            float percentage = 100.0f * (Top - position) / (float) (Top - Bottom);
+        if (getDB2() == ZERO && getDB1() == MOVE && (getDB0() == 0x0A || getDB0() == 0x0E)) {
+            int position = getDB3Value();
+            float percentage = 100.0f * (TOP - position) / (float) (TOP - BOTTOM);
             return new PercentType(Math.round(Math.min(100, (Math.max(0, percentage)))));
         }
         return UnDefType.UNDEF;
index df9dc4450577461b19ca71580132f25b8a680aef..3d6e55d0c7378a24b675f81d3183ea95087829fe 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.ZERO;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRollershutterConfig;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -31,14 +33,15 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_3F_7F_EltakoFSB extends _4BSMessage {
 
-    static final byte Stop = 0x00;
-    static final byte MoveUp = 0x01;
-    static final byte MoveDown = 0x02;
+    static final byte STOP = 0x00;
+    static final byte MOVE_UP = 0x01;
+    static final byte MOVE_DOWN = 0x02;
 
-    static final byte Up = 0x70;
-    static final byte Down = 0x50;
+    static final byte UP = 0x70;
+    static final byte DOWN = 0x50;
 
     public A5_3F_7F_EltakoFSB() {
         super();
@@ -50,9 +53,11 @@ public class A5_3F_7F_EltakoFSB extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         int shutTime = 0xFF;
-        if (config != null) {
+        if (config == null) {
+            logger.debug("No configuration, shutTime fallback to {}", shutTime);
+        } else {
             shutTime = Math.min(255, config.as(EnOceanChannelRollershutterConfig.class).shutTime);
         }
 
@@ -61,60 +66,57 @@ public class A5_3F_7F_EltakoFSB extends _4BSMessage {
 
             PercentType target = (PercentType) command;
             if (target.intValue() == PercentType.ZERO.intValue()) {
-                setData(ZERO, (byte) shutTime, MoveUp, TeachInBit); // => move completely up
+                setData(ZERO, (byte) shutTime, MOVE_UP, TEACHIN_BIT); // => move completely up
             } else if (target.intValue() == PercentType.HUNDRED.intValue()) {
-                setData(ZERO, (byte) shutTime, MoveDown, TeachInBit); // => move completely down
+                setData(ZERO, (byte) shutTime, MOVE_DOWN, TEACHIN_BIT); // => move completely down
             } else if (channelState != null) {
                 PercentType current = channelState.as(PercentType.class);
-                if (config != null && current != null) {
+                if (current != null) {
                     if (current.intValue() != target.intValue()) {
-                        byte direction = current.intValue() > target.intValue() ? MoveUp : MoveDown;
+                        byte direction = current.intValue() > target.intValue() ? MOVE_UP : MOVE_DOWN;
                         byte duration = (byte) Math.min(255,
                                 (Math.abs(current.intValue() - target.intValue()) * shutTime)
                                         / PercentType.HUNDRED.intValue());
 
-                        setData(ZERO, duration, direction, TeachInBit);
+                        setData(ZERO, duration, direction, TEACHIN_BIT);
                     }
                 }
             }
 
         } else if (command instanceof UpDownType) {
             if ((UpDownType) command == UpDownType.UP) {
-                setData(ZERO, (byte) shutTime, MoveUp, TeachInBit); // => 0 percent
+                setData(ZERO, (byte) shutTime, MOVE_UP, TEACHIN_BIT); // => 0 percent
             } else if ((UpDownType) command == UpDownType.DOWN) {
-                setData(ZERO, (byte) shutTime, MoveDown, TeachInBit); // => 100 percent
+                setData(ZERO, (byte) shutTime, MOVE_DOWN, TEACHIN_BIT); // => 100 percent
             }
         } else if (command instanceof StopMoveType) {
             if ((StopMoveType) command == StopMoveType.STOP) {
-                setData(ZERO, (byte) 0xFF, Stop, TeachInBit);
+                setData(ZERO, (byte) 0xFF, STOP, TEACHIN_BIT);
             }
         }
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         State currentState = getCurrentStateFunc.apply(channelId);
 
         if (currentState != null) {
-            int duration = ((getDB_3Value() << 8) + getDB_2Value()) / 10; // => Time in DB3 and DB2 is given
-                                                                          // in ms
-
-            if (config != null) {
-                EnOceanChannelRollershutterConfig c = config.as(EnOceanChannelRollershutterConfig.class);
-                if (duration == c.shutTime) {
-                    return getDB_1() == MoveUp ? PercentType.ZERO : PercentType.HUNDRED;
-                } else {
-                    PercentType current = PercentType.ZERO;
-                    if (currentState instanceof PercentType) {
-                        current = currentState.as(PercentType.class);
-                    }
+            int duration = ((getDB3Value() << 8) + getDB2Value()) / 10; // => Time in DB3 and DB2 is given
+                                                                        // in ms
+            EnOceanChannelRollershutterConfig c = config.as(EnOceanChannelRollershutterConfig.class);
+            if (duration == c.shutTime) {
+                return getDB1() == MOVE_UP ? PercentType.ZERO : PercentType.HUNDRED;
+            } else {
+                PercentType current = PercentType.ZERO;
+                if (currentState instanceof PercentType) {
+                    current = currentState.as(PercentType.class);
+                }
 
-                    int direction = getDB_1() == MoveUp ? -1 : 1;
-                    if (c.shutTime != -1 && c.shutTime != 0) {
-                        return new PercentType(Math.min(100, (Math.max(0, current.intValue()
-                                + direction * ((duration * PercentType.HUNDRED.intValue()) / c.shutTime)))));
-                    }
+                int direction = getDB1() == MOVE_UP ? -1 : 1;
+                if (current != null && c.shutTime != -1 && c.shutTime != 0) {
+                    return new PercentType(Math.min(100, (Math.max(0, current.intValue()
+                            + direction * ((duration * PercentType.HUNDRED.intValue()) / c.shutTime)))));
                 }
             }
         }
index 5279c4db1b1b43a5a4d656e64583b381a84ecc0b..276edf02f6ae9c5b727aa37de2af0803aa785d71 100644 (file)
@@ -14,6 +14,8 @@ package org.openhab.binding.enocean.internal.eep.A5_3F;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelTransformationConfig;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -27,6 +29,7 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class A5_3F_7F_Universal extends _4BSMessage {
 
     // This class is currently not used => instead use Generic4BS
@@ -41,21 +44,22 @@ public class A5_3F_7F_Universal extends _4BSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-        if (config != null) {
-            try {
-                EnOceanChannelTransformationConfig transformationInfo = config
-                        .as(EnOceanChannelTransformationConfig.class);
-                String c = Transformation.transform(transformationInfo.transformationType,
-                        transformationInfo.transformationFunction, command.toString());
-
-                if (c != null && !c.equals(command.toString())) {
-                    setData(HexUtils.hexToBytes(c));
-                }
-
-            } catch (Exception e) {
-                logger.debug("Command {} could not transformed", command.toString());
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
+        if (config == null) {
+            logger.error("Command {} could not transformed without proper configuration", command.toString());
+            return;
+        }
+        try {
+            EnOceanChannelTransformationConfig transformationInfo = config.as(EnOceanChannelTransformationConfig.class);
+            String c = Transformation.transform(transformationInfo.transformationType,
+                    transformationInfo.transformationFunction, command.toString());
+
+            if (c != null && !c.equals(command.toString())) {
+                setData(HexUtils.hexToBytes(c));
             }
+        } catch (IllegalArgumentException e) {
+            logger.debug("Command {} could not transformed", command.toString());
+            throw e;
         }
     }
 }
index 281a958192abecaaff8bdd4d8bded9ab1edf7a8a..40a850a623f041ebc7c5fdfea8b1f074a224708d 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -30,14 +32,15 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class PTM200Message extends _RPSMessage {
 
-    static final byte On = 0x70;
-    static final byte Off = 0x50;
-    static final byte Up = 0x70;
-    static final byte Down = 0x50;
-    static final byte Open = (byte) 0xE0;
-    static final byte Closed = (byte) 0xF0;
+    static final byte SWITCH_ON = 0x70;
+    static final byte SWITCH_OFF = 0x50;
+    static final byte UP = 0x70;
+    static final byte DOWN = 0x50;
+    static final byte OPEN = (byte) 0xE0;
+    static final byte CLOSED = (byte) 0xF0;
 
     public PTM200Message() {
         super();
@@ -49,26 +52,25 @@ public class PTM200Message extends _RPSMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_GENERAL_SWITCHING:
-                return bytes[0] == On ? OnOffType.ON : OnOffType.OFF;
+                return bytes[0] == SWITCH_ON ? OnOffType.ON : OnOffType.OFF;
             case CHANNEL_ROLLERSHUTTER:
-                return bytes[0] == Up ? PercentType.ZERO : (bytes[0] == Down ? PercentType.HUNDRED : UnDefType.UNDEF);
+                return bytes[0] == UP ? PercentType.ZERO : (bytes[0] == DOWN ? PercentType.HUNDRED : UnDefType.UNDEF);
             case CHANNEL_CONTACT:
                 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
                 if (c.inverted) {
-                    return bytes[0] == Open ? OpenClosedType.CLOSED
-                            : (bytes[0] == Closed ? OpenClosedType.OPEN : UnDefType.UNDEF);
+                    return bytes[0] == OPEN ? OpenClosedType.CLOSED
+                            : (bytes[0] == CLOSED ? OpenClosedType.OPEN : UnDefType.UNDEF);
                 } else {
-                    return bytes[0] == Open ? OpenClosedType.OPEN
-                            : (bytes[0] == Closed ? OpenClosedType.CLOSED : UnDefType.UNDEF);
+                    return bytes[0] == OPEN ? OpenClosedType.OPEN
+                            : (bytes[0] == CLOSED ? OpenClosedType.CLOSED : UnDefType.UNDEF);
                 }
         }
 
index 1da53766f66f27ec70ea7799bc6a5ce659a694bd..8097205b248888d708d9c1181d6419284ba72ff5 100644 (file)
@@ -14,18 +14,20 @@ package org.openhab.binding.enocean.internal.eep.Base;
 
 import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class UTEResponse extends _VLDMessage {
 
-    public static final byte TeachIn_MASK = 0x3f;
-    public static final byte CommunicationType_MASK = (byte) 0x80;
-    public static final byte ResponseNeeded_MASK = 0x40;
-    public static final byte TeachIn_NotSpecified = 0x20;
+    public static final byte TEACHIN_MASK = 0x3f;
+    public static final byte COMMUNICATION_TYPE_MASK = (byte) 0x80;
+    public static final byte RESPONSE_NEEDED_MASK = 0x40;
+    public static final byte TEACHIN_NPTSPECIFIED = 0x20;
 
     public UTEResponse(ERP1Message packet, boolean teachIn) {
         int dataLength = packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
index 318fa27baf36be1596b6b2b7a38c1495ba336917..08cfec6ffc5bf42be371b82987f825ef7bdee8ed 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.Base;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -19,9 +20,10 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class _1BSMessage extends EEP {
 
-    public static final int TeachInBit = 0x08;
+    public static final int TEACHIN_BIT = 0x08;
 
     public _1BSMessage(ERP1Message packet) {
         super(packet);
index 1c5fd6889e5ac5b732c6f4d5a999a58e1498151b..df1faddcddea41f705e91c87d2e95f4765da79ce 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.enocean.internal.eep.Base;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelTeachInConfig;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.eep.EEPType;
@@ -23,6 +25,7 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class _4BSMessage extends EEP {
 
     protected boolean supportsTeachInVariation3 = false;
@@ -39,49 +42,49 @@ public abstract class _4BSMessage extends EEP {
         super();
     }
 
-    public static final byte TeachInBit = 0x08;
-    public static final byte LRN_Type_Mask = (byte) 0x80;
+    public static final byte TEACHIN_BIT = 0x08;
+    public static final byte LRN_TYPE_MASK = (byte) 0x80;
 
-    public byte getDB_0() {
+    public byte getDB0() {
         return bytes[3];
     }
 
-    public int getDB_0Value() {
-        return (getDB_0() & 0xFF);
+    public int getDB0Value() {
+        return (getDB0() & 0xFF);
     }
 
-    public byte getDB_1() {
+    public byte getDB1() {
         return bytes[2];
     }
 
-    public int getDB_1Value() {
-        return (getDB_1() & 0xFF);
+    public int getDB1Value() {
+        return (getDB1() & 0xFF);
     }
 
-    public byte getDB_2() {
+    public byte getDB2() {
         return bytes[1];
     }
 
-    public int getDB_2Value() {
-        return (getDB_2() & 0xFF);
+    public int getDB2Value() {
+        return (getDB2() & 0xFF);
     }
 
-    public byte getDB_3() {
+    public byte getDB3() {
         return bytes[0];
     }
 
-    public int getDB_3Value() {
-        return (getDB_3() & 0xFF);
+    public int getDB3Value() {
+        return (getDB3() & 0xFF);
     }
 
     @Override
-    protected void teachInQueryImpl(Configuration config) {
+    protected void teachInQueryImpl(@Nullable Configuration config) {
         if (config == null) {
             return;
         }
 
         EnOceanChannelTeachInConfig c = config.as(EnOceanChannelTeachInConfig.class);
-        if (c.teachInMSG == null || c.teachInMSG.isEmpty()) {
+        if (c.teachInMSG.isEmpty()) {
             EEPType type = getEEPType();
 
             byte db3 = (byte) ((getEEPType().getFunc() << 2) | ((type.getType()) >>> 5));
@@ -95,12 +98,14 @@ public abstract class _4BSMessage extends EEP {
             } catch (Exception e) {
             }
 
-            setData(db3, db2, db1, LRN_Type_Mask);
+            setData(db3, db2, db1, LRN_TYPE_MASK);
         } else {
             try {
                 byte[] msg = HexUtils.hexToBytes(c.teachInMSG);
                 setData(msg);
-            } catch (Exception e) {
+            } catch (IllegalArgumentException e) {
+                logger.debug("Command TeachIn could not transformed");
+                throw e;
             }
         }
     }
index 30bc10d492137a1a93a8890af7c718ad333fc324..61b7762baae602f264cad430b4342230df8d932a 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.enocean.internal.eep.Base;
 
 import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
 
@@ -21,6 +22,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
  *
  * @author Dominik Vorreiter - Initial contribution
  */
+@NonNullByDefault
 public class _4BSTeachInVariation3Response extends _4BSMessage {
 
     public _4BSTeachInVariation3Response(ERP1Message packet, boolean teachIn) {
index 67c660a2c6a6ab4ffa47eb86296afc1b15b4bfca..f595fdda111d6bfa64dc516469641c5b3d87df9a 100644 (file)
@@ -12,6 +12,7 @@
  */
 package org.openhab.binding.enocean.internal.eep.Base;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -19,13 +20,14 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class _RPSMessage extends EEP {
 
     protected boolean t21;
     protected boolean nu;
 
-    public static final byte T21Flag = 0x20;
-    public static final byte NUFlag = 0x10;
+    public static final byte T21_FLAG = 0x20;
+    public static final byte NU_FLAG = 0x10;
 
     public _RPSMessage() {
         super();
@@ -46,8 +48,8 @@ public abstract class _RPSMessage extends EEP {
     @Override
     public EEP setStatus(byte status) {
         super.setStatus(status);
-        t21 = (status & T21Flag) != 0;
-        nu = (status & NUFlag) != 0;
+        t21 = (status & T21_FLAG) != 0;
+        nu = (status & NU_FLAG) != 0;
 
         return this;
     }
index 77c55c5a43f2000b1fe4e737fc2e1ece6154c1d9..2be0d4f53a9048bd8fb1291bbee571f9a08fb233 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.enocean.internal.eep.Base;
 
 import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -21,6 +22,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class _SIGMessage extends EEP {
 
     public static final byte MID_ENERGY_STATUS = 0x06;
@@ -35,8 +37,9 @@ public abstract class _SIGMessage extends EEP {
 
     @Override
     protected int getDataLength() {
-        if (packet != null) {
-            return packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
+        ERP1Message localPacket = packet;
+        if (localPacket != null) {
+            return localPacket.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
         } else {
             return bytes.length;
         }
index 409f64e33bbfea4c5d554f1dc36e67639042ebe7..fcfa1bc6450a6ea1d6d1480792bd7ad9ba49a85f 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.enocean.internal.eep.Base;
 
 import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
@@ -21,6 +22,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class _VLDMessage extends EEP {
 
     public _VLDMessage() {
@@ -33,11 +35,11 @@ public abstract class _VLDMessage extends EEP {
 
     @Override
     protected int getDataLength() {
-        if (packet != null) {
-            return packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
-        } else {
-            return bytes.length;
+        ERP1Message localPacket = packet;
+        if (localPacket != null) {
+            return localPacket.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
         }
+        return bytes.length;
     }
 
     @Override
index 56925790902a59fffc28938017f197bdb4528e0a..fce24d07d6c482a18358f155ca3da60c5481d43e 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._SIGMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -28,6 +30,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D0_06 extends _SIGMessage {
 
     public D0_06() {
@@ -39,8 +42,8 @@ public class D0_06 extends _SIGMessage {
     }
 
     @Override
-    public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
-            Configuration config) {
+    public State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
             return new QuantityType<>(bytes[1] & 0xFF, Units.PERCENT);
         }
index 8f5d502514bf0db795bd3a346805433b6cce52e9..074ba0af22bbb199d7106d62d0fa903f87dc4023 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelDimmerConfig;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.eep.EEPHelper;
@@ -37,25 +39,26 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class D2_01 extends _VLDMessage {
 
-    protected final byte cmdMask = 0x0f;
-    protected final byte outputValueMask = 0x7f;
-    protected final byte outputChannelMask = 0x1f;
+    protected static final byte CMD_MASK = 0x0f;
+    protected static final byte OUTPUT_VALUE_MASK = 0x7f;
+    protected static final byte OUTPUT_CHANNEL_MASK = 0x1f;
 
-    protected final byte CMD_ACTUATOR_SET_STATUS = 0x01;
-    protected final byte CMD_ACTUATOR_STATUS_QUERY = 0x03;
-    protected final byte CMD_ACTUATOR_STATUS_RESPONE = 0x04;
-    protected final byte CMD_ACTUATOR_MEASUREMENT_QUERY = 0x06;
-    protected final byte CMD_ACTUATOR_MEASUREMENT_RESPONE = 0x07;
+    protected static final byte CMD_ACTUATOR_SET_STATUS = 0x01;
+    protected static final byte CMD_ACTUATOR_STATUS_QUERY = 0x03;
+    protected static final byte CMD_ACTUATOR_STATUS_RESPONE = 0x04;
+    protected static final byte CMD_ACTUATOR_MEASUREMENT_QUERY = 0x06;
+    protected static final byte CMD_ACTUATOR_MEASUREMENT_RESPONE = 0x07;
 
-    protected final byte AllChannels_Mask = 0x1e;
-    protected final byte ChannelA_Mask = 0x00;
-    protected final byte ChannelB_Mask = 0x01;
+    protected static final byte ALL_CHANNELS_MASK = 0x1e;
+    protected static final byte CHANNEL_A_MASK = 0x00;
+    protected static final byte CHANNEL_B_MASK = 0x01;
 
-    protected final byte STATUS_SWITCHING_ON = 0x01;
-    protected final byte STATUS_SWITCHING_OFF = 0x00;
-    protected final byte STATUS_DIMMING_100 = 0x64;
+    protected static final byte STATUS_SWITCHING_ON = 0x01;
+    protected static final byte STATUS_SWITCHING_OFF = 0x00;
+    protected static final byte STATUS_DIMMING_100 = 0x64;
 
     public D2_01() {
         super();
@@ -66,7 +69,7 @@ public abstract class D2_01 extends _VLDMessage {
     }
 
     protected byte getCMD() {
-        return (byte) (bytes[0] & cmdMask);
+        return (byte) (bytes[0] & CMD_MASK);
     }
 
     protected void setSwitchingData(OnOffType command, byte outputChannel) {
@@ -83,19 +86,19 @@ public abstract class D2_01 extends _VLDMessage {
 
     protected State getSwitchingData() {
         if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE) {
-            return (bytes[bytes.length - 1] & outputValueMask) == STATUS_SWITCHING_OFF ? OnOffType.OFF : OnOffType.ON;
+            return (bytes[bytes.length - 1] & OUTPUT_VALUE_MASK) == STATUS_SWITCHING_OFF ? OnOffType.OFF : OnOffType.ON;
         }
 
         return UnDefType.UNDEF;
     }
 
     protected byte getChannel() {
-        return (byte) (bytes[1] & outputChannelMask);
+        return (byte) (bytes[1] & OUTPUT_CHANNEL_MASK);
     }
 
     protected State getSwitchingData(byte channel) {
-        if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE && (getChannel() == channel || getChannel() == AllChannels_Mask)) {
-            return (bytes[bytes.length - 1] & outputValueMask) == STATUS_SWITCHING_OFF ? OnOffType.OFF : OnOffType.ON;
+        if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE && (getChannel() == channel || getChannel() == ALL_CHANNELS_MASK)) {
+            return (bytes[bytes.length - 1] & OUTPUT_VALUE_MASK) == STATUS_SWITCHING_OFF ? OnOffType.OFF : OnOffType.ON;
         }
 
         return UnDefType.UNDEF;
@@ -124,7 +127,7 @@ public abstract class D2_01 extends _VLDMessage {
 
     protected State getDimmingData() {
         if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE) {
-            return new PercentType((bytes[bytes.length - 1] & outputValueMask));
+            return new PercentType((bytes[bytes.length - 1] & OUTPUT_VALUE_MASK));
         }
 
         return UnDefType.UNDEF;
@@ -197,48 +200,52 @@ public abstract class D2_01 extends _VLDMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equals(CHANNEL_GENERAL_SWITCHING)) {
             if (command == RefreshType.REFRESH) {
-                setSwitchingQueryData(AllChannels_Mask);
+                setSwitchingQueryData(ALL_CHANNELS_MASK);
             } else {
-                setSwitchingData((OnOffType) command, AllChannels_Mask);
+                setSwitchingData((OnOffType) command, ALL_CHANNELS_MASK);
             }
         } else if (channelId.equals(CHANNEL_GENERAL_SWITCHINGA)) {
             if (command == RefreshType.REFRESH) {
-                setSwitchingQueryData(ChannelA_Mask);
+                setSwitchingQueryData(CHANNEL_A_MASK);
             } else {
-                setSwitchingData((OnOffType) command, ChannelA_Mask);
+                setSwitchingData((OnOffType) command, CHANNEL_A_MASK);
             }
         } else if (channelId.equals(CHANNEL_GENERAL_SWITCHINGB)) {
             if (command == RefreshType.REFRESH) {
-                setSwitchingQueryData(ChannelB_Mask);
+                setSwitchingQueryData(CHANNEL_B_MASK);
             } else {
-                setSwitchingData((OnOffType) command, ChannelB_Mask);
+                setSwitchingData((OnOffType) command, CHANNEL_B_MASK);
             }
         } else if (channelId.equals(CHANNEL_DIMMER)) {
             if (command == RefreshType.REFRESH) {
-                setSwitchingQueryData(AllChannels_Mask);
+                setSwitchingQueryData(ALL_CHANNELS_MASK);
             } else {
-                setDimmingData(command, AllChannels_Mask, config);
+                if (config != null) {
+                    setDimmingData(command, ALL_CHANNELS_MASK, config);
+                } else {
+                    logger.error("Cannot set dimming data when config is null");
+                }
             }
         } else if (channelId.equals(CHANNEL_INSTANTPOWER) && command == RefreshType.REFRESH) {
-            setPowerMeasurementQueryData(AllChannels_Mask);
+            setPowerMeasurementQueryData(ALL_CHANNELS_MASK);
         } else if (channelId.equals(CHANNEL_TOTALUSAGE) && command == RefreshType.REFRESH) {
-            setEnergyMeasurementQueryData(AllChannels_Mask);
+            setEnergyMeasurementQueryData(ALL_CHANNELS_MASK);
         }
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_GENERAL_SWITCHING:
                 return getSwitchingData();
             case CHANNEL_GENERAL_SWITCHINGA:
-                return getSwitchingData(ChannelA_Mask);
+                return getSwitchingData(CHANNEL_A_MASK);
             case CHANNEL_GENERAL_SWITCHINGB:
-                return getSwitchingData(ChannelB_Mask);
+                return getSwitchingData(CHANNEL_B_MASK);
             case CHANNEL_DIMMER:
                 return getDimmingData();
             case CHANNEL_INSTANTPOWER:
index a6bdd27604e29a56816c981aa3259ec99479b750..34fdaa9b2c307522efc117441721f3deda76cc55 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_00 extends D2_01 {
 
     public D2_01_00() {
index f9f31429e3f7520439ad54f844c41fca4ab1a285..12d461e40ea4cc39b654cd8ac4ebd29ed96b852b 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_01 extends D2_01 {
 
     public D2_01_01() {
index aca3594e4a42bd7ea7233c96b26a7ea65f6413a8..3ba5d49a3d2a67bf5687fc805258ed15de4726fc 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_02 extends D2_01 {
 
     public D2_01_02() {
index f5e06244775e95bc1300fcbcdbed6fc0d26e0b3a..57bbf38c441d6a0ae13f3586c626966beea087e4 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_03 extends D2_01 {
 
     public D2_01_03() {
index 7fd1ec2368e1ff4b2f132ddece9699a20f3ac867..5be7d7741f59a3b1e00165c9e84986b9cf3934e4 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_04 extends D2_01 {
 
     public D2_01_04() {
index 016db7b6e99eb4f6a4329b28747806569d1f9d41..7168dc3415510d31a0d684ca745920b3e9e4b743 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_05 extends D2_01 {
 
     public D2_01_05() {
index d26e3c0d302dec9689b52459c5e2390323e46c50..2f74387c187f2365fd7333984125862b85fe023b 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_06 extends D2_01 {
 
     public D2_01_06() {
index 14e771f78134c489ec667dbb69381589afa4bfbc..d4c852f8b7a05eb840d275364c83c23dee365fdb 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_07 extends D2_01 {
 
     public D2_01_07() {
index 99e3bb0ab1a9741cfa74cb44cf3bbdb215067663..77da89812055b45e4ae71581170ab61479ee317c 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_08 extends D2_01 {
 
     public D2_01_08() {
index e585829c0c7f9677c7a2e7dc2fef31eb100962bc..0bad2c87c4059affdce2f7aeaf3363c5e9324da2 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_09 extends D2_01 {
 
     public D2_01_09() {
index 128be45716d4bad46838ff55a86d601669e5e826..75bbde8fd48c733c439b19a8aa5c597585370734 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -30,6 +32,7 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_09_Permundo extends D2_01 {
 
     public D2_01_09_Permundo() {
@@ -42,7 +45,7 @@ public class D2_01_09_Permundo extends D2_01 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equals(CHANNEL_REPEATERMODE)) {
             setRepeaterMode(command);
         } else if (channelId.equals(CHANNEL_ECOMODE)) {
@@ -54,7 +57,7 @@ public class D2_01_09_Permundo extends D2_01 {
 
     private void setRepeaterMode(Command command) {
         if (command == RefreshType.REFRESH) {
-            senderId = null; // make this message invalid as we do not support refresh of repeater status
+            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()) {
                 case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
@@ -71,7 +74,7 @@ public class D2_01_09_Permundo extends D2_01 {
 
     private void setEcoMode(Command command) {
         if (command == RefreshType.REFRESH) {
-            senderId = null; // make this message invalid as we do not support refresh of ecomode status
+            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) {
                 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x01);
index a42ea2afdf096ddb7937596d69d14b6213d8ecb9..5688b506c999cf0f0d9f332e8401e14f47cb2319 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0A extends D2_01 {
 
     public D2_01_0A() {
index fec6d92f0e186a5a8e3092770f937d37d7cef0db..56bbff40e8cfd0a2bee54b44d14fea5020d35ffc 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0B extends D2_01 {
 
     public D2_01_0B() {
index f36c194fab38340312eaa2db7fd8d6b8b43f6a4e..cbbfa4ce46ad86bf75dd9cd9e87093c1655bacec 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0C extends D2_01 {
 
     public D2_01_0C() {
index 6d166e08605fdf810b9111f80ff5c57653b554f6..dd78d7412dd44f4df7ab712292bd519cb5e7a454 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0D extends D2_01 {
 
     public D2_01_0D() {
index dc40b5e8d78cccfe051ed9579b7ebbaf8817178c..5b61a3f231a2c60a864555a60ce663402fda3983 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0E extends D2_01 {
 
     public D2_01_0E() {
index e94e4e13fd7baa23d8e1bf0d31770c9db4684fa3..7f44f496dc644e50ea690df059305209251173ad 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0F extends D2_01 {
 
     public D2_01_0F() {
index 4aa35a81efe90af98b6902e46dd2afefe72d2ec2..dcea0e6f25ee27f71456c76e438ef42df58c9532 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -29,6 +31,7 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_0F_NodON extends D2_01 {
 
     public D2_01_0F_NodON() {
@@ -41,10 +44,10 @@ public class D2_01_0F_NodON extends D2_01 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equalsIgnoreCase(CHANNEL_REPEATERMODE)) {
             if (command instanceof RefreshType) {
-                senderId = null; // make this message invalid as we do not support refresh of repeter status
+                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()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
index bbee729797f70d106ca86fdaa16e3df3ee746221..5d51947429a78b6ff681d8786bf3c78ea45b4730 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_11 extends D2_01 {
 
     public D2_01_11() {
index baaee3572fe92b3f3ced4f6977cb59a75ef5f2f3..826d5c6de03f513923ed2a3b35cc18cd6a976715 100644 (file)
  */
 package org.openhab.binding.enocean.internal.eep.D2_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_12 extends D2_01 {
 
     public D2_01_12() {
index cd1c568d29ada733248f078f7538fba94cb60ad6..28af568f22d8a569f1e631854685bc3d01626ede 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -29,6 +31,7 @@ import org.openhab.core.types.State;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_01_12_NodON extends D2_01 {
 
     public D2_01_12_NodON() {
@@ -41,10 +44,10 @@ public class D2_01_12_NodON extends D2_01 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equalsIgnoreCase(CHANNEL_REPEATERMODE)) {
             if (command instanceof RefreshType) {
-                senderId = null; // make this message invalid as we do not support refresh of repeter status
+                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()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
index 08dc10e0c5cd527c0dca546827ebd1616fe9a1af..824a5408f2909d42689ccb5ac595d4d820af1c61 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -29,12 +31,13 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_03_0A extends _VLDMessage {
 
-    protected final byte ShortPress = 0x01;
-    protected final byte DoublePress = 0x02;
-    protected final byte LongPress = 0x03;
-    protected final byte LongRelease = 0x04;
+    protected static final byte SHORT_PRESS = 0x01;
+    protected static final byte DOUBLE_PRESS = 0x02;
+    protected static final byte LONG_PRESS = 0x03;
+    protected static final byte LONG_RELEASE = 0x04;
 
     public D2_03_0A() {
         super();
@@ -45,24 +48,24 @@ public class D2_03_0A extends _VLDMessage {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
         switch (channelId) {
             case CHANNEL_PUSHBUTTON:
-                return (bytes[1] == ShortPress) ? CommonTriggerEvents.PRESSED : null;
+                return (bytes[1] == SHORT_PRESS) ? CommonTriggerEvents.PRESSED : null;
             case CHANNEL_DOUBLEPRESS:
-                return (bytes[1] == DoublePress) ? CommonTriggerEvents.PRESSED : null;
+                return (bytes[1] == DOUBLE_PRESS) ? CommonTriggerEvents.PRESSED : null;
             case CHANNEL_LONGPRESS:
-                return (bytes[1] == LongPress) ? CommonTriggerEvents.PRESSED
-                        : ((bytes[1] == LongRelease) ? CommonTriggerEvents.RELEASED : null);
+                return (bytes[1] == LONG_PRESS) ? CommonTriggerEvents.PRESSED
+                        : ((bytes[1] == LONG_RELEASE) ? CommonTriggerEvents.RELEASED : null);
             default:
                 return null;
         }
     }
 
     @Override
-    public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
-            Configuration config) {
+    public State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
             return new QuantityType<>(bytes[0] & 0xFF, Units.PERCENT);
         }
index 972b9e02b9a2c4d80d3576b1601788cd7c9f50c8..eeab198a8fb04bc3eda8a5aef5fb7dcb832f3d7f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -32,22 +34,23 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_05_00 extends _VLDMessage {
 
-    protected final byte cmdMask = 0x0f;
-    protected final byte outputValueMask = 0x7f;
-    protected final byte outputChannelMask = 0x1f;
+    protected static final byte CMD_MASK = 0x0f;
+    protected static final byte OUTPUT_VALUE_MASK = 0x7f;
+    protected static final byte OUTPUT_CHANNEL_MASK = 0x1f;
 
-    protected final byte CMD_ACTUATOR_SET_POSITION = 0x01;
-    protected final byte CMD_ACTUATOR_STOP = 0x02;
-    protected final byte CMD_ACTUATOR_POSITION_QUERY = 0x03;
-    protected final byte CMD_ACTUATOR_POSITION_RESPONE = 0x04;
+    protected static final byte CMD_ACTUATOR_SET_POSITION = 0x01;
+    protected static final byte CMD_ACTUATOR_STOP = 0x02;
+    protected static final byte CMD_ACTUATOR_POSITION_QUERY = 0x03;
+    protected static final byte CMD_ACTUATOR_POSITION_RESPONE = 0x04;
 
-    protected final byte AllChannels_Mask = 0x1e;
-    protected final byte ChannelA_Mask = 0x00;
+    protected static final byte ALL_CHANNELS_MASK = 0x1e;
+    protected static final byte CHANNEL_A_MASK = 0x00;
 
-    protected final byte DOWN = 0x64; // 100%
-    protected final byte UP = 0x00; // 0%
+    protected static final byte DOWN = 0x64; // 100%
+    protected static final byte UP = 0x00; // 0%
 
     public D2_05_00() {
         super();
@@ -58,7 +61,7 @@ public class D2_05_00 extends _VLDMessage {
     }
 
     protected byte getCMD() {
-        return (byte) (bytes[bytes.length - 1] & cmdMask);
+        return (byte) (bytes[bytes.length - 1] & CMD_MASK);
     }
 
     protected void setPositionData(Command command, byte outputChannel) {
@@ -94,7 +97,7 @@ public class D2_05_00 extends _VLDMessage {
     }
 
     protected byte getChannel() {
-        return (byte) (bytes[1] & outputChannelMask);
+        return (byte) (bytes[1] & OUTPUT_CHANNEL_MASK);
     }
 
     @Override
@@ -105,19 +108,19 @@ public class D2_05_00 extends _VLDMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equals(CHANNEL_ROLLERSHUTTER)) {
             if (command == RefreshType.REFRESH) {
-                setPositionQueryData(ChannelA_Mask);
+                setPositionQueryData(CHANNEL_A_MASK);
             } else {
-                setPositionData(command, ChannelA_Mask);
+                setPositionData(command, CHANNEL_A_MASK);
             }
         }
     }
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_ROLLERSHUTTER:
                 return getPositionData();
index 9d4308a6c52f2d36fba8ee4bddea263a70872884..a74dcba4eebf51c83d109e8b1a4b505d6c3d4b0f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -26,10 +28,11 @@ import org.openhab.core.types.RefreshType;
 import org.openhab.core.types.State;
 
 /**
- *
+ * @author MArcel Eckert - Initial contribution
  * @author Marcel Eckert - based on D2_01_0F_NodON.java and D2_01_12_NodOn.java
  * 
  */
+@NonNullByDefault
 public class D2_05_00_NodON extends D2_05_00 {
 
     public D2_05_00_NodON() {
@@ -42,10 +45,10 @@ public class D2_05_00_NodON extends D2_05_00 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (channelId.equals(CHANNEL_REPEATERMODE)) {
             if (command == RefreshType.REFRESH) {
-                senderId = null; // make this message invalid as we do not support refresh of repeter status
+                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()) {
                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
index ab96d95f8fb0f3e8c689453ef40c3024a1f9c1ea..8668c0ba6d80118356ba1a485b6a7ed0c062fd08 100644 (file)
@@ -18,6 +18,8 @@ import java.util.Arrays;
 import java.util.Optional;
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -39,10 +41,10 @@ import org.openhab.core.types.UnDefType;
  * 
  * @author Thomas Lauterbach - Initial contribution
  */
+@NonNullByDefault
 public class D2_06_01 extends _VLDMessage {
 
     private enum MessageType {
-
         SENSORVALUES(0x00),
         CONFIGURATIONREPORT(0x10),
         LOGDATA01(0x20),
@@ -63,7 +65,6 @@ public class D2_06_01 extends _VLDMessage {
     }
 
     private enum SashState {
-
         // WINDOWSTATEUNDEFINED(0x00, "UNDEFINED"),
         NOTTILTED(0x01, "NOT TILTED"),
         TILTED(0x02, "TILTED");
@@ -86,7 +87,6 @@ public class D2_06_01 extends _VLDMessage {
     }
 
     private enum HandleState {
-
         // HANDLEPOSITIONUNDEFINED(0x00, "UNDEFINED"),
         HANDLEUP(0x01, "UP"),
         HANDLEDOWN(0x02, "DOWN"),
@@ -111,7 +111,6 @@ public class D2_06_01 extends _VLDMessage {
     }
 
     private enum MotionState {
-
         MOTIONNOTTRIGGERED(0x00, "OFF"),
         MOTIONTRIGGERED(0x01, "ON");
 
@@ -199,9 +198,8 @@ public class D2_06_01 extends _VLDMessage {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
-
         // Sensor values
         if (bytes[0] == MessageType.SENSORVALUES.getIntValue()) {
             switch (channelId) {
@@ -248,9 +246,8 @@ public class D2_06_01 extends _VLDMessage {
     }
 
     @Override
-    public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
-            Configuration config) {
-
+    public State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         // Sensor values
         if (bytes[0] == MessageType.SENSORVALUES.getIntValue()) {
             switch (channelId) {
index 0cfc44f231b0a2a6d3ff451fa71691122252141f..63ad5c71e00c207aed9023e87a5a4b961d9a4950 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -29,6 +31,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Thomas Lauterbach - Initial contribution
  */
+@NonNullByDefault
 public class D2_06_50 extends _VLDMessage {
 
     public D2_06_50() {
@@ -112,9 +115,8 @@ public class D2_06_50 extends _VLDMessage {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
-
         // Alarm
         if (bytes[0] == 0x02) {
             switch (channelId) {
@@ -130,7 +132,6 @@ public class D2_06_50 extends _VLDMessage {
     @Override
     public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
             Configuration config) {
-
         // Window status
         if (bytes[0] == 0x01) {
             switch (channelId) {
index 7230f23f2c2b7f95f462e6ff6939a3e1603d3103..2674a27a3727e150e352403ffd4346b6240c4ad2 100644 (file)
@@ -16,6 +16,7 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -32,6 +33,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_14_30 extends _VLDMessage {
 
     private final String[] hygroComfortIndexValues = { "GOOD", "MEDIUM", "BAD", "ERROR" };
index fedbfe35fdcc425aa69ef37668b827207e2c88e8..eb211b2f4ebabe1e6bc1032794e93ba77da075ab 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -37,16 +39,17 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D2_50 extends _VLDMessage {
 
-    protected static final byte mtMask = (byte) 0xf0;
+    protected static final byte MT_MASK = (byte) 0xf0;
     protected static final byte MT_REMOTE_TRANSMISSION_REQUEST = 0x00;
     protected static final byte MT_CONTROL = 0x20;
     protected static final byte MT_BASIC_STATUS = 0x40;
     protected static final byte MT_EXTENDED_STATUS = 0x60; // not yet implemented
     protected static final byte MT_UNKNOWN_STATUS = (byte) 0x80; // Sent by some systems during teach in
 
-    protected static final byte rmtMask = (byte) 0x0f;
+    protected static final byte RMT_MASK = (byte) 0x0f;
     protected static final byte RMT_BASIC_STATUS = 0x00;
     protected static final byte RMT_EXTENDED_STATUS = 0x01; // not yet implemented
 
@@ -65,7 +68,7 @@ public class D2_50 extends _VLDMessage {
     }
 
     protected byte getMessageType(byte b) {
-        return (byte) (b & mtMask);
+        return (byte) (b & MT_MASK);
     }
 
     @Override
@@ -76,8 +79,7 @@ public class D2_50 extends _VLDMessage {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         // we need to send just a single message to refresh all channel states, hence just send refresh for OM
         if (command == RefreshType.REFRESH && CHANNEL_VENTILATIONOPERATIONMODE.equals(channelId)) {
             setData((byte) (MT_REMOTE_TRANSMISSION_REQUEST + RMT_BASIC_STATUS));
@@ -104,7 +106,6 @@ public class D2_50 extends _VLDMessage {
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
             Function<String, State> getCurrentStateFunc, Configuration config) {
-
         if (getMessageType(bytes[0]) != MT_BASIC_STATUS) {
             return UnDefType.UNDEF;
         }
index 34606816f458b22a0bdec6985ab26a59fece76ee..46acf9928bb0fd2698106ca37a5e5337bf76c8c5 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.eep.Base._1BSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -28,10 +30,11 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class D5_00_01 extends _1BSMessage {
 
-    final byte OPEN = 0 | TeachInBit;
-    final byte CLOSED = 1 | TeachInBit;
+    protected static final byte OPEN = 0 | TEACHIN_BIT;
+    protected static final byte CLOSED = 1 | TEACHIN_BIT;
 
     public D5_00_01() {
         super();
@@ -43,7 +46,7 @@ public class D5_00_01 extends _1BSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_CONTACT)) {
             EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
             if (c.inverted) {
index 50bc81f5ae66c104f788afbccbc735b722f5596c..353f75670d54c4b0d47e3f30b1e9f4c91a81efba 100644 (file)
@@ -18,6 +18,8 @@ import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 import java.util.Arrays;
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -37,29 +39,26 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class EEP {
 
     protected RORG newRORG = RORG.Unknown;
-    protected byte[] bytes;
-    protected byte[] optionalData;
-    protected byte[] senderId;
-    protected byte status;
+    protected byte[] bytes = new byte[0];
+    protected byte[] optionalData = new byte[0];
+    protected byte[] senderId = new byte[0];
+    protected byte status = 0x00;
 
-    protected byte[] destinationId;
+    protected byte[] destinationId = new byte[0];
 
     protected boolean suppressRepeating;
 
     protected Logger logger = LoggerFactory.getLogger(EEP.class);
 
-    private EEPType eepType = null;
-    protected ERP1Message packet = null;
+    private @Nullable EEPType eepType = null;
+    protected @Nullable ERP1Message packet = null;
 
     public EEP() {
         // ctor for sending
-
-        status = 0x00;
-        senderId = null;
-        bytes = null;
     }
 
     public EEP(ERP1Message packet) {
@@ -74,7 +73,7 @@ public abstract class EEP {
     }
 
     public EEP convertFromCommand(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (!getEEPType().isChannelSupported(channelId, channelTypeId)) {
             throw new IllegalArgumentException(String.format("Command %s of channel %s(%s) is not supported",
                     command.toString(), channelId, channelTypeId));
@@ -89,7 +88,7 @@ public abstract class EEP {
     }
 
     public State convertToState(String channelId, String channelTypeId, Configuration config,
-            Function<String, State> getCurrentStateFunc) {
+            Function<String, @Nullable State> getCurrentStateFunc) {
         if (!getEEPType().isChannelSupported(channelId, channelTypeId)) {
             throw new IllegalArgumentException(
                     String.format("Channel %s(%s) is not supported", channelId, channelTypeId));
@@ -97,13 +96,13 @@ public abstract class EEP {
 
         switch (channelTypeId) {
             case CHANNEL_RSSI:
-                if (this.optionalData == null || this.optionalData.length < 6) {
+                if (this.optionalData.length < 6) {
                     return UnDefType.UNDEF;
                 }
 
                 return new DecimalType((this.optionalData[5] & 0xFF) * -1);
             case CHANNEL_REPEATCOUNT:
-                if (this.optionalData == null || this.optionalData.length < 6) {
+                if (this.optionalData.length < 6) {
                     return UnDefType.UNDEF;
                 }
 
@@ -115,7 +114,8 @@ public abstract class EEP {
         return convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);
     }
 
-    public String convertToEvent(String channelId, String channelTypeId, String lastEvent, Configuration config) {
+    public @Nullable String convertToEvent(String channelId, String channelTypeId, String lastEvent,
+            Configuration config) {
         if (!getEEPType().isChannelSupported(channelId, channelTypeId)) {
             throw new IllegalArgumentException(
                     String.format("Channel %s(%s) is not supported", channelId, channelTypeId));
@@ -129,7 +129,7 @@ public abstract class EEP {
         return this;
     }
 
-    public EEP setData(byte... bytes) {
+    public EEP setData(byte... bytes) throws IllegalArgumentException {
         if (!validateData(bytes)) {
             throw new IllegalArgumentException();
         }
@@ -139,11 +139,11 @@ public abstract class EEP {
     }
 
     public boolean hasData() {
-        return (this.bytes != null) && (this.bytes.length > 0);
+        return (this.bytes.length > 0);
     }
 
     public EEP setOptionalData(byte... bytes) {
-        if (bytes != null) {
+        if (bytes.length > 0) {
             this.optionalData = Arrays.copyOf(bytes, bytes.length);
         }
 
@@ -151,7 +151,7 @@ public abstract class EEP {
     }
 
     public EEP setSenderId(byte[] senderId) {
-        if (senderId == null || senderId.length != ESP3_SENDERID_LENGTH) {
+        if (senderId.length != ESP3_SENDERID_LENGTH) {
             throw new IllegalArgumentException();
         }
 
@@ -169,15 +169,10 @@ public abstract class EEP {
         return this;
     }
 
-    public final ERP1Message getERP1Message() {
+    public final @Nullable ERP1Message getERP1Message() {
         if (isValid()) {
-            int optionalDataLength = 0;
-            if (optionalData != null) {
-                optionalDataLength = optionalData.length;
-            }
-
             byte[] payLoad = new byte[ESP3_RORG_LENGTH + getDataLength() + ESP3_SENDERID_LENGTH + ESP3_STATUS_LENGTH
-                    + optionalDataLength];
+                    + optionalData.length];
             Arrays.fill(payLoad, ZERO);
 
             byte rorgValue = getEEPType().getRORG().getValue();
@@ -189,7 +184,7 @@ public abstract class EEP {
             payLoad = Helper.concatAll(new byte[] { rorgValue }, bytes, senderId,
                     new byte[] { (byte) (status | (suppressRepeating ? 0b1111 : 0)) }, optionalData);
 
-            return new ERP1Message(payLoad.length - optionalDataLength, optionalDataLength, payLoad);
+            return new ERP1Message(payLoad.length - optionalData.length, optionalData.length, payLoad);
         } else {
             logger.warn("ERP1Message for EEP {} is not valid!", this.getClass().getName());
         }
@@ -198,45 +193,42 @@ public abstract class EEP {
     }
 
     protected boolean validateData(byte[] bytes) {
-        return bytes != null && bytes.length == getDataLength();
+        return bytes.length == getDataLength();
     }
 
     public boolean isValid() {
-        return validateData(bytes) && senderId != null && senderId.length == ESP3_SENDERID_LENGTH;
+        return validateData(bytes) && senderId.length == ESP3_SENDERID_LENGTH;
     }
 
     protected EEPType getEEPType() {
-        if (eepType == null) {
-            eepType = EEPType.getType(this.getClass());
+        EEPType localType = eepType;
+        if (localType == null) {
+            localType = EEPType.getType(this.getClass());
         }
 
-        return eepType;
+        return localType;
     }
 
     protected int getDataLength() {
-        if (getEEPType() != null) {
-            return getEEPType().getRORG().getDataLength();
-        }
-
-        return 0;
+        return getEEPType().getRORG().getDataLength();
     }
 
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         logger.warn("No implementation for sending data from channel {}/{} for this EEP!", channelId, channelTypeId);
     }
 
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         return UnDefType.UNDEF;
     }
 
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
         return null;
     }
 
-    protected void teachInQueryImpl(Configuration config) {
+    protected void teachInQueryImpl(@Nullable Configuration config) {
         logger.warn("No implementation for sending a response for this teach in!");
     }
 
@@ -245,7 +237,7 @@ public abstract class EEP {
         return (byteData & mask) != 0;
     }
 
-    public ThingTypeUID getThingTypeUID() {
+    public @Nullable ThingTypeUID getThingTypeUID() {
         return getEEPType().getThingTypeUID();
     }
 
@@ -258,7 +250,7 @@ public abstract class EEP {
     }
 
     public EEP setDestinationId(byte[] destinationId) {
-        if (destinationId != null) {
+        if (destinationId.length > 0) {
             this.destinationId = Arrays.copyOf(destinationId, destinationId.length);
             setOptionalData(Helper.concatAll(new byte[] { 0x01 }, destinationId, new byte[] { (byte) 0xff, 0x00 }));
         }
index 276f609d584317ccba8a25e35eab998c9b4f22a8..59d9b95407d4433bc2b922737ad075a7dad2067d 100644 (file)
@@ -17,6 +17,8 @@ import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base.UTEResponse;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
 import org.openhab.binding.enocean.internal.eep.Base._4BSTeachInVariation3Response;
@@ -32,7 +34,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
 import org.openhab.binding.enocean.internal.messages.EventMessage;
 import org.openhab.binding.enocean.internal.messages.EventMessage.EventMessageType;
-import org.openhab.binding.enocean.internal.messages.Responses.SMACKTeachInResponse;
+import org.openhab.binding.enocean.internal.messages.responses.SMACKTeachInResponse;
 import org.openhab.core.util.HexUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,6 +43,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EEPFactory {
 
     private static final Logger logger = LoggerFactory.getLogger(EEPFactory.class);
@@ -76,7 +79,7 @@ public class EEPFactory {
         }
     }
 
-    private static EEPType getGenericEEPTypeFor(byte rorg) {
+    private static @Nullable EEPType getGenericEEPTypeFor(byte rorg) {
         logger.info("Received unsupported EEP teach in, trying to fallback to generic thing");
         RORG r = RORG.getRORG(rorg);
         if (r == RORG._4BS) {
@@ -91,7 +94,7 @@ public class EEPFactory {
         }
     }
 
-    public static EEP buildEEPFromTeachInERP1(ERP1Message msg) {
+    public static @Nullable EEP buildEEPFromTeachInERP1(ERP1Message msg) {
         if (!msg.getIsTeachIn() && !(msg.getRORG() == RORG.RPS)) {
             return null;
         }
@@ -150,19 +153,19 @@ public class EEPFactory {
             case _1BS:
                 return new D5_00_01(msg);
             case _4BS: {
-                int db_0 = msg.getPayload()[4];
-                if ((db_0 & _4BSMessage.LRN_Type_Mask) == 0) { // Variation 1
+                int db0 = msg.getPayload()[4];
+                if ((db0 & _4BSMessage.LRN_TYPE_MASK) == 0) { // Variation 1
                     logger.info("Received 4BS Teach In variation 1 without EEP, fallback to generic thing");
                     return buildEEP(EEPType.Generic4BS, msg);
                 }
 
-                byte db_3 = msg.getPayload()[1];
-                byte db_2 = msg.getPayload()[2];
-                byte db_1 = msg.getPayload()[3];
+                byte db3 = msg.getPayload()[1];
+                byte db2 = msg.getPayload()[2];
+                byte db1 = msg.getPayload()[3];
 
-                int func = (db_3 & 0xFF) >>> 2;
-                int type = ((db_3 & 0b11) << 5) + ((db_2 & 0xFF) >>> 3);
-                int manufId = ((db_2 & 0b111) << 8) + (db_1 & 0xff);
+                int func = (db3 & 0xFF) >>> 2;
+                int type = ((db3 & 0b11) << 5) + ((db2 & 0xFF) >>> 3);
+                int manufId = ((db2 & 0b111) << 8) + (db1 & 0xff);
 
                 logger.debug("Received 4BS Teach In with EEP A5-{}-{} and manufacturerID {}",
                         HexUtils.bytesToHex(new byte[] { (byte) func }),
@@ -210,7 +213,7 @@ public class EEPFactory {
         return null;
     }
 
-    public static EEP buildEEPFromTeachInSMACKEvent(EventMessage event) {
+    public static @Nullable EEP buildEEPFromTeachInSMACKEvent(EventMessage event) {
         if (event.getEventMessageType() != EventMessageType.SA_CONFIRM_LEARN) {
             return null;
         }
@@ -235,10 +238,10 @@ public class EEPFactory {
             eepType = getGenericEEPTypeFor(rorg);
         }
 
-        return createEEP(eepType).setSenderId(senderId);
+        return (eepType == null) ? null : createEEP(eepType).setSenderId(senderId);
     }
 
-    public static EEP buildResponseEEPFromTeachInERP1(ERP1Message msg, byte[] senderId, boolean teachIn) {
+    public static @Nullable EEP buildResponseEEPFromTeachInERP1(ERP1Message msg, byte[] senderId, boolean teachIn) {
         switch (msg.getRORG()) {
             case UTE:
                 EEP result = new UTEResponse(msg, teachIn);
index 9aade0851b0ed5c6da9b44adda061a499df7e018..bce376790f04c61843458949b6c90bca659a0a66 100644 (file)
@@ -14,6 +14,8 @@ package org.openhab.binding.enocean.internal.eep;
 
 import javax.measure.quantity.Energy;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelTotalusageConfig;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.library.types.QuantityType;
@@ -26,8 +28,9 @@ import org.openhab.core.types.UnDefType;
  * @author Dominik Vorreiter - initial contribution
  *
  */
+@NonNullByDefault
 public abstract class EEPHelper {
-    public static State validateTotalUsage(State value, State currentState, Configuration config) {
+    public static State validateTotalUsage(State value, @Nullable State currentState, Configuration config) {
         EnOceanChannelTotalusageConfig c = config.as(EnOceanChannelTotalusageConfig.class);
 
         if (c.validateValue && (value instanceof QuantityType) && (currentState instanceof QuantityType)) {
index 259b68c7fb79a216112ed7213ba9891aee6d7d5f..e9c2506392486d184e43c765acee3f1acd48711c 100644 (file)
@@ -18,7 +18,8 @@ import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanChannelDescription;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelTransformationConfig;
 import org.openhab.binding.enocean.internal.eep.A5_02.A5_02_01;
@@ -150,9 +151,9 @@ import org.openhab.binding.enocean.internal.eep.F6_05.F6_05_02;
 import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_00;
 import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_00_EltakoFPE;
 import org.openhab.binding.enocean.internal.eep.F6_10.F6_10_01;
-import org.openhab.binding.enocean.internal.eep.Generic.Generic4BS;
-import org.openhab.binding.enocean.internal.eep.Generic.GenericRPS;
-import org.openhab.binding.enocean.internal.eep.Generic.GenericVLD;
+import org.openhab.binding.enocean.internal.eep.generic.Generic4BS;
+import org.openhab.binding.enocean.internal.eep.generic.GenericRPS;
+import org.openhab.binding.enocean.internal.eep.generic.GenericVLD;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
 import org.openhab.core.config.core.Configuration;
 import org.openhab.core.thing.Channel;
@@ -163,8 +164,9 @@ import org.openhab.core.thing.type.ChannelTypeUID;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public enum EEPType {
-    Undef(RORG.Unknown, 0, 0, false, null, null, 0),
+    Undef(RORG.Unknown, 0, 0, false, EEP.class, null, 0),
 
     UTEResponse(RORG.UTE, 0, 0, false, UTEResponse.class, null),
     _4BSTeachInVariation3Response(RORG._4BS, 0, 0, false, _4BSTeachInVariation3Response.class, null),
@@ -402,7 +404,7 @@ public enum EEPType {
                     put(CHANNEL_ROLLERSHUTTER, new Configuration());
                     put(CHANNEL_TEACHINCMD, new Configuration() {
                         {
-                            put(PARAMETER_CHANNEL_TeachInMSG, "fff80d80");
+                            put(PARAMETER_CHANNEL_TEACHINMSG, "fff80d80");
                         }
                     });
                 }
@@ -415,7 +417,7 @@ public enum EEPType {
                     put(CHANNEL_ROLLERSHUTTER, new Configuration());
                     put(CHANNEL_TEACHINCMD, new Configuration() {
                         {
-                            put(PARAMETER_CHANNEL_TeachInMSG, "fff80d80");
+                            put(PARAMETER_CHANNEL_TEACHINMSG, "fff80d80");
                         }
                     });
                 }
@@ -529,7 +531,7 @@ public enum EEPType {
     private String manufactorSuffix;
     private int manufactorId;
 
-    private ThingTypeUID thingTypeUID;
+    private @Nullable ThingTypeUID thingTypeUID;
 
     private Hashtable<String, Configuration> channelIdsWithConfig = new Hashtable<>();
     private Hashtable<String, EnOceanChannelDescription> supportedChannels = new Hashtable<>();
@@ -539,7 +541,7 @@ public enum EEPType {
     private boolean requestsResponse;
 
     EEPType(RORG rorg, int func, int type, boolean supportsRefresh, Class<? extends EEP> eepClass,
-            ThingTypeUID thingTypeUID, String... channelIds) {
+            @Nullable ThingTypeUID thingTypeUID, String... channelIds) {
         this(rorg, func, type, supportsRefresh, eepClass, thingTypeUID, -1, channelIds);
     }
 
@@ -555,7 +557,7 @@ public enum EEPType {
     }
 
     EEPType(RORG rorg, int func, int type, boolean supportsRefresh, Class<? extends EEP> eepClass,
-            ThingTypeUID thingTypeUID, int command, String... channelIds) {
+            @Nullable ThingTypeUID thingTypeUID, int command, String... channelIds) {
         this(rorg, func, type, supportsRefresh, false, "", 0, eepClass, thingTypeUID, command, channelIds);
     }
 
@@ -565,7 +567,8 @@ public enum EEPType {
     }
 
     EEPType(RORG rorg, int func, int type, boolean supportsRefresh, boolean requestsResponse, String manufactorSuffix,
-            int manufId, Class<? extends EEP> eepClass, ThingTypeUID thingTypeUID, int command, String... channelIds) {
+            int manufId, Class<? extends EEP> eepClass, @Nullable ThingTypeUID thingTypeUID, int command,
+            String... channelIds) {
         this.rorg = rorg;
         this.func = func;
         this.type = type;
@@ -578,15 +581,20 @@ public enum EEPType {
         this.requestsResponse = requestsResponse;
 
         for (String id : channelIds) {
-            this.channelIdsWithConfig.put(id, new Configuration());
-            this.supportedChannels.put(id, CHANNELID2CHANNELDESCRIPTION.get(id));
+            if (id != null) {
+                this.channelIdsWithConfig.put(id, new Configuration());
+                EnOceanChannelDescription description = CHANNELID2CHANNELDESCRIPTION.get(id);
+                if (description != null) {
+                    this.supportedChannels.put(id, description);
+                }
+            }
         }
 
         addDefaultChannels();
     }
 
     EEPType(RORG rorg, int func, int type, boolean supportsRefresh, boolean requestsResponse, String manufactorSuffix,
-            int manufId, Class<? extends EEP> eepClass, ThingTypeUID thingTypeUID, int command,
+            int manufId, Class<? extends EEP> eepClass, @Nullable ThingTypeUID thingTypeUID, int command,
             Hashtable<String, Configuration> channelConfigs) {
         this.rorg = rorg;
         this.func = func;
@@ -601,59 +609,72 @@ public enum EEPType {
         this.requestsResponse = requestsResponse;
 
         for (String id : channelConfigs.keySet()) {
-            this.supportedChannels.put(id, CHANNELID2CHANNELDESCRIPTION.get(id));
+            this.supportedChannels = addChannelDescription(supportedChannels, id, CHANNELID2CHANNELDESCRIPTION.get(id));
         }
 
         addDefaultChannels();
     }
 
     private void addDefaultChannels() {
-
         if (THING_TYPE_GENERICTHING.equals(this.thingTypeUID)) {
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_SWITCH, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_SWITCH,
+
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_SWITCH,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_SWITCH));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_ROLLERSHUTTER, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_ROLLERSHUTTER,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_ROLLERSHUTTER,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_ROLLERSHUTTER));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_DIMMER, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_DIMMER,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_DIMMER,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_DIMMER));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_NUMBER, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_NUMBER,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_NUMBER,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_NUMBER));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_STRING, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_STRING,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_STRING,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_STRING));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_COLOR, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_COLOR, CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_COLOR));
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_COLOR,
+                    CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_COLOR));
 
             this.channelIdsWithConfig.put(CHANNEL_GENERIC_TEACHINCMD, new EnOceanChannelTransformationConfig());
-            this.supportedChannels.put(CHANNEL_GENERIC_TEACHINCMD,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_GENERIC_TEACHINCMD,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_GENERIC_TEACHINCMD));
         }
 
         this.channelIdsWithConfig.put(CHANNEL_RSSI, new Configuration());
-        this.supportedChannels.put(CHANNEL_RSSI, CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_RSSI));
+        this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_RSSI,
+                CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_RSSI));
 
         this.channelIdsWithConfig.put(CHANNEL_REPEATCOUNT, new Configuration());
-        this.supportedChannels.put(CHANNEL_REPEATCOUNT, CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_REPEATCOUNT));
+        this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_REPEATCOUNT,
+                CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_REPEATCOUNT));
 
         this.channelIdsWithConfig.put(CHANNEL_LASTRECEIVED, new Configuration());
-        this.supportedChannels.put(CHANNEL_LASTRECEIVED, CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_LASTRECEIVED));
+        this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_LASTRECEIVED,
+                CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_LASTRECEIVED));
 
         if (requestsResponse) {
             this.channelIdsWithConfig.put(CHANNEL_STATUS_REQUEST_EVENT, new Configuration());
-            this.supportedChannels.put(CHANNEL_STATUS_REQUEST_EVENT,
+            this.supportedChannels = addChannelDescription(this.supportedChannels, CHANNEL_STATUS_REQUEST_EVENT,
                     CHANNELID2CHANNELDESCRIPTION.get(CHANNEL_STATUS_REQUEST_EVENT));
         }
     }
 
+    private static Hashtable<String, EnOceanChannelDescription> addChannelDescription(
+            Hashtable<String, EnOceanChannelDescription> channels, @Nullable String id,
+            @Nullable EnOceanChannelDescription channelDescription) {
+        if (id != null && channelDescription != null) {
+            channels.put(id, channelDescription);
+        }
+        return channels;
+    }
+
     public Class<? extends EEP> getEEPClass() {
         return eepClass;
     }
@@ -678,7 +699,7 @@ public enum EEPType {
         return requestsResponse;
     }
 
-    public Map<String, EnOceanChannelDescription> GetSupportedChannels() {
+    public Map<String, EnOceanChannelDescription> getSupportedChannels() {
         return Collections.unmodifiableMap(supportedChannels);
     }
 
@@ -694,11 +715,10 @@ public enum EEPType {
                 || supportedChannels.values().stream().anyMatch(c -> c.channelTypeUID.getId().equals(channelTypeId));
     }
 
-    public ThingTypeUID getThingTypeUID() {
+    public @Nullable ThingTypeUID getThingTypeUID() {
         return thingTypeUID;
     }
 
-    @NonNull
     public String getId() {
         if (command == -1) {
             return String.format("%02X_%02X_%02X", rorg.getValue(), func, type);
@@ -709,18 +729,14 @@ public enum EEPType {
         }
     }
 
-    @NonNull
     public Configuration getChannelConfig(String channelId) {
         Configuration c = null;
-
-        if (channelIdsWithConfig != null) {
+        if (!channelIdsWithConfig.isEmpty()) {
             c = channelIdsWithConfig.get(channelId);
+            if (c != null) {
+                return c;
+            }
         }
-
-        if (c != null) {
-            return c;
-        }
-
         return new Configuration();
     }
 
@@ -736,7 +752,7 @@ public enum EEPType {
 
     public static EEPType getType(Class<? extends EEP> eepClass) {
         for (EEPType eep : values()) {
-            if (eep.eepClass != null && eep.eepClass.equals(eepClass)) {
+            if (eep.eepClass.equals(eepClass)) {
                 return eep;
             }
         }
@@ -744,7 +760,7 @@ public enum EEPType {
         throw new IllegalArgumentException(String.format("EEP with class %s could not be found", eepClass.getName()));
     }
 
-    public static EEPType getType(RORG rorg, int func, int type, int manufId) {
+    public static @Nullable EEPType getType(RORG rorg, int func, int type, int manufId) {
         EEPType fallback = null;
 
         for (EEPType eep : values()) {
index 0b2ee415bc4408bf310188f8fa02ef40da9ff11b..60329e831d93ece2a9404690696809a7a421d51c 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.enocean.internal.eep.F6_01;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -21,6 +23,7 @@ import org.openhab.core.thing.CommonTriggerEvents;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_01_01 extends _RPSMessage {
 
     public F6_01_01() {
@@ -32,9 +35,8 @@ public class F6_01_01 extends _RPSMessage {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
-
         return getBit(bytes[0], 4) ? CommonTriggerEvents.PRESSED : CommonTriggerEvents.RELEASED;
     }
 
index 10f930a869b611b491e3a63a936165998df60e4b..b8feccd0a3f81232400b900c706ae45802ab89d4 100644 (file)
@@ -14,6 +14,8 @@ package org.openhab.binding.enocean.internal.eep.F6_02;
 
 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchConfigBase.SwitchMode;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -28,18 +30,19 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class F6_02 extends _RPSMessage {
 
-    final byte AI = 0;
-    final byte A0 = 1;
-    final byte BI = 2;
-    final byte B0 = 3;
-    final byte PRESSED = 16;
-    final byte PRESSED_SEC = 1;
+    protected static final byte AI = 0;
+    protected static final byte A0 = 1;
+    protected static final byte BI = 2;
+    protected static final byte B0 = 3;
+    protected static final byte PRESSED = 16;
+    protected static final byte PRESSED_SEC = 1;
 
-    final String DIR1 = "DIR1";
-    final String DIR2 = "DIR2";
-    final String NODIR = "-";
+    protected static final String DIR1 = "DIR1";
+    protected static final String DIR2 = "DIR2";
+    protected static final String NODIR = "-";
 
     int secondByte = -1;
     int secondStatus = -1;
@@ -83,7 +86,7 @@ public abstract class F6_02 extends _RPSMessage {
         return dirA + "|" + dirB;
     }
 
-    protected String getChannelEvent(byte dir1, byte dir2) {
+    protected @Nullable String getChannelEvent(byte dir1, byte dir2) {
         if ((bytes[0] & PRESSED_SEC) != 0) {
             // Do not emit an event if channelA is pressed together with channelB as it is undetermined which one gets
             // fired first
index d4d5fe1de7690d81b7508d4d8853deb6ddcbb7b1..36126907651040c4b5711e4fdcbe4dc6e0b4defa 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchConfigBase.Channel;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchListenerConfig;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
@@ -31,6 +33,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_02_01 extends F6_02 {
 
     public F6_02_01() {
@@ -42,9 +45,8 @@ public class F6_02_01 extends F6_02 {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
-
         if (t21 && nu) {
             if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
                 return getRockerSwitchAction(config);
@@ -58,9 +60,9 @@ public class F6_02_01 extends F6_02 {
             if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
                 return CommonTriggerEvents.RELEASED;
             } else {
-                if (lastEvent != null && lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
+                if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
                     return CommonTriggerEvents.DIR1_RELEASED;
-                } else if (lastEvent != null && lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
+                } else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
                     return CommonTriggerEvents.DIR2_RELEASED;
                 }
             }
@@ -71,12 +73,12 @@ public class F6_02_01 extends F6_02 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (command instanceof StringType) {
             String s = ((StringType) command).toString();
 
             if (s.equals(CommonTriggerEvents.DIR1_RELEASED) || s.equals(CommonTriggerEvents.DIR2_RELEASED)) {
-                setStatus(_RPSMessage.T21Flag);
+                setStatus(_RPSMessage.T21_FLAG);
                 setData((byte) 0x00);
                 return;
             }
@@ -85,10 +87,10 @@ public class F6_02_01 extends F6_02 {
             byte dir2 = channelTypeId.equalsIgnoreCase(CHANNEL_VIRTUALROCKERSWITCHB) ? BI : AI;
 
             if (s.equals(CommonTriggerEvents.DIR1_PRESSED)) {
-                setStatus((byte) (_RPSMessage.T21Flag | _RPSMessage.NUFlag));
+                setStatus((byte) (_RPSMessage.T21_FLAG | _RPSMessage.NU_FLAG));
                 setData((byte) ((dir1 << 5) | PRESSED));
             } else if (s.equals(CommonTriggerEvents.DIR2_PRESSED)) {
-                setStatus((byte) (_RPSMessage.T21Flag | _RPSMessage.NUFlag));
+                setStatus((byte) (_RPSMessage.T21_FLAG | _RPSMessage.NU_FLAG));
                 setData((byte) ((dir2 << 5) | PRESSED));
             }
         }
@@ -96,11 +98,11 @@ public class F6_02_01 extends F6_02 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         // this method is used by the classic device listener channels to convert a rocker switch message into an
         // appropriate item update
         State currentState = getCurrentStateFunc.apply(channelId);
-        if (t21 && nu) {
+        if (t21 && nu && currentState != null) {
             EnOceanChannelRockerSwitchListenerConfig c = config.as(EnOceanChannelRockerSwitchListenerConfig.class);
             byte dir1 = c.getChannel() == Channel.ChannelA ? A0 : B0;
             byte dir2 = c.getChannel() == Channel.ChannelA ? AI : BI;
index 4cb89535842b60abe45426b495b928d7dec8c526..514c07eab7e7c560b58e2c52cbd0433f118e6bce 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchConfigBase.Channel;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchListenerConfig;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
@@ -31,6 +33,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_02_02 extends F6_02 {
 
     public F6_02_02() {
@@ -42,9 +45,8 @@ public class F6_02_02 extends F6_02 {
     }
 
     @Override
-    protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+    protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
             Configuration config) {
-
         if (t21 && nu) {
             if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
                 return getRockerSwitchAction(config);
@@ -57,9 +59,9 @@ public class F6_02_02 extends F6_02 {
             if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
                 return CommonTriggerEvents.RELEASED;
             } else {
-                if (lastEvent != null && lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
+                if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
                     return CommonTriggerEvents.DIR1_RELEASED;
-                } else if (lastEvent != null && lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
+                } else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
                     return CommonTriggerEvents.DIR2_RELEASED;
                 }
             }
@@ -70,12 +72,12 @@ public class F6_02_02 extends F6_02 {
 
     @Override
     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
         if (command instanceof StringType) {
             String s = ((StringType) command).toString();
 
             if (s.equals(CommonTriggerEvents.DIR1_RELEASED) || s.equals(CommonTriggerEvents.DIR2_RELEASED)) {
-                setStatus(_RPSMessage.T21Flag);
+                setStatus(_RPSMessage.T21_FLAG);
                 setData((byte) 0x00);
                 return;
             }
@@ -84,10 +86,10 @@ public class F6_02_02 extends F6_02 {
             byte dir2 = channelTypeId.equalsIgnoreCase(CHANNEL_VIRTUALROCKERSWITCHB) ? B0 : A0;
 
             if (s.equals(CommonTriggerEvents.DIR1_PRESSED)) {
-                setStatus((byte) (_RPSMessage.T21Flag | _RPSMessage.NUFlag));
+                setStatus((byte) (_RPSMessage.T21_FLAG | _RPSMessage.NU_FLAG));
                 setData((byte) ((dir1 << 5) | PRESSED));
             } else if (s.equals(CommonTriggerEvents.DIR2_PRESSED)) {
-                setStatus((byte) (_RPSMessage.T21Flag | _RPSMessage.NUFlag));
+                setStatus((byte) (_RPSMessage.T21_FLAG | _RPSMessage.NU_FLAG));
                 setData((byte) ((dir2 << 5) | PRESSED));
             }
         }
@@ -95,11 +97,11 @@ public class F6_02_02 extends F6_02 {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         // this method is used by the classic device listener channels to convert a rocker switch message into an
         // appropriate item update
         State currentState = getCurrentStateFunc.apply(channelId);
-        if (t21 && nu) {
+        if (t21 && nu && currentState != null) {
             EnOceanChannelRockerSwitchListenerConfig c = config.as(EnOceanChannelRockerSwitchListenerConfig.class);
             byte dir1 = c.getChannel() == Channel.ChannelA ? AI : BI;
             byte dir2 = c.getChannel() == Channel.ChannelA ? A0 : B0;
index 7226158c7889ef4cdf504492ebfa65794489f1a2..4a92a2723ac7d112c40620bb652ed675eb28881b 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
 import org.openhab.core.config.core.Configuration;
@@ -27,6 +29,7 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_05_02 extends _RPSMessage {
 
     protected static final byte ALARM_OFF = 0x00;
@@ -43,8 +46,7 @@ public class F6_05_02 extends _RPSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         switch (channelId) {
             case CHANNEL_SMOKEDETECTION:
                 return bytes[0] == ALARM_OFF ? OnOffType.OFF : (bytes[0] == ALARM_ON ? OnOffType.ON : UnDefType.UNDEF);
index ecc4b44d496b7c639b689e4fa70726730be71ba8..8af7707a2d8d1df70ba8ee2154698026c8288d7f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -29,12 +31,13 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_10_00 extends _RPSMessage {
 
-    public final byte Closed = (byte) 0xF0; // 1111xxxx
-    public final byte Open1 = (byte) 0xE0; // 1110xxxx
-    public final byte Open2 = (byte) 0xC0; // 1100xxxx
-    public final byte Tilted = (byte) 0xD0; // 1101xxxx
+    public static final byte CLOSED = (byte) 0xF0; // 1111xxxx
+    public static final byte OPEN_1 = (byte) 0xE0; // 1110xxxx
+    public static final byte OPEN_2 = (byte) 0xC0; // 1100xxxx
+    public static final byte TILTED = (byte) 0xD0; // 1101xxxx
 
     public F6_10_00() {
         super();
@@ -46,28 +49,27 @@ public class F6_10_00 extends _RPSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         byte data = (byte) (bytes[0] & 0xF0);
 
         // todo localization
         switch (channelId) {
             case CHANNEL_WINDOWHANDLESTATE:
-                if (data == Closed) {
+                if (data == CLOSED) {
                     return new StringType("CLOSED");
-                } else if (data == Tilted) {
+                } else if (data == TILTED) {
                     return new StringType("TILTED");
-                } else if (data == Open1 || data == Open2) {
+                } else if (data == OPEN_1 || data == OPEN_2) {
                     return new StringType("OPEN");
                 }
 
             case CHANNEL_CONTACT:
                 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
-                if (data == Closed) {
+                if (data == CLOSED) {
                     return c.inverted ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
-                } else if (data == Tilted) {
+                } else if (data == TILTED) {
                     return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
-                } else if (data == Open1 || data == Open2) {
+                } else if (data == OPEN_1 || data == OPEN_2) {
                     return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
                 }
         }
index 6a247a5c7a4d699a15e19b3bf3552e12be798f77..6c5b4f440cc74b287feb451639b98bc16c7af858 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANN
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -28,10 +30,11 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Holger Englert - Initial contribution
  */
+@NonNullByDefault
 public class F6_10_00_EltakoFPE extends _RPSMessage {
 
-    final byte OPEN = 0x00;
-    final byte CLOSED = 0x10;
+    protected static final byte OPEN = 0x00;
+    protected static final byte CLOSED = 0x10;
 
     public F6_10_00_EltakoFPE() {
         super();
@@ -43,7 +46,7 @@ public class F6_10_00_EltakoFPE extends _RPSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         if (channelId.equals(CHANNEL_CONTACT)) {
             EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
             if (c.inverted) {
index 62f8b665332d8492216ba5f9cb0b89fc4c881e94..93aaac8f4517de8ce81c021a1ada8bce650bb76f 100644 (file)
@@ -16,6 +16,8 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
 import java.util.function.Function;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -29,12 +31,13 @@ import org.openhab.core.types.UnDefType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class F6_10_01 extends _RPSMessage {
 
-    public final byte Closed = 0x0F; // xxxx1111
-    public final byte Open1 = 0x0E; // xxxx1110
-    public final byte Open2 = 0x0C; // xxxx1100
-    public final byte Tilted = 0x0D; // xxxx1101
+    public static final byte CLOSED = 0x0F; // xxxx1111
+    public static final byte OPEN_1 = 0x0E; // xxxx1110
+    public static final byte OPEN_2 = 0x0C; // xxxx1100
+    public static final byte TILTED = 0x0D; // xxxx1101
 
     public F6_10_01() {
         super();
@@ -46,28 +49,27 @@ public class F6_10_01 extends _RPSMessage {
 
     @Override
     protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
         byte data = (byte) (bytes[0] & 0x0F);
 
         // todo localization
         switch (channelId) {
             case CHANNEL_WINDOWHANDLESTATE:
-                if (data == Closed) {
+                if (data == CLOSED) {
                     return new StringType("CLOSED");
-                } else if (data == Tilted) {
+                } else if (data == TILTED) {
                     return new StringType("TILTED");
-                } else if (data == Open1 || data == Open2) {
+                } else if (data == OPEN_1 || data == OPEN_2) {
                     return new StringType("OPEN");
                 }
 
             case CHANNEL_CONTACT:
                 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
-                if (data == Closed) {
+                if (data == CLOSED) {
                     return c.inverted ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
-                } else if (data == Tilted) {
+                } else if (data == TILTED) {
                     return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
-                } else if (data == Open1 || data == Open2) {
+                } else if (data == OPEN_1 || data == OPEN_2) {
                     return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
                 }
         }
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/Generic4BS.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/Generic4BS.java
deleted file mode 100644 (file)
index b449b4f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.eep.Generic;
-
-import org.openhab.binding.enocean.internal.messages.ERP1Message;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-public class Generic4BS extends GenericEEP {
-
-    public Generic4BS() {
-        super();
-    }
-
-    public Generic4BS(ERP1Message packet) {
-        super(packet);
-    }
-}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericEEP.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericEEP.java
deleted file mode 100644 (file)
index b69ec05..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.eep.Generic;
-
-import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
-import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.function.Function;
-
-import org.openhab.binding.enocean.internal.config.EnOceanChannelTransformationConfig;
-import org.openhab.binding.enocean.internal.eep.EEP;
-import org.openhab.binding.enocean.internal.messages.ERP1Message;
-import org.openhab.core.config.core.Configuration;
-import org.openhab.core.config.discovery.DiscoveryResultBuilder;
-import org.openhab.core.library.types.DateTimeType;
-import org.openhab.core.library.types.DecimalType;
-import org.openhab.core.library.types.HSBType;
-import org.openhab.core.library.types.OnOffType;
-import org.openhab.core.library.types.OpenClosedType;
-import org.openhab.core.library.types.PercentType;
-import org.openhab.core.library.types.PlayPauseType;
-import org.openhab.core.library.types.PointType;
-import org.openhab.core.library.types.RewindFastforwardType;
-import org.openhab.core.library.types.StringListType;
-import org.openhab.core.library.types.StringType;
-import org.openhab.core.library.types.UpDownType;
-import org.openhab.core.transform.actions.Transformation;
-import org.openhab.core.types.Command;
-import org.openhab.core.types.State;
-import org.openhab.core.types.UnDefType;
-import org.openhab.core.util.HexUtils;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-public class GenericEEP extends EEP {
-
-    final List<Class<? extends State>> supportedStates = Collections
-            .unmodifiableList(new LinkedList<Class<? extends State>>() {
-
-                private static final long serialVersionUID = 1L;
-
-                {
-                    add(DateTimeType.class);
-                    add(DecimalType.class);
-                    add(HSBType.class);
-                    add(OnOffType.class);
-                    add(OpenClosedType.class);
-                    add(PercentType.class);
-                    add(PlayPauseType.class);
-                    add(PointType.class);
-                    add(RewindFastforwardType.class);
-                    add(StringListType.class);
-                    add(StringType.class);
-                    add(UpDownType.class);
-                }
-            });
-
-    public GenericEEP() {
-        super();
-    }
-
-    public GenericEEP(ERP1Message packet) {
-        super(packet);
-    }
-
-    @Override
-    protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-        if (config != null) {
-            EnOceanChannelTransformationConfig transformationInfo = config.as(EnOceanChannelTransformationConfig.class);
-
-            String input = channelId + "|" + command.toString();
-            String output = Transformation.transform(transformationInfo.transformationType,
-                    transformationInfo.transformationFunction, input);
-
-            if (output != null && !output.isEmpty() && !input.equals(output)) {
-                try {
-                    setData(HexUtils.hexToBytes(output));
-                } catch (Exception e) {
-                    logger.debug("Command {} could not transformed", command.toString());
-                }
-            }
-        }
-    }
-
-    @Override
-    protected State convertToStateImpl(String channelId, String channelTypeId,
-            Function<String, State> getCurrentStateFunc, Configuration config) {
-        if (config != null) {
-            EnOceanChannelTransformationConfig transformationInfo = config.as(EnOceanChannelTransformationConfig.class);
-
-            String payload = HexUtils.bytesToHex(bytes);
-            String input = channelId + "|" + payload;
-            String output = Transformation.transform(transformationInfo.transformationType,
-                    transformationInfo.transformationFunction, input);
-
-            if (output != null && !output.isEmpty() && !input.equals(output)) {
-                String[] parts = output.split("\\|");
-
-                if (parts.length == 2) {
-                    Class<? extends State> state = supportedStates.stream().filter(s -> s.getName().contains(parts[0]))
-                            .findFirst().orElse(null);
-
-                    if (state != null) {
-                        if (state.isEnum()) {
-                            for (State s : state.getEnumConstants()) {
-                                if (s.toString().equalsIgnoreCase(parts[1])) {
-                                    return s;
-                                }
-                            }
-                            logger.debug("Could not find value '{}' for state '{}'", parts[1], parts[0]);
-                        } else {
-                            try {
-                                return state.getConstructor(String.class).newInstance(parts[1]);
-                            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
-                                    | InvocationTargetException | NoSuchMethodException | SecurityException e) {
-                                logger.debug("Could not create state '{}' with value '{}'", parts[0], parts[1]);
-                            }
-                        }
-                    } else {
-                        logger.debug("State '{}' not found", parts[0]);
-                    }
-                } else {
-                    logger.debug("Transformation result malformed: {}", output);
-                }
-            }
-        }
-
-        return UnDefType.UNDEF;
-    }
-
-    @Override
-    protected int getDataLength() {
-        if (packet != null) {
-            return packet.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
-        } else {
-            return bytes.length;
-        }
-    }
-
-    @Override
-    protected boolean validateData(byte[] bytes) {
-        return true;
-    }
-
-    @Override
-    public void addConfigPropertiesTo(DiscoveryResultBuilder discoveredThingResultBuilder) {
-        discoveredThingResultBuilder.withProperty(PARAMETER_SENDINGEEPID, getEEPType().getId())
-                .withProperty(PARAMETER_RECEIVINGEEPID, getEEPType().getId());
-    }
-}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericRPS.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericRPS.java
deleted file mode 100644 (file)
index 9955d8f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.eep.Generic;
-
-import org.openhab.binding.enocean.internal.messages.ERP1Message;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-public class GenericRPS extends GenericEEP {
-
-    public GenericRPS() {
-        super();
-    }
-
-    public GenericRPS(ERP1Message packet) {
-        super(packet);
-    }
-}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericVLD.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/Generic/GenericVLD.java
deleted file mode 100644 (file)
index f26ac35..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.eep.Generic;
-
-import org.openhab.binding.enocean.internal.messages.ERP1Message;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-public class GenericVLD extends GenericEEP {
-
-    public GenericVLD() {
-        super();
-    }
-
-    public GenericVLD(ERP1Message packet) {
-        super(packet);
-    }
-}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/Generic4BS.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/Generic4BS.java
new file mode 100644 (file)
index 0000000..e6dd3b4
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.eep.generic;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.ERP1Message;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class Generic4BS extends GenericEEP {
+
+    public Generic4BS() {
+        super();
+    }
+
+    public Generic4BS(ERP1Message packet) {
+        super(packet);
+    }
+}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericEEP.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericEEP.java
new file mode 100644 (file)
index 0000000..2c61a87
--- /dev/null
@@ -0,0 +1,175 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.eep.generic;
+
+import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
+import static org.openhab.binding.enocean.internal.messages.ESP3Packet.*;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Function;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.enocean.internal.config.EnOceanChannelTransformationConfig;
+import org.openhab.binding.enocean.internal.eep.EEP;
+import org.openhab.binding.enocean.internal.messages.ERP1Message;
+import org.openhab.core.config.core.Configuration;
+import org.openhab.core.config.discovery.DiscoveryResultBuilder;
+import org.openhab.core.library.types.DateTimeType;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.HSBType;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.library.types.OpenClosedType;
+import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.PlayPauseType;
+import org.openhab.core.library.types.PointType;
+import org.openhab.core.library.types.RewindFastforwardType;
+import org.openhab.core.library.types.StringListType;
+import org.openhab.core.library.types.StringType;
+import org.openhab.core.library.types.UpDownType;
+import org.openhab.core.transform.actions.Transformation;
+import org.openhab.core.types.Command;
+import org.openhab.core.types.State;
+import org.openhab.core.types.UnDefType;
+import org.openhab.core.util.HexUtils;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class GenericEEP extends EEP {
+
+    final List<Class<? extends State>> supportedStates = Collections
+            .unmodifiableList(new LinkedList<Class<? extends State>>() {
+                private static final long serialVersionUID = 1L;
+
+                {
+                    add(DateTimeType.class);
+                    add(DecimalType.class);
+                    add(HSBType.class);
+                    add(OnOffType.class);
+                    add(OpenClosedType.class);
+                    add(PercentType.class);
+                    add(PlayPauseType.class);
+                    add(PointType.class);
+                    add(RewindFastforwardType.class);
+                    add(StringListType.class);
+                    add(StringType.class);
+                    add(UpDownType.class);
+                }
+            });
+
+    public GenericEEP() {
+        super();
+    }
+
+    public GenericEEP(ERP1Message packet) {
+        super(packet);
+    }
+
+    @Override
+    protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
+            Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
+        if (config == null) {
+            logger.error("Cannot handle command {}, when transformation configuration is null", command.toString());
+            return;
+        }
+        EnOceanChannelTransformationConfig transformationInfo = config.as(EnOceanChannelTransformationConfig.class);
+
+        String input = channelId + "|" + command.toString();
+        String output = Transformation.transform(transformationInfo.transformationType,
+                transformationInfo.transformationFunction, input);
+
+        if (output != null && !output.isEmpty() && !input.equals(output)) {
+            try {
+                setData(HexUtils.hexToBytes(output));
+            } catch (IllegalArgumentException e) {
+                logger.debug("Command {} could not transformed", command.toString());
+                throw e;
+            }
+        }
+    }
+
+    @Override
+    protected State convertToStateImpl(String channelId, String channelTypeId,
+            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
+        EnOceanChannelTransformationConfig transformationInfo = config.as(EnOceanChannelTransformationConfig.class);
+
+        String payload = HexUtils.bytesToHex(bytes);
+        String input = channelId + "|" + payload;
+        String output = Transformation.transform(transformationInfo.transformationType,
+                transformationInfo.transformationFunction, input);
+
+        if (output != null && !output.isEmpty() && !input.equals(output)) {
+            String[] parts = output.split("\\|");
+
+            if (parts.length == 2) {
+                @Nullable
+                Class<? extends State> state = supportedStates.stream().filter(s -> s.getName().contains(parts[0]))
+                        .findFirst().orElse(null);
+
+                if (state != null) {
+                    if (state.isEnum()) {
+                        State[] states;
+                        if ((states = state.getEnumConstants()) != null) {
+                            for (State s : states) {
+                                if (s.toString().equalsIgnoreCase(parts[1])) {
+                                    return s;
+                                }
+                            }
+                        }
+                        logger.debug("Could not find value '{}' for state '{}'", parts[1], parts[0]);
+                    } else {
+                        try {
+                            return state.getConstructor(String.class).newInstance(parts[1]);
+                        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+                                | InvocationTargetException | NoSuchMethodException | SecurityException e) {
+                            logger.debug("Could not create state '{}' with value '{}'", parts[0], parts[1]);
+                        }
+                    }
+                } else {
+                    logger.debug("State '{}' not found", parts[0]);
+                }
+            } else {
+                logger.debug("Transformation result malformed: {}", output);
+            }
+        }
+
+        return UnDefType.UNDEF;
+    }
+
+    @Override
+    protected int getDataLength() {
+        ERP1Message localPacket = packet;
+        if (localPacket != null) {
+            return localPacket.getPayload().length - ESP3_SENDERID_LENGTH - ESP3_RORG_LENGTH - ESP3_STATUS_LENGTH;
+        } else {
+            return bytes.length;
+        }
+    }
+
+    @Override
+    protected boolean validateData(byte[] bytes) {
+        return true;
+    }
+
+    @Override
+    public void addConfigPropertiesTo(DiscoveryResultBuilder discoveredThingResultBuilder) {
+        discoveredThingResultBuilder.withProperty(PARAMETER_SENDINGEEPID, getEEPType().getId())
+                .withProperty(PARAMETER_RECEIVINGEEPID, getEEPType().getId());
+    }
+}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericRPS.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericRPS.java
new file mode 100644 (file)
index 0000000..68ab79f
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.eep.generic;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.ERP1Message;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class GenericRPS extends GenericEEP {
+
+    public GenericRPS() {
+        super();
+    }
+
+    public GenericRPS(ERP1Message packet) {
+        super(packet);
+    }
+}
diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericVLD.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/generic/GenericVLD.java
new file mode 100644 (file)
index 0000000..d25071b
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.eep.generic;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.ERP1Message;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class GenericVLD extends GenericEEP {
+
+    public GenericVLD() {
+        super();
+    }
+
+    public GenericVLD(ERP1Message packet) {
+        super(packet);
+    }
+}
index 8c4177c5be3811dc042d8daf6145478abff0cdb4..a5ffacc312b5c5bd6aa812bb5d3776017f2190a9 100644 (file)
@@ -22,6 +22,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanActuatorConfig;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.eep.EEPFactory;
@@ -46,6 +48,7 @@ import org.openhab.core.util.HexUtils;
  *         This class defines base functionality for sending eep messages. This class extends EnOceanBaseSensorHandler
  *         class as most actuator things send status or response messages, too.
  */
+@NonNullByDefault
 public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
 
     // List of thing types which support sending of eep messages
@@ -53,12 +56,13 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
             THING_TYPE_MEASUREMENTSWITCH, THING_TYPE_GENERICTHING, THING_TYPE_ROLLERSHUTTER, THING_TYPE_THERMOSTAT,
             THING_TYPE_HEATRECOVERYVENTILATION);
 
-    protected byte[] senderId; // base id of bridge + senderIdOffset, used for sending msg
-    protected byte[] destinationId; // in case of broadcast FFFFFFFF otherwise the enocean id of the device
+    protected byte[] senderId = new byte[0]; // base id of bridge + senderIdOffset, used for sending msg
+    protected byte[] destinationId = new byte[0]; // in case of broadcast FFFFFFFF otherwise the enocean id of the
+                                                  // device
 
-    protected EEPType sendingEEPType = null;
+    protected @Nullable EEPType sendingEEPType = null;
 
-    private ScheduledFuture<?> refreshJob; // used for polling current status of thing
+    private @Nullable ScheduledFuture<?> refreshJob; // used for polling current status of thing
 
     public EnOceanBaseActuatorHandler(Thing thing, ItemChannelLinkRegistry itemChannelLinkRegistry) {
         super(thing, itemChannelLinkRegistry);
@@ -69,7 +73,7 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
      * @param senderIdOffset to be validated
      * @return true if senderIdOffset is between ]0;128[ and is not used yet
      */
-    private boolean validateSenderIdOffset(Integer senderIdOffset) {
+    private boolean validateSenderIdOffset(@Nullable Integer senderIdOffset) {
         if (senderIdOffset == null) {
             return true;
         }
@@ -94,12 +98,16 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
     }
 
     @Override
+    @Nullable
     Collection<EEPType> getEEPTypes() {
         Collection<EEPType> r = super.getEEPTypes();
+
         if (sendingEEPType == null) {
             return r;
         }
-
+        if (r == null) {
+            r = Collections.emptyList();
+        }
         return Collections.unmodifiableCollection(Stream
                 .concat(r.stream(), Collections.singletonList(sendingEEPType).stream()).collect(Collectors.toList()));
     }
@@ -107,18 +115,16 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
     @Override
     boolean validateConfig() {
         EnOceanActuatorConfig config = getConfiguration();
-        if (config == null) {
-            configurationErrorDescription = "Configuration is not valid";
-            return false;
-        }
 
-        if (config.sendingEEPId == null || config.sendingEEPId.isEmpty()) {
+        if (config.sendingEEPId.isEmpty()) {
             configurationErrorDescription = "Sending EEP must be provided";
             return false;
         }
 
+        EEPType localEEPType = null;
         try {
-            sendingEEPType = EEPType.getType(getConfiguration().sendingEEPId);
+            localEEPType = EEPType.getType(getConfiguration().sendingEEPId);
+            sendingEEPType = localEEPType;
         } catch (IllegalArgumentException e) {
             configurationErrorDescription = "Sending EEP is not supported";
             return false;
@@ -126,7 +132,7 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
 
         if (super.validateConfig()) {
             try {
-                if (sendingEEPType.getSupportsRefresh()) {
+                if (localEEPType.getSupportsRefresh()) {
                     if (getConfiguration().pollingInterval > 0) {
                         refreshJob = scheduler.scheduleWithFixedDelay(() -> {
                             try {
@@ -166,28 +172,30 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
         // Generic things are treated as actuator things, however to support also generic sensors one can omit
         // senderIdOffset
         // TODO: seperate generic actuators from generic sensors?
-        if ((getConfiguration().senderIdOffset == null
-                && THING_TYPE_GENERICTHING.equals(this.getThing().getThingTypeUID()))) {
+        Integer senderOffset = getConfiguration().senderIdOffset;
+
+        if ((senderOffset == null && THING_TYPE_GENERICTHING.equals(this.getThing().getThingTypeUID()))) {
             return true;
         }
 
         // if senderIdOffset is not set, the next free senderIdOffset is determined
-        if (getConfiguration().senderIdOffset == null) {
+        if (senderOffset == null) {
             Configuration updateConfig = editConfiguration();
-            getConfiguration().senderIdOffset = bridgeHandler.getNextSenderId(thing);
-            if (getConfiguration().senderIdOffset == null) {
+            senderOffset = bridgeHandler.getNextSenderId(thing);
+            getConfiguration().senderIdOffset = senderOffset;
+            if (senderOffset == null) {
                 configurationErrorDescription = "Could not get a free sender Id from Bridge";
                 return false;
             }
-            updateConfig.put(PARAMETER_SENDERIDOFFSET, getConfiguration().senderIdOffset);
+            updateConfig.put(PARAMETER_SENDERIDOFFSET, senderOffset);
             updateConfiguration(updateConfig);
         }
 
         byte[] baseId = bridgeHandler.getBaseId();
-        baseId[3] = (byte) ((baseId[3] + getConfiguration().senderIdOffset) & 0xFF);
+        baseId[3] = (byte) ((baseId[3] + senderOffset) & 0xFF);
         this.senderId = baseId;
         this.updateProperty(PROPERTY_SENDINGENOCEAN_ID, HexUtils.bytesToHex(this.senderId));
-        bridgeHandler.addSender(getConfiguration().senderIdOffset, thing);
+        bridgeHandler.addSender(senderOffset, thing);
         return true;
     }
 
@@ -205,21 +213,34 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
         sendMessage(VIRTUALCHANNEL_SEND_COMMAND, VIRTUALCHANNEL_SEND_COMMAND, OnOffType.ON, null);
     }
 
-    protected void sendMessage(String channelId, String channelTypeId, Command command, Configuration channelConfig) {
-        EEP eep = EEPFactory.createEEP(sendingEEPType);
+    protected void sendMessage(String channelId, String channelTypeId, Command command,
+            @Nullable Configuration channelConfig) {
+        EEPType sendType = sendingEEPType;
+        if (sendType == null) {
+            logger.warn("cannot send a message with an empty EEPType");
+            return;
+        }
+        EEP eep = EEPFactory.createEEP(sendType);
         if (eep.convertFromCommand(channelId, channelTypeId, command, id -> getCurrentState(id), channelConfig)
                 .hasData()) {
             BasePacket msg = eep.setSenderId(senderId).setDestinationId(destinationId)
                     .setSuppressRepeating(getConfiguration().suppressRepeating).getERP1Message();
-
-            getBridgeHandler().sendMessage(msg, null);
+            if (msg == null) {
+                logger.warn("cannot send an empty message");
+                return;
+            }
+            EnOceanBridgeHandler handler = getBridgeHandler();
+            if (handler != null) {
+                handler.sendMessage(msg, null);
+            }
         }
     }
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
         // We must have a valid sendingEEPType and sender id to send commands
-        if (sendingEEPType == null || senderId == null) {
+        EEPType localsendingType = sendingEEPType;
+        if (localsendingType == null) {
             return;
         }
 
@@ -235,7 +256,7 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
 
         // check if we do support refreshs
         if (command == RefreshType.REFRESH) {
-            if (!sendingEEPType.getSupportsRefresh()) {
+            if (!localsendingType.getSupportsRefresh()) {
                 return;
             }
 
@@ -258,11 +279,11 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
 
     @Override
     public void handleRemoval() {
-
         EnOceanBridgeHandler bridgeHandler = getBridgeHandler();
         if (bridgeHandler != null) {
-            if (getConfiguration().senderIdOffset != null && getConfiguration().senderIdOffset > 0) {
-                bridgeHandler.removeSender(getConfiguration().senderIdOffset);
+            Integer senderOffset = getConfiguration().senderIdOffset;
+            if (senderOffset != null && senderOffset > 0) {
+                bridgeHandler.removeSender(senderOffset);
             }
 
             if (bridgeHandler.isSmackClient(this.thing)) {
@@ -275,8 +296,9 @@ public class EnOceanBaseActuatorHandler extends EnOceanBaseSensorHandler {
 
     @Override
     public void dispose() {
-        if (refreshJob != null && !refreshJob.isCancelled()) {
-            refreshJob.cancel(true);
+        ScheduledFuture<?> localRefreshJob = refreshJob;
+        if (localRefreshJob != null && !localRefreshJob.isCancelled()) {
+            localRefreshJob.cancel(true);
             refreshJob = null;
         }
     }
index 67d0790ddb4f6b51fc7a655619ca9fa3c0fb007c..b67e7ec2ccc22bc34e60a11f5c1c524ff0de09f2 100644 (file)
@@ -23,6 +23,8 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanBaseConfig;
 import org.openhab.binding.enocean.internal.eep.EEP;
 import org.openhab.binding.enocean.internal.eep.EEPFactory;
@@ -48,6 +50,7 @@ import org.openhab.core.util.HexUtils;
  * @author Daniel Weber - Initial contribution
  *         This class defines base functionality for receiving eep messages.
  */
+@NonNullByDefault
 public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements PacketListener {
 
     // List of all thing types which support receiving of eep messages
@@ -60,7 +63,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
 
     protected final Hashtable<RORG, EEPType> receivingEEPTypes = new Hashtable<>();
 
-    protected ScheduledFuture<?> responseFuture = null;
+    protected @Nullable ScheduledFuture<?> responseFuture = null;
 
     public EnOceanBaseSensorHandler(Thing thing, ItemChannelLinkRegistry itemChannelLinkRegistry) {
         super(thing, itemChannelLinkRegistry);
@@ -72,6 +75,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
     }
 
     @Override
+    @Nullable
     Collection<EEPType> getEEPTypes() {
         return Collections.unmodifiableCollection(receivingEEPTypes.values());
     }
@@ -82,7 +86,8 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
         try {
             config.receivingEEPId.forEach(receivingEEP -> {
                 EEPType receivingEEPType = EEPType.getType(receivingEEP);
-                if (receivingEEPTypes.putIfAbsent(receivingEEPType.getRORG(), receivingEEPType) != null) {
+                EEPType existingKey = receivingEEPTypes.putIfAbsent(receivingEEPType.getRORG(), receivingEEPType);
+                if (existingKey != null) {
                     throw new IllegalArgumentException("Receiving more than one EEP of the same RORG is not supported");
                 }
             });
@@ -90,7 +95,9 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
                 receivingEEPTypes.put(EEPType.SigBatteryStatus.getRORG(), EEPType.SigBatteryStatus);
             }
         } catch (IllegalArgumentException e) {
-            configurationErrorDescription = e.getMessage();
+            String eMessage = e.getMessage();
+            configurationErrorDescription = eMessage != null ? eMessage
+                    : "IllegalArgumentException without a message was thrown";
             return false;
         }
 
@@ -102,7 +109,10 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
         }
 
         if (!config.enoceanId.equals(EMPTYENOCEANID)) {
-            getBridgeHandler().addPacketListener(this);
+            EnOceanBridgeHandler handler = getBridgeHandler();
+            if (handler != null) {
+                handler.addPacketListener(this);
+            }
         }
 
         return true;
@@ -115,8 +125,9 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
 
     @Override
     public void handleRemoval() {
-        if (getBridgeHandler() != null) {
-            getBridgeHandler().removePacketListener(this);
+        EnOceanBridgeHandler handler = getBridgeHandler();
+        if (handler != null) {
+            handler.removePacketListener(this);
         }
         super.handleRemoval();
     }
@@ -142,12 +153,13 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
     @Override
     public void packetReceived(BasePacket packet) {
         ERP1Message msg = (ERP1Message) packet;
-        EEPType receivingEEPType = receivingEEPTypes.get(msg.getRORG());
-        if (receivingEEPType == null) {
+
+        EEPType localReceivingType = receivingEEPTypes.get(msg.getRORG());
+        if (localReceivingType == null) {
             return;
         }
 
-        EEP eep = EEPFactory.buildEEP(receivingEEPType, (ERP1Message) packet);
+        EEP eep = EEPFactory.buildEEP(localReceivingType, (ERP1Message) packet);
         logger.debug("ESP Packet payload {} for {} received", HexUtils.bytesToHex(packet.getPayload()),
                 HexUtils.bytesToHex(msg.getSenderId()));
 
@@ -155,7 +167,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
             byte[] senderId = msg.getSenderId();
 
             // try to interpret received message for all linked or trigger channels
-            getThing().getChannels().stream().filter(channelFilter(receivingEEPType, senderId))
+            getThing().getChannels().stream().filter(channelFilter(localReceivingType, senderId))
                     .sorted(Comparator.comparing(Channel::getKind)) // handle state channels first
                     .forEachOrdered(channel -> {
 
@@ -171,27 +183,31 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
                                         this::getCurrentState);
 
                                 // if message can be interpreted (result != UnDefType.UNDEF) => update item state
-                                if (result != null && result != UnDefType.UNDEF) {
+                                if (result != UnDefType.UNDEF) {
                                     updateState(channelId, result);
                                 }
                                 break;
                             case TRIGGER:
                                 String lastEvent = lastEvents.get(channelId);
-                                String event = eep.convertToEvent(channelId, channelTypeId, lastEvent, channelConfig);
-                                if (event != null) {
-                                    triggerChannel(channel.getUID(), event);
-                                    lastEvents.put(channelId, event);
+                                if (lastEvent != null) {
+                                    String event = eep.convertToEvent(channelId, channelTypeId, lastEvent,
+                                            channelConfig);
+                                    if (event != null) {
+                                        triggerChannel(channel.getUID(), event);
+                                        lastEvents.put(channelId, event);
+                                    }
                                 }
                                 break;
                         }
                     });
 
-            if (receivingEEPType.getRequstesResponse()) {
+            if (localReceivingType.getRequstesResponse()) {
                 // fire trigger for receive
                 triggerChannel(prepareAnswer, "requestAnswer");
                 // Send response after 100ms
-                if (responseFuture == null || responseFuture.isDone()) {
-                    responseFuture = scheduler.schedule(this::sendRequestResponse, 100, TimeUnit.MILLISECONDS);
+                ScheduledFuture<?> localResponseFuture = responseFuture;
+                if (localResponseFuture == null || localResponseFuture.isDone()) {
+                    localResponseFuture = scheduler.schedule(this::sendRequestResponse, 100, TimeUnit.MILLISECONDS);
                 }
             }
         }
index e308d4c6af447a7a64f60d96d52793a85c7a50f9..c598caa30776e538b6f02e54695d189dfc416777 100644 (file)
@@ -22,7 +22,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanChannelDescription;
 import org.openhab.binding.enocean.internal.config.EnOceanBaseConfig;
 import org.openhab.binding.enocean.internal.eep.EEPType;
@@ -50,22 +51,23 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
 
-    private EnOceanBridgeHandler gateway = null;
+    private @Nullable EnOceanBridgeHandler gateway = null;
     protected Logger logger = LoggerFactory.getLogger(EnOceanBaseThingHandler.class);
 
-    protected String configurationErrorDescription;
+    protected String configurationErrorDescription = "";
 
     // There is no data structure which holds the last triggered event, so we have to implement it by ourself
     // This is especially needed for press and release events
     protected Hashtable<String, String> lastEvents = new Hashtable<>();
 
-    protected EnOceanBaseConfig config = null;
+    protected EnOceanBaseConfig config = new EnOceanBaseConfig();
 
     private ItemChannelLinkRegistry itemChannelLinkRegistry;
 
-    protected @NonNull ChannelUID prepareAnswer;
+    protected ChannelUID prepareAnswer;
 
     public EnOceanBaseThingHandler(Thing thing, ItemChannelLinkRegistry itemChannelLinkRegistry) {
         super(thing);
@@ -77,7 +79,6 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
     public void initialize() {
         logger.debug("Initializing enocean base thing handler.");
         this.gateway = null; // reset gateway in case we change the bridge
-        this.config = null;
         Bridge bridge = getBridge();
         if (bridge == null) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "A bridge is required");
@@ -89,29 +90,24 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
     private void initializeThing(ThingStatus bridgeStatus) {
         logger.debug("initializeThing thing {} bridge status {}", getThing().getUID(), bridgeStatus);
 
-        if (this.itemChannelLinkRegistry == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "ItemChannelLinkRegistry could not be found");
-        } else {
-            if (getBridgeHandler() != null) {
-                if (bridgeStatus == ThingStatus.ONLINE) {
-                    initializeConfig();
-                    if (validateConfig()) {
-                        updateStatus(ThingStatus.ONLINE);
-                    } else {
-                        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                                configurationErrorDescription);
-                    }
+        if (getBridgeHandler() != null) {
+            if (bridgeStatus == ThingStatus.ONLINE) {
+                initializeConfig();
+                if (validateConfig()) {
+                    updateStatus(ThingStatus.ONLINE);
                 } else {
-                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
+                            configurationErrorDescription);
                 }
             } else {
-                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "A bridge is required");
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
             }
+        } else {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "A bridge is required");
         }
     }
 
-    protected boolean validateEnoceanId(String id) {
+    protected boolean validateEnoceanId(@Nullable String id) {
         if (id == null || id.isEmpty()) {
             return false;
         } else {
@@ -132,11 +128,10 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
 
     abstract boolean validateConfig();
 
-    abstract Collection<EEPType> getEEPTypes();
+    abstract @Nullable Collection<EEPType> getEEPTypes();
 
     protected void updateChannels() {
-        @NonNull
-        List<@NonNull Channel> channelList = new LinkedList<>(this.getThing().getChannels());
+        List<Channel> channelList = new LinkedList<>(this.getThing().getChannels());
         Collection<EEPType> eeps = getEEPTypes();
         if (eeps == null) {
             return;
@@ -147,10 +142,10 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
                 channelList.removeIf(channel -> !eeps.stream().anyMatch(eep -> eep.isChannelSupported(channel))));
 
         // Next create supported channels of each selected eep
-        eeps.stream().flatMap(eep -> eep.GetSupportedChannels().keySet().stream().map(id -> new SimpleEntry<>(id, eep)))
+        eeps.stream().flatMap(eep -> eep.getSupportedChannels().keySet().stream().map(id -> new SimpleEntry<>(id, eep)))
                 .forEach(entry -> {
                     String channelId = entry.getKey();
-                    EnOceanChannelDescription cd = entry.getValue().GetSupportedChannels().get(channelId);
+                    EnOceanChannelDescription cd = entry.getValue().getSupportedChannels().get(channelId);
 
                     if (cd == null) {
                         return;
@@ -189,7 +184,7 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
         }
     }
 
-    protected State getCurrentState(Channel channel) {
+    protected State getCurrentState(@Nullable Channel channel) {
         if (channel != null) {
             Set<Item> items = itemChannelLinkRegistry.getLinkedItems(channel.getUID());
             for (Item item : items) {
@@ -207,7 +202,7 @@ public abstract class EnOceanBaseThingHandler extends ConfigStatusThingHandler {
         return getCurrentState(getThing().getChannel(channelId));
     }
 
-    protected synchronized EnOceanBridgeHandler getBridgeHandler() {
+    protected synchronized @Nullable EnOceanBridgeHandler getBridgeHandler() {
         if (this.gateway == null) {
             Bridge bridge = getBridge();
             if (bridge == null) {
index 91be555bcb321e06af067d66e788c580afff95b6..cadb17f98de388c6fcb4a911018c9d549d9cceae 100644 (file)
@@ -23,6 +23,8 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanConfigStatusMessage;
 import org.openhab.binding.enocean.internal.config.EnOceanBaseConfig;
 import org.openhab.binding.enocean.internal.config.EnOceanBridgeConfig;
@@ -31,12 +33,12 @@ import org.openhab.binding.enocean.internal.messages.BasePacket;
 import org.openhab.binding.enocean.internal.messages.ESP3PacketFactory;
 import org.openhab.binding.enocean.internal.messages.Response;
 import org.openhab.binding.enocean.internal.messages.Response.ResponseType;
-import org.openhab.binding.enocean.internal.messages.Responses.BaseResponse;
-import org.openhab.binding.enocean.internal.messages.Responses.RDBaseIdResponse;
-import org.openhab.binding.enocean.internal.messages.Responses.RDLearnedClientsResponse;
-import org.openhab.binding.enocean.internal.messages.Responses.RDLearnedClientsResponse.LearnedClient;
-import org.openhab.binding.enocean.internal.messages.Responses.RDRepeaterResponse;
-import org.openhab.binding.enocean.internal.messages.Responses.RDVersionResponse;
+import org.openhab.binding.enocean.internal.messages.responses.BaseResponse;
+import org.openhab.binding.enocean.internal.messages.responses.RDBaseIdResponse;
+import org.openhab.binding.enocean.internal.messages.responses.RDLearnedClientsResponse;
+import org.openhab.binding.enocean.internal.messages.responses.RDLearnedClientsResponse.LearnedClient;
+import org.openhab.binding.enocean.internal.messages.responses.RDRepeaterResponse;
+import org.openhab.binding.enocean.internal.messages.responses.RDVersionResponse;
 import org.openhab.binding.enocean.internal.transceiver.EnOceanESP2Transceiver;
 import org.openhab.binding.enocean.internal.transceiver.EnOceanESP3Transceiver;
 import org.openhab.binding.enocean.internal.transceiver.EnOceanTransceiver;
@@ -69,16 +71,17 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements TransceiverErrorListener {
 
     private Logger logger = LoggerFactory.getLogger(EnOceanBridgeHandler.class);
 
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BRIDGE);
 
-    private EnOceanTransceiver transceiver; // holds connection to serial/tcp port and sends/receives messages
-    private ScheduledFuture<?> connectorTask; // is used for reconnection if something goes wrong
+    private @Nullable EnOceanTransceiver transceiver; // holds connection to serial/tcp port and sends/receives messages
+    private @Nullable ScheduledFuture<?> connectorTask; // is used for reconnection if something goes wrong
 
-    private byte[] baseId = null;
+    private byte[] baseId = new byte[0];
     private Thing[] sendingThings = new Thing[128];
 
     private SerialPortManager serialPortManager;
@@ -161,28 +164,26 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
     @Override
     public void initialize() {
         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "trying to connect to gateway...");
-        if (this.serialPortManager == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "SerialPortManager could not be found");
-        } else {
-            if (connectorTask == null || connectorTask.isDone()) {
-                connectorTask = scheduler.scheduleWithFixedDelay(new Runnable() {
-                    @Override
-                    public void run() {
-                        if (thing.getStatus() != ThingStatus.ONLINE) {
-                            initTransceiver();
-                        }
+
+        ScheduledFuture<?> localConnectorTask = connectorTask;
+        if (localConnectorTask == null || localConnectorTask.isDone()) {
+            localConnectorTask = scheduler.scheduleWithFixedDelay(new Runnable() {
+                @Override
+                public void run() {
+                    if (thing.getStatus() != ThingStatus.ONLINE) {
+                        initTransceiver();
                     }
-                }, 0, 60, TimeUnit.SECONDS);
-            }
+                }
+            }, 0, 60, TimeUnit.SECONDS);
         }
     }
 
     private synchronized void initTransceiver() {
         try {
             EnOceanBridgeConfig c = getThing().getConfiguration().as(EnOceanBridgeConfig.class);
-            if (transceiver != null) {
-                transceiver.ShutDown();
+            EnOceanTransceiver localTransceiver = transceiver;
+            if (localTransceiver != null) {
+                localTransceiver.shutDown();
             }
 
             switch (c.getESPVersion()) {
@@ -199,15 +200,22 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
                     break;
             }
 
+            localTransceiver = transceiver;
+            if (localTransceiver == null) {
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
+                        "Failed to initialize EnOceanTransceiver");
+                return;
+            }
+
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "opening serial port...");
-            transceiver.Initialize();
+            localTransceiver.initilize();
 
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "starting rx thread...");
-            transceiver.StartReceiving(scheduler);
+            localTransceiver.startReceiving(scheduler);
             logger.info("EnOceanSerialTransceiver RX thread up and running");
 
             if (c.rs485) {
-                if (c.rs485BaseId != null && !c.rs485BaseId.isEmpty()) {
+                if (!c.rs485BaseId.isEmpty()) {
                     baseId = HexUtils.hexToBytes(c.rs485BaseId);
                     if (baseId.length != 4) {
                         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
@@ -224,18 +232,21 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
                         "trying to get bridge base id...");
 
                 logger.debug("request base id");
-                transceiver.sendBasePacket(ESP3PacketFactory.CO_RD_IDBASE,
+                localTransceiver.sendBasePacket(ESP3PacketFactory.CO_RD_IDBASE,
                         new ResponseListenerIgnoringTimeouts<RDBaseIdResponse>() {
+
                             @Override
                             public void responseReceived(RDBaseIdResponse response) {
                                 logger.debug("received response for base id");
                                 if (response.isValid() && response.isOK()) {
                                     baseId = response.getBaseId().clone();
                                     updateProperty(PROPERTY_BASE_ID, HexUtils.bytesToHex(response.getBaseId()));
-                                    updateProperty(PROPERTY_REMAINING_WRITE_CYCLES_Base_ID,
+                                    updateProperty(PROPERTY_REMAINING_WRITE_CYCLES_BASE_ID,
                                             Integer.toString(response.getRemainingWriteCycles()));
-                                    transceiver.setFilteredDeviceId(baseId);
-
+                                    EnOceanTransceiver localTransceiver = transceiver;
+                                    if (localTransceiver != null) {
+                                        localTransceiver.setFilteredDeviceId(baseId);
+                                    }
                                     updateStatus(ThingStatus.ONLINE);
                                 } else {
                                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
@@ -246,12 +257,11 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
 
                 if (c.getESPVersion() == ESPVersion.ESP3) {
                     logger.debug("set postmaster mailboxes");
-                    transceiver.sendBasePacket(ESP3PacketFactory.SA_WR_POSTMASTER((byte) (c.enableSmack ? 20 : 0)),
+                    localTransceiver.sendBasePacket(ESP3PacketFactory.SA_WR_POSTMASTER((byte) (c.enableSmack ? 20 : 0)),
                             new ResponseListenerIgnoringTimeouts<BaseResponse>() {
 
                                 @Override
                                 public void responseReceived(BaseResponse response) {
-
                                     logger.debug("received response for postmaster mailboxes");
                                     if (response.isOK()) {
                                         updateProperty("Postmaster mailboxes:",
@@ -268,8 +278,9 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
             }
 
             logger.debug("request version info");
-            transceiver.sendBasePacket(ESP3PacketFactory.CO_RD_VERSION,
+            localTransceiver.sendBasePacket(ESP3PacketFactory.CO_RD_VERSION,
                     new ResponseListenerIgnoringTimeouts<RDVersionResponse>() {
+
                         @Override
                         public void responseReceived(RDVersionResponse response) {
                             if (response.isValid() && response.isOK()) {
@@ -292,13 +303,15 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
 
     @Override
     public synchronized void dispose() {
-        if (transceiver != null) {
-            transceiver.ShutDown();
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.shutDown();
             transceiver = null;
         }
 
-        if (connectorTask != null && !connectorTask.isDone()) {
-            connectorTask.cancel(true);
+        ScheduledFuture<?> localConnectorTask = connectorTask;
+        if (localConnectorTask != null && !localConnectorTask.isDone()) {
+            localConnectorTask.cancel(true);
             connectorTask = null;
         }
 
@@ -311,10 +324,13 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
 
         // The serial port must be provided
         String path = getThing().getConfiguration().as(EnOceanBridgeConfig.class).path;
-        if (path == null || path.isEmpty()) {
-            configStatusMessages.add(ConfigStatusMessage.Builder.error(PATH)
+        if (path.isEmpty()) {
+            ConfigStatusMessage statusMessage = ConfigStatusMessage.Builder.error(PATH)
                     .withMessageKeySuffix(EnOceanConfigStatusMessage.PORT_MISSING.getMessageKey()).withArguments(PATH)
-                    .build());
+                    .build();
+            if (statusMessage != null) {
+                configStatusMessages.add(statusMessage);
+            }
         }
 
         return configStatusMessages;
@@ -328,19 +344,22 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
         return smackClients.contains(sender.getConfiguration().as(EnOceanBaseConfig.class).enoceanId);
     }
 
-    public Integer getNextSenderId(Thing sender) {
+    public @Nullable Integer getNextSenderId(Thing sender) {
         return getNextSenderId(sender.getConfiguration().as(EnOceanBaseConfig.class).enoceanId);
     }
 
-    public Integer getNextSenderId(String enoceanId) {
+    public @Nullable Integer getNextSenderId(String enoceanId) {
         EnOceanBridgeConfig config = getConfigAs(EnOceanBridgeConfig.class);
-
-        if (config.nextSenderId != null && sendingThings[config.nextSenderId] == null) {
+        Integer senderId = config.nextSenderId;
+        if (senderId == null) {
+            return null;
+        }
+        if (sendingThings[senderId] == null) {
             Configuration c = this.editConfiguration();
             c.put(PARAMETER_NEXT_SENDERID, null);
             updateConfiguration(c);
 
-            return config.nextSenderId;
+            return senderId;
         }
 
         for (int i = 1; i < sendingThings.length; i++) {
@@ -366,9 +385,14 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
         sendingThings[id] = null;
     }
 
-    public <T extends Response> void sendMessage(BasePacket message, ResponseListener<T> responseListener) {
+    public <T extends @Nullable Response> void sendMessage(BasePacket message,
+            @Nullable ResponseListener<T> responseListener) {
         try {
-            transceiver.sendBasePacket(message, responseListener);
+            EnOceanTransceiver localTransceiver = transceiver;
+            if (localTransceiver == null) {
+                throw new IOException("EnOceanTransceiver has state null");
+            }
+            localTransceiver.sendBasePacket(message, responseListener);
         } catch (IOException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
         }
@@ -379,8 +403,9 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
     }
 
     public void addPacketListener(PacketListener listener, long senderIdToListenTo) {
-        if (transceiver != null) {
-            transceiver.addPacketListener(listener, senderIdToListenTo);
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.addPacketListener(listener, senderIdToListenTo);
         }
     }
 
@@ -389,24 +414,29 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
     }
 
     public void removePacketListener(PacketListener listener, long senderIdToListenTo) {
-        if (transceiver != null) {
-            transceiver.removePacketListener(listener, senderIdToListenTo);
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.removePacketListener(listener, senderIdToListenTo);
         }
     }
 
     public void startDiscovery(TeachInListener teachInListener) {
-        transceiver.startDiscovery(teachInListener);
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.startDiscovery(teachInListener);
+        }
 
         if (smackAvailable) {
             // activate smack teach in
             logger.debug("activate smack teach in");
             try {
-                transceiver.sendBasePacket(ESP3PacketFactory.SA_WR_LEARNMODE(true),
+                if (localTransceiver == null) {
+                    throw new IOException("EnOceanTransceiver has state null");
+                }
+                localTransceiver.sendBasePacket(ESP3PacketFactory.SA_WR_LEARNMODE(true),
                         new ResponseListenerIgnoringTimeouts<BaseResponse>() {
-
                             @Override
                             public void responseReceived(BaseResponse response) {
-
                                 if (response.isOK()) {
                                     logger.debug("Smack teach in activated");
                                 }
@@ -420,10 +450,16 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
     }
 
     public void stopDiscovery() {
-        transceiver.stopDiscovery();
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.stopDiscovery();
+        }
 
         try {
-            transceiver.sendBasePacket(ESP3PacketFactory.SA_WR_LEARNMODE(false), null);
+            if (localTransceiver == null) {
+                throw new IOException("EnOceanTransceiver has state null");
+            }
+            localTransceiver.sendBasePacket(ESP3PacketFactory.SA_WR_LEARNMODE(false), null);
             refreshProperties();
         } catch (IOException e) {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
@@ -433,41 +469,43 @@ public class EnOceanBridgeHandler extends ConfigStatusBridgeHandler implements T
 
     private void refreshProperties() {
         if (getThing().getStatus() == ThingStatus.ONLINE && smackAvailable) {
-
             logger.debug("request learned smack clients");
             try {
-                transceiver.sendBasePacket(ESP3PacketFactory.SA_RD_LEARNEDCLIENTS,
-                        new ResponseListenerIgnoringTimeouts<RDLearnedClientsResponse>() {
-
-                            @Override
-                            public void responseReceived(RDLearnedClientsResponse response) {
-
-                                logger.debug("received response for learned smack clients");
-                                if (response.isValid() && response.isOK()) {
-                                    LearnedClient[] clients = response.getLearnedClients();
-                                    updateProperty("Learned smart ack clients", Integer.toString(clients.length));
-                                    updateProperty("Smart ack clients",
-                                            Arrays.stream(clients)
-                                                    .map(x -> String.format("%s (MB Idx: %d)",
-                                                            HexUtils.bytesToHex(x.clientId), x.mailboxIndex))
-                                                    .collect(Collectors.joining(", ")));
-                                    smackClients = Arrays.stream(clients).map(x -> HexUtils.bytesToHex(x.clientId))
-                                            .collect(Collectors.toSet());
+                EnOceanTransceiver localTransceiver = transceiver;
+                if (localTransceiver != null) {
+                    localTransceiver.sendBasePacket(ESP3PacketFactory.SA_RD_LEARNEDCLIENTS,
+                            new ResponseListenerIgnoringTimeouts<RDLearnedClientsResponse>() {
+                                @Override
+                                public void responseReceived(RDLearnedClientsResponse response) {
+                                    logger.debug("received response for learned smack clients");
+                                    if (response.isValid() && response.isOK()) {
+                                        LearnedClient[] clients = response.getLearnedClients();
+                                        updateProperty("Learned smart ack clients", Integer.toString(clients.length));
+                                        updateProperty("Smart ack clients",
+                                                Arrays.stream(clients)
+                                                        .map(x -> String.format("%s (MB Idx: %d)",
+                                                                HexUtils.bytesToHex(x.clientId), x.mailboxIndex))
+                                                        .collect(Collectors.joining(", ")));
+                                        smackClients = Arrays.stream(clients).map(x -> HexUtils.bytesToHex(x.clientId))
+                                                .collect(Collectors.toSet());
+                                    }
                                 }
-                            }
-                        });
+                            });
+                }
             } catch (IOException e) {
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
                         "Smack packet could not be send: " + e.getMessage());
-
             }
         }
     }
 
     @Override
-    public void ErrorOccured(Throwable exception) {
-        transceiver.ShutDown();
-        transceiver = null;
+    public void errorOccured(Throwable exception) {
+        EnOceanTransceiver localTransceiver = transceiver;
+        if (localTransceiver != null) {
+            localTransceiver.shutDown();
+            transceiver = null;
+        }
         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, exception.getMessage());
     }
 
index c670378b44e473278bba1d74bf5f974168ffc7e3..f0d94de609b1cce0e6d904f408c6e7daf24351dd 100644 (file)
@@ -19,7 +19,8 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.config.EnOceanActuatorConfig;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchConfigBase.SwitchMode;
 import org.openhab.binding.enocean.internal.config.EnOceanChannelRockerSwitchListenerConfig;
@@ -51,12 +52,14 @@ import org.openhab.core.util.HexUtils;
  *         This class defines base functionality for sending eep messages. This class extends EnOceanBaseSensorHandler
  *         class as most actuator things send status or response messages, too.
  */
+@NonNullByDefault
 public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
 
     // List of thing types which support sending of eep messages
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_CLASSICDEVICE);
 
     private StringType lastTriggerEvent = StringType.valueOf(CommonTriggerEvents.DIR1_PRESSED);
+    @Nullable
     ScheduledFuture<?> releaseFuture = null;
 
     public EnOceanClassicDeviceHandler(Thing thing, ItemChannelLinkRegistry itemChannelLinkRegistry) {
@@ -76,7 +79,7 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
     }
 
     @Override
-    public void channelLinked(@NonNull ChannelUID channelUID) {
+    public void channelLinked(ChannelUID channelUID) {
         super.channelLinked(channelUID);
 
         // if linked channel is a listening channel => put listener
@@ -90,7 +93,10 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
 
         // it seems that there does not exist a channel update callback
         // => remove all listeners and add them again
-        getBridgeHandler().removePacketListener(this);
+        EnOceanBridgeHandler handler = getBridgeHandler();
+        if (handler != null) {
+            handler.removePacketListener(this);
+        }
 
         this.getThing().getChannels().forEach(c -> {
             if (isLinked(c.getUID()) && !addListener(c)) {
@@ -100,7 +106,7 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
     }
 
     @Override
-    public void channelUnlinked(@NonNull ChannelUID channelUID) {
+    public void channelUnlinked(ChannelUID channelUID) {
         super.channelUnlinked(channelUID);
 
         // if unlinked channel is listening channel => remove listener
@@ -108,7 +114,7 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
         removeListener(channel);
     }
 
-    protected boolean addListener(Channel channel) {
+    protected boolean addListener(@Nullable Channel channel) {
         if (channel == null) {
             return true;
         }
@@ -120,7 +126,11 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
             EnOceanChannelRockerSwitchListenerConfig config = channel.getConfiguration()
                     .as(EnOceanChannelRockerSwitchListenerConfig.class);
             try {
-                getBridgeHandler().addPacketListener(this, Long.parseLong(config.enoceanId, 16));
+                @Nullable
+                EnOceanBridgeHandler handler = getBridgeHandler();
+                if (handler != null) {
+                    handler.addPacketListener(this, Long.parseLong(config.enoceanId, 16));
+                }
                 return true;
             } catch (NumberFormatException e) {
             }
@@ -130,7 +140,7 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
         return true;
     }
 
-    protected void removeListener(Channel channel) {
+    protected void removeListener(@Nullable Channel channel) {
         if (channel == null) {
             return;
         }
@@ -142,7 +152,10 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
             EnOceanChannelRockerSwitchListenerConfig config = channel.getConfiguration()
                     .as(EnOceanChannelRockerSwitchListenerConfig.class);
             try {
-                getBridgeHandler().removePacketListener(this, Long.parseLong(config.enoceanId, 16));
+                EnOceanBridgeHandler handler = getBridgeHandler();
+                if (handler != null) {
+                    handler.removePacketListener(this, Long.parseLong(config.enoceanId, 16));
+                }
             } catch (NumberFormatException e) {
             }
         }
@@ -166,7 +179,7 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
                 : StringType.valueOf(CommonTriggerEvents.DIR2_RELEASED);
     }
 
-    private StringType convertToPressedCommand(Command command, SwitchMode switchMode) {
+    private @Nullable StringType convertToPressedCommand(Command command, SwitchMode switchMode) {
         if (command instanceof StringType) {
             return (StringType) command;
         } else if (command instanceof OnOffType) {
@@ -203,9 +216,9 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
     }
 
     @Override
-    public void handleCommand(@NonNull ChannelUID channelUID, @NonNull Command command) {
+    public void handleCommand(ChannelUID channelUID, Command command) {
         // We must have a valid sendingEEPType and sender id to send commands
-        if (sendingEEPType == null || senderId == null || command == RefreshType.REFRESH) {
+        if (sendingEEPType == null || senderId.length == 0 || command == RefreshType.REFRESH) {
             return;
         }
 
@@ -228,22 +241,34 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
 
         if (result != null) {
             lastTriggerEvent = result;
-
-            EEP eep = EEPFactory.createEEP(sendingEEPType);
-            if (eep.setSenderId(senderId).setDestinationId(destinationId).convertFromCommand(channelId, channelTypeId,
-                    result, id -> this.getCurrentState(id), channel.getConfiguration()).hasData()) {
-                BasePacket press = eep.setSuppressRepeating(getConfiguration().suppressRepeating).getERP1Message();
-
-                getBridgeHandler().sendMessage(press, null);
-
-                if (channelConfig.duration > 0) {
-                    releaseFuture = scheduler.schedule(() -> {
-                        if (eep.convertFromCommand(channelId, channelTypeId, convertToReleasedCommand(lastTriggerEvent),
-                                id -> this.getCurrentState(id), channel.getConfiguration()).hasData()) {
-                            BasePacket release = eep.getERP1Message();
-                            getBridgeHandler().sendMessage(release, null);
+            EEPType localSendType = sendingEEPType;
+            if (localSendType != null) {
+                EEP eep = EEPFactory.createEEP(localSendType);
+                if (eep.setSenderId(senderId).setDestinationId(destinationId).convertFromCommand(channelId,
+                        channelTypeId, result, id -> this.getCurrentState(id), channel.getConfiguration()).hasData()) {
+                    BasePacket press = eep.setSuppressRepeating(getConfiguration().suppressRepeating).getERP1Message();
+                    if (press != null) {
+                        EnOceanBridgeHandler handler = getBridgeHandler();
+                        if (handler != null) {
+                            handler.sendMessage(press, null);
                         }
-                    }, channelConfig.duration, TimeUnit.MILLISECONDS);
+                    }
+
+                    if (channelConfig.duration > 0) {
+                        releaseFuture = scheduler.schedule(() -> {
+                            if (eep.convertFromCommand(channelId, channelTypeId,
+                                    convertToReleasedCommand(lastTriggerEvent), id -> this.getCurrentState(id),
+                                    channel.getConfiguration()).hasData()) {
+                                BasePacket release = eep.getERP1Message();
+                                if (release != null) {
+                                    EnOceanBridgeHandler handler = getBridgeHandler();
+                                    if (handler != null) {
+                                        handler.sendMessage(release, null);
+                                    }
+                                }
+                            }
+                        }, channelConfig.duration, TimeUnit.MILLISECONDS);
+                    }
                 }
             }
         }
@@ -251,8 +276,10 @@ public class EnOceanClassicDeviceHandler extends EnOceanBaseActuatorHandler {
 
     @Override
     public void handleRemoval() {
-        if (releaseFuture != null && !releaseFuture.isDone()) {
-            releaseFuture.cancel(true);
+        ScheduledFuture<?> future = releaseFuture;
+        if (future != null && !future.isDone()) {
+            future.cancel(true);
+            future = null;
         }
 
         releaseFuture = null;
index 6b4053982d4117b349dbc76ac118c8345fa4848b..9eb9cef356874028dbeb50f383114f7cc25870f8 100644 (file)
@@ -15,10 +15,13 @@ package org.openhab.binding.enocean.internal.messages;
 import java.security.InvalidParameterException;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class BasePacket {
 
     public enum ESPPacketType {
@@ -65,7 +68,7 @@ public abstract class BasePacket {
 
     protected ESPPacketType packetType;
     protected byte[] data;
-    protected byte[] optionalData;
+    protected byte[] optionalData = new byte[0];
 
     public BasePacket(int dataLength, int optionalDataLength, ESPPacketType packetType, byte[] payload) {
         this(dataLength, optionalDataLength, packetType.value, payload);
index bdfa00af298ee900e7688a50c7ba36b0b36f9663..a03a9a4393ff1e99fb8900d30eac78e97bdd473f 100644 (file)
  */
 package org.openhab.binding.enocean.internal.messages;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 class CCMessage extends BasePacket {
 
     public enum CCMessageType {
index 1b236027cd59b333a33a385ed40cce6e26d55b63..4c398ee6eae74755bad9a9ffea422b455edb662e 100644 (file)
@@ -15,6 +15,7 @@ package org.openhab.binding.enocean.internal.messages;
 import java.security.InvalidParameterException;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.eep.Base.UTEResponse;
 import org.openhab.binding.enocean.internal.eep.Base._1BSMessage;
 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
@@ -23,6 +24,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class ERP1Message extends BasePacket {
 
     // these are just ESP3 RORGs, ESP2 ORGs are converted by ESP2PacketConverter
@@ -87,13 +89,13 @@ public class ERP1Message extends BasePacket {
                 case _1BS:
                     if (dataLength >= 6) {
                         senderId = Arrays.copyOfRange(payload, 2, 6);
-                        teachIn = ((_1BSMessage.TeachInBit & payload[1]) == 0);
+                        teachIn = ((_1BSMessage.TEACHIN_BIT & payload[1]) == 0);
                     }
                     break;
                 case _4BS:
                     if (dataLength >= 9) {
                         senderId = Arrays.copyOfRange(payload, 5, 9);
-                        teachIn = (_4BSMessage.TeachInBit & payload[4]) == 0;
+                        teachIn = (_4BSMessage.TEACHIN_BIT & payload[4]) == 0;
                     }
                     break;
                 case VLD:
@@ -102,8 +104,8 @@ public class ERP1Message extends BasePacket {
                     break;
                 case UTE:
                     if (dataLength >= 6) {
-                        teachIn = (payload[1] & UTEResponse.TeachIn_MASK) == 0
-                                || (payload[1] & UTEResponse.TeachIn_MASK) == UTEResponse.TeachIn_NotSpecified;
+                        teachIn = (payload[1] & UTEResponse.TEACHIN_MASK) == 0
+                                || (payload[1] & UTEResponse.TEACHIN_MASK) == UTEResponse.TEACHIN_NPTSPECIFIED;
                         senderId = Arrays.copyOfRange(payload, dataLength - 5, dataLength - 1);
                     }
                     break;
index ad8dedab8073d641479a6099369a588cc517fcf4..3f0e277b415b6b9ba4b480747d905ba1f5ec6946 100644 (file)
@@ -17,6 +17,7 @@ import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.ZERO;
 import java.security.InvalidParameterException;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.EnOceanException;
 import org.openhab.binding.enocean.internal.messages.BasePacket.ESPPacketType;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
@@ -25,6 +26,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class ESP2Packet {
 
     public static final byte ENOCEAN_ESP2_FIRSTSYNC_BYTE = (byte) 0xA5;
index 64a11def2aef7b3318659035110c8d6b23d12e5c..f74d0ddbd7d815995d2bb518223503a57daecbe8 100644 (file)
@@ -15,6 +15,8 @@ package org.openhab.binding.enocean.internal.messages;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.BasePacket.ESPPacketType;
 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
 import org.openhab.binding.enocean.internal.messages.ESP2Packet.ESP2PacketType;
@@ -27,6 +29,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class ESP2PacketConverter {
 
     protected static Logger logger = LoggerFactory.getLogger(ESP2PacketConverter.class);
@@ -34,19 +37,19 @@ public class ESP2PacketConverter {
     private static final int ESP3PACKET_BASE_LENGTH = ESP3Packet.ESP3_RORG_LENGTH + ESP3Packet.ESP3_SENDERID_LENGTH
             + ESP3Packet.ESP3_STATUS_LENGTH;
 
-    private static BasePacket handleRadioTelegram(int dataLength, byte packetType, byte[] payload) {
+    private static @Nullable BasePacket handleRadioTelegram(int dataLength, byte packetType, byte[] payload) {
         switch (ESP2Packet.ORG.getORG(payload[1])) {
             case _RPS:
-                return ESP3PacketFactory.BuildPacket(ESP3PACKET_BASE_LENGTH + RORG.RPS.getDataLength(), 0,
+                return ESP3PacketFactory.buildPacket(ESP3PACKET_BASE_LENGTH + RORG.RPS.getDataLength(), 0,
                         ESPPacketType.RADIO_ERP1.getValue(), new byte[] { RORG.RPS.getValue(), payload[2], payload[6],
                                 payload[7], payload[8], payload[9], payload[10] });
             case _1BS:
-                return ESP3PacketFactory.BuildPacket(ESP3PACKET_BASE_LENGTH + RORG._1BS.getDataLength(), 0,
+                return ESP3PacketFactory.buildPacket(ESP3PACKET_BASE_LENGTH + RORG._1BS.getDataLength(), 0,
                         ESPPacketType.RADIO_ERP1.getValue(), new byte[] { RORG._1BS.getValue(), payload[2], payload[6],
                                 payload[7], payload[8], payload[9], payload[10] });
 
             case _4BS:
-                return ESP3PacketFactory.BuildPacket(ESP3PACKET_BASE_LENGTH + RORG._4BS.getDataLength(), 0,
+                return ESP3PacketFactory.buildPacket(ESP3PACKET_BASE_LENGTH + RORG._4BS.getDataLength(), 0,
                         ESPPacketType.RADIO_ERP1.getValue(), new byte[] { RORG._4BS.getValue(), payload[2], payload[3],
                                 payload[4], payload[5], payload[6], payload[7], payload[8], payload[9], payload[10] });
             default:
@@ -55,13 +58,13 @@ public class ESP2PacketConverter {
         }
     }
 
-    private static BasePacket handleMessageTelegram(int dataLength, byte packetType, byte[] payload) {
+    private static @Nullable BasePacket handleMessageTelegram(int dataLength, byte packetType, byte[] payload) {
         switch (ESP2Packet.ESP2Response.getResponse(payload[1])) {
             case OK:
-                return ESP3PacketFactory.BuildPacket(1, 0, ESPPacketType.RESPONSE.getValue(),
+                return ESP3PacketFactory.buildPacket(1, 0, ESPPacketType.RESPONSE.getValue(),
                         new byte[] { ResponseType.RET_OK.getValue() });
             case ERR:
-                return ESP3PacketFactory.BuildPacket(1, 0, ESPPacketType.RESPONSE.getValue(),
+                return ESP3PacketFactory.buildPacket(1, 0, ESPPacketType.RESPONSE.getValue(),
                         new byte[] { ResponseType.RET_ERROR.getValue() });
             case INF_SW_VERSION: {
                 byte[] data = new byte[33];
@@ -71,7 +74,7 @@ public class ESP2PacketConverter {
 
                 byte[] description = "TCM 210".getBytes(Charset.forName("ASCII"));
                 System.arraycopy(description, 0, data, 17, description.length);
-                return ESP3PacketFactory.BuildPacket(data.length, 0, ESPPacketType.RESPONSE.getValue(), data);
+                return ESP3PacketFactory.buildPacket(data.length, 0, ESPPacketType.RESPONSE.getValue(), data);
             }
             case UNKOWN: // try to interpret it as a radio telegram
                 return handleRadioTelegram(dataLength, packetType, payload);
@@ -95,7 +98,7 @@ public class ESP2PacketConverter {
         }
     }
 
-    public static BasePacket BuildPacket(int dataLength, byte packetType, byte[] payload) {
+    public static @Nullable BasePacket buildPacket(int dataLength, byte packetType, byte[] payload) {
         ESP2PacketType type = ESP2PacketType.getPacketType(packetType);
 
         switch (type) {
index fe1e62ee14a6c124e666dfe420f6425e1ee388fb..b27a01f410919ecff225851f8e188acdd63035f7 100644 (file)
  */
 package org.openhab.binding.enocean.internal.messages;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.EnOceanException;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class ESP3Packet {
 
-    private static byte[] crc8_table = new byte[] { (byte) 0x00, (byte) 0x07, (byte) 0x0e, (byte) 0x09, (byte) 0x1c,
+    private static byte[] crc8Table = new byte[] { (byte) 0x00, (byte) 0x07, (byte) 0x0e, (byte) 0x09, (byte) 0x1c,
             (byte) 0x1b, (byte) 0x12, (byte) 0x15, (byte) 0x38, (byte) 0x3f, (byte) 0x36, (byte) 0x31, (byte) 0x24,
             (byte) 0x23, (byte) 0x2a, (byte) 0x2d, (byte) 0x70, (byte) 0x77, (byte) 0x7e, (byte) 0x79, (byte) 0x6c,
             (byte) 0x6b, (byte) 0x62, (byte) 0x65, (byte) 0x48, (byte) 0x4f, (byte) 0x46, (byte) 0x41, (byte) 0x54,
@@ -75,7 +77,7 @@ public class ESP3Packet {
         byte output = 0;
         for (int i = offset; i < offset + length; i++) {
             int index = (output ^ data[i]) & 0xff;
-            output = crc8_table[index];
+            output = crc8Table[index];
         }
         return (byte) (output & 0xff);
     }
@@ -85,26 +87,24 @@ public class ESP3Packet {
             byte[] payload = basePacket.getPayload();
             byte[] optionalPayload = basePacket.getOptionalPayload();
 
-            int optionalLength = optionalPayload != null ? optionalPayload.length : 0;
-
             byte[] result = new byte[ESP3_SYNC_BYTE_LENGTH + ESP3_HEADER_LENGTH + ESP3_CRC3_HEADER_LENGTH
-                    + payload.length + optionalLength + ESP3_CRC8_DATA_LENGTH];
+                    + payload.length + optionalPayload.length + ESP3_CRC8_DATA_LENGTH];
 
             result[0] = ESP3_SYNC_BYTE;
             result[1] = (byte) ((payload.length >> 8) & 0xff);
             result[2] = (byte) (payload.length & 0xff);
-            result[3] = (byte) (optionalLength & 0xff);
+            result[3] = (byte) (optionalPayload.length & 0xff);
             result[4] = basePacket.getPacketType().getValue();
             result[5] = calcCRC8(result, ESP3_SYNC_BYTE_LENGTH, ESP3_HEADER_LENGTH);
-            for (int i = 0; i < payload.length; i++) {
-                result[6 + i] = payload[i];
-            }
-            if (optionalPayload != null) {
-                for (int i = 0; i < optionalPayload.length; i++) {
-                    result[6 + payload.length + i] = (byte) (optionalPayload[i] & 0xff);
-                }
+
+            System.arraycopy(payload, 0, result, 6, payload.length);
+
+            for (int i = 0; i < optionalPayload.length; i++) {
+                result[6 + payload.length + i] = (byte) (optionalPayload[i] & 0xff);
             }
-            result[6 + payload.length + optionalLength] = calcCRC8(result, 6, payload.length + optionalLength);
+
+            result[6 + payload.length + optionalPayload.length] = calcCRC8(result, 6,
+                    payload.length + optionalPayload.length);
 
             return result;
         } catch (Exception e) {
@@ -116,7 +116,7 @@ public class ESP3Packet {
         byte output = 0;
         for (int i = 0; i < length; i++) {
             int index = (output ^ data[i]) & 0xff;
-            output = crc8_table[index];
+            output = crc8Table[index];
         }
         return output == crc8;
     }
index 4fbf31a64ef41f2d9c151171a96cfd28ad1fde78..64287b611397720f63e18a41b3309c979f2c4080 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.enocean.internal.messages;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.messages.BasePacket.ESPPacketType;
@@ -23,6 +25,7 @@ import org.openhab.core.library.types.StringType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class ESP3PacketFactory {
 
     public static final BasePacket CO_RD_VERSION = new CCMessage(CCMessageType.CO_RD_VERSION);
@@ -66,7 +69,8 @@ public class ESP3PacketFactory {
                 new byte[] { SAMessageType.SA_WR_CLIENTLEARNRQ.getValue(), manu1, manu2, rorg, func, type });
     }
 
-    public static BasePacket BuildPacket(int dataLength, int optionalDataLength, byte packetType, byte[] payload) {
+    public static @Nullable BasePacket buildPacket(int dataLength, int optionalDataLength, byte packetType,
+            byte[] payload) {
         ESPPacketType type = ESPPacketType.getPacketType(packetType);
 
         switch (type) {
index 7f5bb514eca0c435501a8bb3931853531404afa4..3027b2131d69899e20ef483787ca5251b362693d 100644 (file)
@@ -14,10 +14,13 @@ package org.openhab.binding.enocean.internal.messages;
 
 import java.util.stream.Stream;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EventMessage extends BasePacket {
 
     public enum EventMessageType {
index 649b071d6833a725425226cd7636a896f563f539..cc9e300935cef2d4e43214462a3ef14fe3437541 100644 (file)
@@ -14,10 +14,13 @@ package org.openhab.binding.enocean.internal.messages;
 
 import java.security.InvalidParameterException;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class Response extends BasePacket {
 
     public enum ResponseType {
@@ -55,7 +58,7 @@ public class Response extends BasePacket {
     }
 
     protected ResponseType responseType;
-    protected boolean _isValid = false;
+    protected boolean isValid = false;
 
     public Response(int dataLength, int optionalDataLength, byte[] payload) {
         super(dataLength, optionalDataLength, ESPPacketType.RESPONSE, payload);
@@ -76,6 +79,6 @@ public class Response extends BasePacket {
     }
 
     public boolean isValid() {
-        return _isValid;
+        return isValid;
     }
 }
index 3df820feb78de092959c492e97cc4493b06a7cbe..e1aa3642c12d75eba4a3d39b2f8e26d8c5dac1fc 100644 (file)
@@ -10,8 +10,9 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.messages.Response;
 
@@ -19,6 +20,7 @@ import org.openhab.binding.enocean.internal.messages.Response;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class BaseResponse extends Response {
 
     public BaseResponse(Response response) {
index 8b2c9543aab579d21b703d53f44bc12c64ac7530..c00672a89771d9b6a39e67134062177706b81429 100644 (file)
@@ -10,8 +10,9 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.messages.Response;
 
@@ -19,9 +20,10 @@ import org.openhab.binding.enocean.internal.messages.Response;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class RDBaseIdResponse extends Response {
 
-    private byte[] baseId = null;
+    private byte[] baseId = new byte[0];
     private int remainingWriteCycles = 0;
 
     public RDBaseIdResponse(Response response) {
@@ -32,14 +34,14 @@ public class RDBaseIdResponse extends Response {
     RDBaseIdResponse(int dataLength, int optionalDataLength, byte[] payload) {
         super(dataLength, optionalDataLength, payload);
 
-        if (this.data == null || this.data.length != 5 || this.optionalData == null || this.optionalData.length != 1) {
+        if (this.data.length != 5 || this.optionalData.length != 1) {
             return;
         }
 
         baseId = getPayload(1, 4);
         remainingWriteCycles = optionalData[0] & 0xFF;
 
-        _isValid = true;
+        isValid = true;
     }
 
     public final byte[] getBaseId() {
index 8c8671a65bc44db8b3a9c77204acd7a987173c71..6c114878e81e21804e709efc6d205f38f01ff20d 100644 (file)
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
 import java.util.Arrays;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.Helper;
 import org.openhab.binding.enocean.internal.messages.Response;
 
@@ -21,15 +22,16 @@ import org.openhab.binding.enocean.internal.messages.Response;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class RDLearnedClientsResponse extends Response {
 
     public class LearnedClient {
-        public byte[] clientId;
-        public byte[] controllerId;
+        public byte[] clientId = new byte[0];
+        public byte[] controllerId = new byte[0];
         public int mailboxIndex;
     }
 
-    LearnedClient[] learnedClients;
+    LearnedClient[] learnedClients = new LearnedClient[0];
 
     public RDLearnedClientsResponse(Response response) {
         this(response.getPayload().length, response.getOptionalPayload().length,
@@ -39,10 +41,10 @@ public class RDLearnedClientsResponse extends Response {
     RDLearnedClientsResponse(int dataLength, int optionalDataLength, byte[] payload) {
         super(dataLength, optionalDataLength, payload);
 
-        if (payload == null || ((payload.length - 1) % 9) != 0) {
+        if (payload.length == 0 || (payload.length - 1) % 9 != 0) {
             return;
         } else {
-            _isValid = true;
+            isValid = true;
         }
 
         learnedClients = new LearnedClient[(payload.length - 1) / 9];
index 953644f34480f398f09c4e9ee4e8b4f1177a95b4..d61ab7bfee64f5be99064c9ef77c17dd924d7b5a 100644 (file)
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.Response;
 import org.openhab.core.library.types.StringType;
 
@@ -22,9 +22,10 @@ import org.openhab.core.library.types.StringType;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class RDRepeaterResponse extends Response {
 
-    protected String repeaterLevel;
+    protected String repeaterLevel = "";
 
     public RDRepeaterResponse(Response response) {
         this(response.getPayload().length, 0, response.getPayload());
@@ -33,7 +34,7 @@ public class RDRepeaterResponse extends Response {
     RDRepeaterResponse(int dataLength, int optionalDataLength, byte[] payload) {
         super(dataLength, optionalDataLength, payload);
 
-        if (payload == null || payload.length < 3) {
+        if (payload.length < 3) {
             return;
         }
 
@@ -54,11 +55,10 @@ public class RDRepeaterResponse extends Response {
                     return;
             }
 
-            _isValid = true;
+            isValid = true;
         }
     }
 
-    @NonNull
     public StringType getRepeaterLevel() {
         return StringType.valueOf(repeaterLevel);
     }
index 2808093fe2383ea4dd4c10040118d5776da5b7e2..e041586aaf3fb9fdd6cb35b343c9b4df5da5ccef 100644 (file)
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
 import java.util.Arrays;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.Response;
 import org.openhab.core.util.HexUtils;
 
@@ -22,6 +22,7 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class RDVersionResponse extends Response {
 
     protected String appVersion = "";
@@ -53,29 +54,25 @@ public class RDVersionResponse extends Response {
                 sb.append((char) (payload[i] & 0xff));
             }
             description = sb.toString();
-            _isValid = true;
+            isValid = true;
 
         } catch (Exception e) {
             responseType = ResponseType.RET_ERROR;
         }
     }
 
-    @NonNull
     public String getAPPVersion() {
         return appVersion;
     }
 
-    @NonNull
     public String getAPIVersion() {
         return apiVersion;
     }
 
-    @NonNull
     public String getChipID() {
         return chipId;
     }
 
-    @NonNull
     public String getDescription() {
         return description;
     }
index d265b7b439198f8e053300c09a996a6cded14c0f..b09dc582899d21fb616c6aea820824e8df627b76 100644 (file)
  *
  * SPDX-License-Identifier: EPL-2.0
  */
-package org.openhab.binding.enocean.internal.messages.Responses;
+package org.openhab.binding.enocean.internal.messages.responses;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.Response;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class SMACKTeachInResponse extends Response {
 
     // set response time to 250ms
index a1ebce44a219fb2aa3052f9cf22ca2bd96b1af1d..9aee034f274daf8a1793786e7a0b5b37de559937 100644 (file)
  */
 package org.openhab.binding.enocean.internal.messages;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class SAMessage extends BasePacket {
 
     public enum SAMessageType {
index f1de2cde08eed67456d84976c21ebe2f1feaff43..76da602ed75b009aff397d176ab3734472f4d193 100644 (file)
@@ -78,7 +78,6 @@ public class EnOceanProfileFactory implements ProfileFactory, ProfileAdvisor, Pr
 
     @Override
     public @Nullable ProfileTypeUID getSuggestedProfileTypeUID(ChannelType channelType, @Nullable String itemType) {
-
         if (CHANNELTYPE_ROCKERSWITCH_ACTION_UID.equals(channelType.getUID())) {
             if (CoreItemFactory.PLAYER.equalsIgnoreCase(itemType)) {
                 return ROCKERSWITCHACTION_TOGGLE_PLAYER;
index 8584d50956c98aa07d91e7a83653ac628f0cb3dd..69b942b668f069b4555d249a71bb8ef56283f842 100644 (file)
@@ -31,7 +31,7 @@ public abstract class RockerSwitchActionBaseProfile implements TriggerProfile {
 
     protected @Nullable State previousState;
 
-    final String ANYDIR = "*";
+    protected static final String ANY_DIR = "*";
 
     public RockerSwitchActionBaseProfile(ProfileCallback callback, ProfileContext context) {
         this.callback = callback;
@@ -46,9 +46,9 @@ public abstract class RockerSwitchActionBaseProfile implements TriggerProfile {
 
         EnOceanProfileRockerSwitchActionConfig config = context.getConfiguration()
                 .as(EnOceanProfileRockerSwitchActionConfig.class);
-        if (!(config.channelAFilter.equals(ANYDIR) || config.channelAFilter.equals(directions[0]))) {
+        if (!(config.channelAFilter.equals(ANY_DIR) || config.channelAFilter.equals(directions[0]))) {
             return false;
-        } else if (!(config.channelBFilter.equals(ANYDIR) || config.channelBFilter.equals(directions[1]))) {
+        } else if (!(config.channelBFilter.equals(ANY_DIR) || config.channelBFilter.equals(directions[1]))) {
             return false;
         }
 
index 179d7aa2937b0918de0959e691a6d005f03cb14e..d7e9681f7982a77d7660cc8ecd913a212ae5188e 100644 (file)
 package org.openhab.binding.enocean.internal.transceiver;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Arrays;
+import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanException;
 import org.openhab.binding.enocean.internal.messages.BasePacket;
 import org.openhab.binding.enocean.internal.messages.ERP1Message;
@@ -30,10 +34,11 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanESP2Transceiver extends EnOceanTransceiver {
 
     public EnOceanESP2Transceiver(String path, TransceiverErrorListener errorListener,
-            ScheduledExecutorService scheduler, SerialPortManager serialPortManager) {
+            ScheduledExecutorService scheduler, @Nullable SerialPortManager serialPortManager) {
         super(path, errorListener, scheduler, serialPortManager);
     }
 
@@ -54,33 +59,37 @@ public class EnOceanESP2Transceiver extends EnOceanTransceiver {
     protected void processMessage(byte firstByte) {
         byte[] readingBuffer = new byte[ENOCEAN_MAX_DATA];
         int bytesRead = -1;
-        byte _byte;
+        byte byteBuffer;
 
         try {
             readingBuffer[0] = firstByte;
-
-            bytesRead = this.inputStream.read(readingBuffer, 1, inputStream.available());
+            InputStream localInputStream = inputStream;
+            if (localInputStream == null) {
+                throw new IOException("could not read from inputstream, it was null");
+            }
+            bytesRead = localInputStream.read(readingBuffer, 1, localInputStream.available());
             if (bytesRead == -1) {
                 throw new IOException("could not read from inputstream");
             }
 
-            if (readingTask == null || readingTask.isCancelled()) {
+            Future<?> localReadingTask = readingTask;
+            if (localReadingTask == null || localReadingTask.isCancelled()) {
                 return;
             }
 
             bytesRead++;
             for (int p = 0; p < bytesRead; p++) {
-                _byte = readingBuffer[p];
+                byteBuffer = readingBuffer[p];
 
                 switch (state) {
                     case WaitingForFirstSyncByte:
-                        if (_byte == ESP2Packet.ENOCEAN_ESP2_FIRSTSYNC_BYTE) {
+                        if (byteBuffer == ESP2Packet.ENOCEAN_ESP2_FIRSTSYNC_BYTE) {
                             state = ReadingState.WaitingForSecondSyncByte;
                             logger.trace("Received First Sync Byte");
                         }
                         break;
                     case WaitingForSecondSyncByte:
-                        if (_byte == ESP2Packet.ENOCEAN_ESP2_SECONDSYNC_BYTE) {
+                        if (byteBuffer == ESP2Packet.ENOCEAN_ESP2_SECONDSYNC_BYTE) {
                             state = ReadingState.ReadingHeader;
                             logger.trace("Received Second Sync Byte");
                         }
@@ -89,7 +98,7 @@ public class EnOceanESP2Transceiver extends EnOceanTransceiver {
                         state = ReadingState.ReadingData;
 
                         currentPosition = 0;
-                        dataBuffer[currentPosition++] = _byte;
+                        dataBuffer[currentPosition++] = byteBuffer;
                         dataLength = ((dataBuffer[0] & 0xFF) & 0b11111);
                         packetType = (byte) ((dataBuffer[0] & 0xFF) >> 5);
 
@@ -98,8 +107,8 @@ public class EnOceanESP2Transceiver extends EnOceanTransceiver {
                         break;
                     case ReadingData:
                         if (currentPosition == dataLength) {
-                            if (ESP2Packet.validateCheckSum(dataBuffer, dataLength, _byte)) {
-                                BasePacket packet = ESP2PacketConverter.BuildPacket(dataLength, packetType, dataBuffer);
+                            if (ESP2Packet.validateCheckSum(dataBuffer, dataLength, byteBuffer)) {
+                                BasePacket packet = ESP2PacketConverter.buildPacket(dataLength, packetType, dataBuffer);
                                 if (packet != null) {
                                     switch (packet.getPacketType()) {
                                         case RADIO_ERP1: {
@@ -128,30 +137,33 @@ public class EnOceanESP2Transceiver extends EnOceanTransceiver {
                                     }
                                 } else {
                                     if (dataBuffer[1] != (byte) 0xFC) {
-                                        logger.debug("Unknown/unsupported ESP2Packet: {}",
-                                                HexUtils.bytesToHex(Arrays.copyOf(dataBuffer, dataLength)));
+                                        byte[] array = Arrays.copyOf(dataBuffer, dataLength);
+                                        String packetString = array != null ? HexUtils.bytesToHex(array) : "";
+                                        logger.debug("Unknown/unsupported ESP2Packet: {}", packetString);
                                     }
                                 }
                             } else {
                                 logger.debug("ESP2Packet malformed: {}", HexUtils.bytesToHex(dataBuffer));
                             }
 
-                            state = _byte == ESP2Packet.ENOCEAN_ESP2_FIRSTSYNC_BYTE
+                            state = byteBuffer == ESP2Packet.ENOCEAN_ESP2_FIRSTSYNC_BYTE
                                     ? ReadingState.WaitingForSecondSyncByte
                                     : ReadingState.WaitingForFirstSyncByte;
 
                             currentPosition = 0;
                             dataLength = packetType = -1;
                         } else {
-                            dataBuffer[currentPosition++] = _byte;
+                            dataBuffer[currentPosition++] = byteBuffer;
                         }
                         break;
                 }
             }
-        } catch (
-
-        IOException ioexception) {
-            errorListener.ErrorOccured(ioexception);
+        } catch (IOException ioexception) {
+            logger.trace("Unable to process message", ioexception);
+            TransceiverErrorListener localListener = errorListener;
+            if (localListener != null) {
+                localListener.errorOccured(ioexception);
+            }
             return;
         }
     }
index a8713e7ec56284a76424966f442f08610121786b..e9e350976c373f3284b13f05b98286bae6129dd4 100644 (file)
 package org.openhab.binding.enocean.internal.transceiver;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Arrays;
+import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanException;
 import org.openhab.binding.enocean.internal.messages.BasePacket;
 import org.openhab.binding.enocean.internal.messages.ESP3Packet;
@@ -28,10 +32,11 @@ import org.openhab.core.util.HexUtils;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public class EnOceanESP3Transceiver extends EnOceanTransceiver {
 
     public EnOceanESP3Transceiver(String path, TransceiverErrorListener errorListener,
-            ScheduledExecutorService scheduler, SerialPortManager serialPortManager) {
+            ScheduledExecutorService scheduler, @Nullable SerialPortManager serialPortManager) {
         super(path, errorListener, scheduler, serialPortManager);
     }
 
@@ -52,34 +57,38 @@ public class EnOceanESP3Transceiver extends EnOceanTransceiver {
     protected void processMessage(byte firstByte) {
         byte[] readingBuffer = new byte[ENOCEAN_MAX_DATA];
         int bytesRead = -1;
-        byte _byte;
+        byte byteBuffer;
 
         try {
             readingBuffer[0] = firstByte;
-
-            bytesRead = this.inputStream.read(readingBuffer, 1, inputStream.available());
+            InputStream localInPutStream = this.inputStream;
+            if (localInPutStream == null) {
+                throw new IOException("could not read from inputstream");
+            }
+            bytesRead = localInPutStream.read(readingBuffer, 1, localInPutStream.available());
             if (bytesRead == -1) {
                 throw new IOException("could not read from inputstream");
             }
 
-            if (readingTask == null || readingTask.isCancelled()) {
+            Future<?> localReadingTask = readingTask;
+            if (localReadingTask == null || localReadingTask.isCancelled()) {
                 return;
             }
 
             bytesRead++;
             for (int p = 0; p < bytesRead; p++) {
-                _byte = readingBuffer[p];
+                byteBuffer = readingBuffer[p];
 
                 switch (state) {
                     case WaitingForSyncByte:
-                        if (_byte == ESP3Packet.ESP3_SYNC_BYTE) {
+                        if (byteBuffer == ESP3Packet.ESP3_SYNC_BYTE) {
                             state = ReadingState.ReadingHeader;
                             logger.trace("Received Sync Byte");
                         }
                         break;
                     case ReadingHeader:
                         if (currentPosition == ESP3Packet.ESP3_HEADER_LENGTH) {
-                            if (ESP3Packet.checkCRC8(dataBuffer, ESP3Packet.ESP3_HEADER_LENGTH, _byte)
+                            if (ESP3Packet.checkCRC8(dataBuffer, ESP3Packet.ESP3_HEADER_LENGTH, byteBuffer)
                                     && ((dataBuffer[0] & 0xFF) << 8) + (dataBuffer[1] & 0xFF)
                                             + (dataBuffer[2] & 0xFF) > 0) {
                                 state = ReadingState.ReadingData;
@@ -110,23 +119,23 @@ public class EnOceanESP3Transceiver extends EnOceanTransceiver {
                                             ESP3Packet.ESP3_HEADER_LENGTH - copyFrom);
                                     state = ReadingState.ReadingHeader;
                                     currentPosition = ESP3Packet.ESP3_HEADER_LENGTH - copyFrom;
-                                    dataBuffer[currentPosition++] = _byte;
+                                    dataBuffer[currentPosition++] = byteBuffer;
                                 } else {
                                     currentPosition = 0;
-                                    state = _byte == ESP3Packet.ESP3_SYNC_BYTE ? ReadingState.ReadingHeader
+                                    state = byteBuffer == ESP3Packet.ESP3_SYNC_BYTE ? ReadingState.ReadingHeader
                                             : ReadingState.WaitingForSyncByte;
                                 }
                                 logger.trace("CrC8 header check not successful");
                             }
                         } else {
-                            dataBuffer[currentPosition++] = _byte;
+                            dataBuffer[currentPosition++] = byteBuffer;
                         }
                         break;
                     case ReadingData:
                         if (currentPosition == dataLength + optionalLength) {
-                            if (ESP3Packet.checkCRC8(dataBuffer, dataLength + optionalLength, _byte)) {
+                            if (ESP3Packet.checkCRC8(dataBuffer, dataLength + optionalLength, byteBuffer)) {
                                 state = ReadingState.WaitingForSyncByte;
-                                BasePacket packet = ESP3PacketFactory.BuildPacket(dataLength, optionalLength,
+                                BasePacket packet = ESP3PacketFactory.buildPacket(dataLength, optionalLength,
                                         packetType, dataBuffer);
 
                                 if (packet != null) {
@@ -166,7 +175,7 @@ public class EnOceanESP3Transceiver extends EnOceanTransceiver {
                                             .bytesToHex(Arrays.copyOf(dataBuffer, dataLength + optionalLength)));
                                 }
                             } else {
-                                state = _byte == ESP3Packet.ESP3_SYNC_BYTE ? ReadingState.ReadingHeader
+                                state = byteBuffer == ESP3Packet.ESP3_SYNC_BYTE ? ReadingState.ReadingHeader
                                         : ReadingState.WaitingForSyncByte;
                                 logger.trace("ESP3Packet malformed: {}",
                                         HexUtils.bytesToHex(Arrays.copyOf(dataBuffer, dataLength + optionalLength)));
@@ -175,13 +184,17 @@ public class EnOceanESP3Transceiver extends EnOceanTransceiver {
                             currentPosition = 0;
                             dataLength = optionalLength = packetType = -1;
                         } else {
-                            dataBuffer[currentPosition++] = _byte;
+                            dataBuffer[currentPosition++] = byteBuffer;
                         }
                         break;
                 }
             }
         } catch (IOException ioexception) {
-            errorListener.ErrorOccured(ioexception);
+            logger.trace("Unable to process message", ioexception);
+            TransceiverErrorListener localListener = errorListener;
+            if (localListener != null) {
+                localListener.errorOccured(ioexception);
+            }
             return;
         }
     }
index 6fac447240d0359a3e362a4237552d1c7fdc51ba..298d1b1f06122baf295f4ac693f45fdd195f7641 100644 (file)
@@ -25,6 +25,8 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
 import org.openhab.binding.enocean.internal.EnOceanException;
 import org.openhab.binding.enocean.internal.Helper;
@@ -50,26 +52,29 @@ import org.slf4j.LoggerFactory;
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public abstract class EnOceanTransceiver implements SerialPortEventListener {
 
     public static final int ENOCEAN_MAX_DATA = 65790;
 
     // Thread management
-    protected Future<?> readingTask = null;
-    private Future<?> timeOut = null;
+    protected @Nullable Future<?> readingTask = null;
+    private @Nullable Future<?> timeOut = null;
 
     protected Logger logger = LoggerFactory.getLogger(EnOceanTransceiver.class);
 
-    private SerialPortManager serialPortManager;
+    private @Nullable SerialPortManager serialPortManager;
     private static final int ENOCEAN_DEFAULT_BAUD = 57600;
     protected String path;
-    SerialPort serialPort;
+    private @Nullable SerialPort serialPort;
 
     class Request {
-        BasePacket RequestPacket;
-
-        Response ResponsePacket;
-        ResponseListener<? extends Response> ResponseListener;
+        @Nullable
+        BasePacket requestPacket;
+        @Nullable
+        Response responsePacket;
+        @Nullable
+        ResponseListener<? extends @Nullable Response> responseListener;
     }
 
     private class RequestQueue {
@@ -101,32 +106,41 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
             if (!queue.isEmpty()) {
                 currentRequest = queue.peek();
                 try {
-                    if (currentRequest != null && currentRequest.RequestPacket != null) {
-                        synchronized (currentRequest) {
-                            logger.debug("Sending data, type {}, payload {}{}",
-                                    currentRequest.RequestPacket.getPacketType().name(),
-                                    HexUtils.bytesToHex(currentRequest.RequestPacket.getPayload()),
-                                    HexUtils.bytesToHex(currentRequest.RequestPacket.getOptionalPayload()));
-
-                            byte[] b = serializePacket(currentRequest.RequestPacket);
-                            logger.trace("Sending raw data: {}", HexUtils.bytesToHex(b));
-                            outputStream.write(b);
-                            outputStream.flush();
-
-                            if (timeOut != null) {
-                                timeOut.cancel(true);
-                            }
-
-                            // slowdown sending of message to avoid hickups at receivers
-                            // Todo tweak sending intervall (250 ist just a first try)
-                            timeOut = scheduler.schedule(() -> {
-                                try {
-                                    sendNext();
-                                } catch (IOException e) {
-                                    errorListener.ErrorOccured(e);
-                                    return;
+                    Request localCurrentRequest = currentRequest;
+                    if (localCurrentRequest != null && localCurrentRequest.requestPacket != null) {
+                        synchronized (localCurrentRequest) {
+                            BasePacket rqPacket = localCurrentRequest.requestPacket;
+                            if (currentRequest != null && rqPacket != null) {
+                                logger.debug("Sending data, type {}, payload {}{}", rqPacket.getPacketType().name(),
+                                        HexUtils.bytesToHex(rqPacket.getPayload()),
+                                        HexUtils.bytesToHex(rqPacket.getOptionalPayload()));
+                                byte[] b = serializePacket(rqPacket);
+                                logger.trace("Sending raw data: {}", HexUtils.bytesToHex(b));
+                                OutputStream localOutPutStream = outputStream;
+                                if (localOutPutStream != null) {
+                                    localOutPutStream.write(b);
+                                    localOutPutStream.flush();
+                                }
+                                Future<?> localTimeOut = timeOut;
+                                if (localTimeOut != null) {
+                                    localTimeOut.cancel(true);
                                 }
-                            }, 250, TimeUnit.MILLISECONDS);
+
+                                // slowdown sending of message to avoid hickups at receivers
+                                // Todo tweak sending intervall (250 ist just a first try)
+                                timeOut = scheduler.schedule(() -> {
+                                    try {
+                                        sendNext();
+                                    } catch (IOException e) {
+                                        logger.trace("Unable to process message", e);
+                                        TransceiverErrorListener localListener = errorListener;
+                                        if (localListener != null) {
+                                            localListener.errorOccured(e);
+                                        }
+                                        return;
+                                    }
+                                }, 250, TimeUnit.MILLISECONDS);
+                            }
                         }
                     } else {
                         sendNext();
@@ -139,20 +153,22 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
     }
 
     RequestQueue requestQueue;
+    @Nullable
     Request currentRequest = null;
 
     protected Map<Long, HashSet<PacketListener>> listeners;
     protected HashSet<EventListener> eventListeners;
-    protected TeachInListener teachInListener;
+    protected @Nullable TeachInListener teachInListener;
 
-    protected InputStream inputStream;
-    protected OutputStream outputStream;
+    protected @Nullable InputStream inputStream;
+    protected @Nullable OutputStream outputStream;
 
-    private byte[] filteredDeviceId;
+    private byte[] filteredDeviceId = new byte[0];
+    @Nullable
     TransceiverErrorListener errorListener;
 
     public EnOceanTransceiver(String path, TransceiverErrorListener errorListener, ScheduledExecutorService scheduler,
-            SerialPortManager serialPortManager) {
+            @Nullable SerialPortManager serialPortManager) {
         requestQueue = new RequestQueue(scheduler);
 
         listeners = new HashMap<>();
@@ -164,34 +180,51 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
         this.path = path;
     }
 
-    public void Initialize()
+    public void initilize()
             throws UnsupportedCommOperationException, PortInUseException, IOException, TooManyListenersException {
-        SerialPortIdentifier id = serialPortManager.getIdentifier(path);
+        SerialPortManager localSerialPortManager = serialPortManager;
+        if (localSerialPortManager == null) {
+            throw new IOException("Could access the SerialPortManager, it was null");
+        }
+        SerialPortIdentifier id = localSerialPortManager.getIdentifier(path);
         if (id == null) {
             throw new IOException("Could not find a gateway on given path '" + path + "', "
-                    + serialPortManager.getIdentifiers().count() + " ports available.");
+                    + localSerialPortManager.getIdentifiers().count() + " ports available.");
         }
 
-        serialPort = id.open(EnOceanBindingConstants.BINDING_ID, 1000);
-        serialPort.setSerialPortParams(ENOCEAN_DEFAULT_BAUD, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
+        try {
+            serialPort = id.open(EnOceanBindingConstants.BINDING_ID, 1000);
+        } catch (PortInUseException e) {
+            logger.warn("EnOceanSerialTransceiver not initialized, port allready in use", e);
+            return;
+        }
+        SerialPort localSerialPort = serialPort;
+        if (localSerialPort == null) {
+            logger.debug("EnOceanSerialTransceiver not initialized, serialPort was null");
+            return;
+        }
+        localSerialPort.setSerialPortParams(ENOCEAN_DEFAULT_BAUD, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
                 SerialPort.PARITY_NONE);
 
         try {
-            serialPort.enableReceiveThreshold(1);
-            serialPort.enableReceiveTimeout(100); // In ms. Small values mean faster shutdown but more cpu usage.
+            localSerialPort.enableReceiveThreshold(1);
+            localSerialPort.enableReceiveTimeout(100); // In ms. Small values mean faster shutdown but more cpu usage.
         } catch (UnsupportedCommOperationException e) {
             // rfc connections do not allow a ReceiveThreshold
+            logger.debug("EnOceanSerialTransceiver encountered an UnsupportedCommOperationException while initilizing",
+                    e);
         }
 
-        inputStream = serialPort.getInputStream();
-        outputStream = serialPort.getOutputStream();
-
+        inputStream = localSerialPort.getInputStream();
+        outputStream = localSerialPort.getOutputStream();
         logger.info("EnOceanSerialTransceiver initialized");
     }
 
-    public void StartReceiving(ScheduledExecutorService scheduler) {
-        if (readingTask == null || readingTask.isCancelled()) {
-            readingTask = scheduler.submit(new Runnable() {
+    public void startReceiving(ScheduledExecutorService scheduler) {
+        @Nullable
+        Future<?> localReadingTask = readingTask;
+        if (localReadingTask == null || localReadingTask.isCancelled()) {
+            localReadingTask = scheduler.submit(new Runnable() {
                 @Override
                 public void run() {
                     receivePackets();
@@ -201,19 +234,26 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
         logger.info("EnOceanSerialTransceiver RX thread started");
     }
 
-    public void ShutDown() {
+    public void shutDown() {
         logger.debug("shutting down transceiver");
         logger.debug("Interrupt rx Thread");
 
-        if (timeOut != null) {
-            timeOut.cancel(true);
+        Future<?> localTimeOut = timeOut;
+        if (localTimeOut != null) {
+            localTimeOut.cancel(true);
         }
 
-        if (readingTask != null) {
-            readingTask.cancel(true);
-            try {
-                inputStream.close();
-            } catch (Exception e) {
+        Future<?> localReadingTask = readingTask;
+        if (localReadingTask != null) {
+            localReadingTask.cancel(true);
+
+            InputStream localInputStream = inputStream;
+            if (localInputStream != null) {
+                try {
+                    localInputStream.close();
+                } catch (IOException e) {
+                    logger.debug("IOException occured while closing the stream", e);
+                }
             }
         }
 
@@ -224,26 +264,28 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
         teachInListener = null;
         errorListener = null;
 
-        if (outputStream != null) {
-            logger.debug("Closing serial output stream");
+        OutputStream localOutputStream = outputStream;
+        if (localOutputStream != null) {
             try {
-                outputStream.close();
+                localOutputStream.close();
             } catch (IOException e) {
-                logger.debug("Error while closing the output stream: {}", e.getMessage());
+                logger.debug("IOException occured while closing the output stream", e);
             }
         }
-        if (inputStream != null) {
-            logger.debug("Closeing serial input stream");
+
+        InputStream localInputStream = inputStream;
+        if (localInputStream != null) {
             try {
-                inputStream.close();
+                localInputStream.close();
             } catch (IOException e) {
-                logger.debug("Error while closing the input stream: {}", e.getMessage());
+                logger.debug("IOException occured while closing the input stream", e);
             }
         }
 
-        if (serialPort != null) {
-            logger.debug("Closing serial port");
-            serialPort.close();
+        SerialPort localSerialPort = serialPort;
+        if (localSerialPort != null) {
+            logger.debug("Closing the serial port");
+            localSerialPort.close();
         }
 
         serialPort = null;
@@ -256,7 +298,8 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
     private void receivePackets() {
         byte[] buffer = new byte[1];
 
-        while (readingTask != null && !readingTask.isCancelled()) {
+        Future<?> localReadingTask = readingTask;
+        while (localReadingTask != null && !localReadingTask.isCancelled()) {
             int bytesRead = read(buffer, 1);
             if (bytesRead > 0) {
                 processMessage(buffer[0]);
@@ -267,11 +310,16 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
     protected abstract void processMessage(byte firstByte);
 
     protected int read(byte[] buffer, int length) {
-        try {
-            return this.inputStream.read(buffer, 0, length);
-        } catch (IOException e) {
-            return 0;
+        InputStream localInputStream = inputStream;
+        if (localInputStream != null) {
+            try {
+                localInputStream.read(buffer, 0, length);
+            } catch (IOException e) {
+                logger.debug("IOException occured while reading the input stream", e);
+                return 0;
+            }
         }
+        return 0;
     }
 
     protected void informListeners(BasePacket packet) {
@@ -285,8 +333,8 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
                         msg.getRORG().name(), HexUtils.bytesToHex(msg.getSenderId()), HexUtils.bytesToHex(d));
 
                 if (msg.getRORG() != RORG.Unknown) {
-                    if (senderId != null) {
-                        if (filteredDeviceId != null && senderId[0] == filteredDeviceId[0]
+                    if (senderId.length > 0) {
+                        if (senderId.length > 2 && filteredDeviceId.length > 2 && senderId[0] == filteredDeviceId[0]
                                 && senderId[1] == filteredDeviceId[1] && senderId[2] == filteredDeviceId[2]) {
                             // filter away own messages which are received through a repeater
                             return;
@@ -294,7 +342,11 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
 
                         if (teachInListener != null && (msg.getIsTeachIn() || msg.getRORG() == RORG.RPS)) {
                             logger.info("Received teach in message from {}", HexUtils.bytesToHex(msg.getSenderId()));
-                            teachInListener.packetReceived(msg);
+
+                            TeachInListener localListener = teachInListener;
+                            if (localListener != null) {
+                                localListener.packetReceived(msg);
+                            }
                             return;
                         } else if (teachInListener == null && msg.getIsTeachIn()) {
                             logger.info("Discard message because this is a teach-in telegram from {}!",
@@ -325,7 +377,10 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
 
                     if (teachInListener != null) {
                         logger.info("Received smart teach in from {}", HexUtils.bytesToHex(senderId));
-                        teachInListener.eventReceived(event);
+                        TeachInListener localListener = teachInListener;
+                        if (localListener != null) {
+                            localListener.eventReceived(event);
+                        }
                         return;
                     } else {
                         logger.info("Discard message because this is a smart teach-in telegram from {}!",
@@ -344,11 +399,13 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
     }
 
     protected void handleResponse(Response response) throws IOException {
-        if (currentRequest != null) {
-            if (currentRequest.ResponseListener != null) {
-                currentRequest.ResponsePacket = response;
+        Request localCurrentRequest = currentRequest;
+        if (localCurrentRequest != null) {
+            ResponseListener<? extends @Nullable Response> listener = localCurrentRequest.responseListener;
+            if (listener != null) {
+                localCurrentRequest.responsePacket = response;
                 try {
-                    currentRequest.ResponseListener.handleResponse(response);
+                    listener.handleResponse(response);
                 } catch (Exception e) {
                     logger.debug("Exception during response handling");
                 } finally {
@@ -362,8 +419,8 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
         }
     }
 
-    public void sendBasePacket(BasePacket packet, ResponseListener<? extends Response> responseCallback)
-            throws IOException {
+    public void sendBasePacket(@Nullable BasePacket packet,
+            @Nullable ResponseListener<? extends @Nullable Response> responseCallback) throws IOException {
         if (packet == null) {
             return;
         }
@@ -371,8 +428,8 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
         logger.debug("Enqueue new send request with ESP3 type {} {} callback", packet.getPacketType().name(),
                 responseCallback == null ? "without" : "with");
         Request r = new Request();
-        r.RequestPacket = packet;
-        r.ResponseListener = responseCallback;
+        r.requestPacket = packet;
+        r.responseListener = responseCallback;
 
         requestQueue.enqueRequest(r);
     }
@@ -412,9 +469,7 @@ public abstract class EnOceanTransceiver implements SerialPortEventListener {
     }
 
     public void setFilteredDeviceId(byte[] filteredDeviceId) {
-        if (filteredDeviceId != null) {
-            System.arraycopy(filteredDeviceId, 0, filteredDeviceId, 0, filteredDeviceId.length);
-        }
+        System.arraycopy(filteredDeviceId, 0, filteredDeviceId, 0, filteredDeviceId.length);
     }
 
     @Override
index 99fbb4cf2a4c33ac5f39c6de7511d525ea00312e..213b9d5124634a4cd445af37329d841e3f5a65f7 100644 (file)
  */
 package org.openhab.binding.enocean.internal.transceiver;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.EventMessage;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public interface EventListener {
     public void eventReceived(EventMessage event);
 }
index 32783ff1b3ee5e6b69467ab2610e4e40116cc2fc..94caf5c9cd4d0b9712886ce8c27e5314114f55d4 100644 (file)
  */
 package org.openhab.binding.enocean.internal.transceiver;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.enocean.internal.messages.BasePacket;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public interface PacketListener {
 
     public void packetReceived(BasePacket packet);
index 1cf7ec73bd33faa6de59ed9ac30086c6baa9f0cf..9ff933aacca06ad9615327cd2029d9f1d1ea5187 100644 (file)
@@ -14,6 +14,8 @@ package org.openhab.binding.enocean.internal.transceiver;
 
 import java.lang.reflect.ParameterizedType;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.EnOceanException;
 import org.openhab.binding.enocean.internal.messages.Response;
 
@@ -21,11 +23,12 @@ import org.openhab.binding.enocean.internal.messages.Response;
  *
  * @author Daniel Weber - Initial contribution
  */
-public abstract class ResponseListener<T extends Response> {
+@NonNullByDefault
+public abstract class ResponseListener<T extends @Nullable Response> {
 
     protected Class<T> persistentClass;
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     public ResponseListener() {
         this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
                 .getActualTypeArguments()[0];
index c74c3611d1acd0e23f683268a4da405303a08d85..314efc7a0cb56bdd27bfb7a6623187d6d024fb96 100644 (file)
@@ -14,15 +14,18 @@ package org.openhab.binding.enocean.internal.transceiver;
 
 import java.lang.reflect.ParameterizedType;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.enocean.internal.messages.Response;
 
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
-public abstract class ResponseListenerIgnoringTimeouts<T extends Response> extends ResponseListener<T> {
+@NonNullByDefault
+public abstract class ResponseListenerIgnoringTimeouts<T extends @Nullable Response> extends ResponseListener<T> {
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     public ResponseListenerIgnoringTimeouts() {
         this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
                 .getActualTypeArguments()[0];
index 972995fbdc61ef74e19dab8305b2491bbd793eca..e87cec7f6a3648abecea426fdee35e322311ff7f 100644 (file)
  */
 package org.openhab.binding.enocean.internal.transceiver;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public interface TeachInListener extends PacketListener, EventListener {
 
 }
index b2191d2ce0e12e06561592c2d181f7adf02aee5e..99b6f452b917db36d35c9f5b64819135d60e7cbe 100644 (file)
  */
 package org.openhab.binding.enocean.internal.transceiver;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  *
  * @author Daniel Weber - Initial contribution
  */
+@NonNullByDefault
 public interface TransceiverErrorListener {
 
-    public void ErrorOccured(Throwable exception);
+    public void errorOccured(Throwable exception);
 }