]> git.basschouten.com Git - openhab-addons.git/commitdiff
[knx] Reduce compiler warnings (#12518)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Sun, 27 Mar 2022 09:27:39 +0000 (11:27 +0200)
committerGitHub <noreply@github.com>
Sun, 27 Mar 2022 09:27:39 +0000 (11:27 +0200)
added NonNullByDefault annotations
rename functions and local variables not matching the naming scheme

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
19 files changed:
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/KNXBindingConstants.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/KNXTypeMapper.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/channel/AbstractSpec.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/channel/ListenSpecImpl.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/AbstractKNXClient.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/CustomKNXNetworkLinkIP.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/DeviceInspector.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialClient.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/config/BridgeConfiguration.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/config/DeviceConfig.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/config/IPBridgeConfiguration.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/config/SerialBridgeConfiguration.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/factory/KNXHandlerFactory.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/AbstractKNXThingHandler.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceConstants.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/DeviceThingHandler.java
bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/handler/IPBridgeThingHandler.java
bundles/org.openhab.binding.knx/src/test/java/org/openhab/binding/knx/internal/channel/KNXChannelTypeTest.java
bundles/org.openhab.binding.knx/src/test/java/org/openhab/binding/knx/internal/dpt/KNXCoreTypeMapperTest.java

index 4f243cb62c7236c3114a4912adb1517a06117086..1896c04a27cfe0f91ca1102ecee09963bead1d71 100644 (file)
@@ -18,6 +18,7 @@ import java.util.Collections;
 import java.util.Set;
 import java.util.stream.Stream;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingTypeUID;
 
 /**
@@ -26,6 +27,7 @@ import org.openhab.core.thing.ThingTypeUID;
  *
  * @author Karel Goderis - Initial contribution
  */
+@NonNullByDefault
 public class KNXBindingConstants {
 
     public static final String BINDING_ID = "knx";
index 2fb88e342b49c3bb98142d744405ae4f2bd86b43..a02d6e7bfa2adaaae527c95899831bf942275aae 100644 (file)
@@ -17,7 +17,6 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.core.types.Type;
 
 import tuwien.auto.calimero.datapoint.Datapoint;
-import tuwien.auto.calimero.process.ProcessEvent;
 
 /**
  * This interface must be implemented by classes that provide a type mapping
@@ -25,7 +24,7 @@ import tuwien.auto.calimero.process.ProcessEvent;
  * When a command or status update is sent to an item on the openHAB event bus,
  * it must be clear, in which format it must be sent to KNX and vice versa.
  *
- * @author Kai Kreuzer
+ * @author Kai Kreuzer - Initial contribution
  *
  */
 @NonNullByDefault
@@ -45,7 +44,8 @@ public interface KNXTypeMapper {
      * maps a datapoint value to an openHAB command or state
      *
      * @param datapoint the source datapoint
-     * @param data the datapoint value as an ASDU byte array (see <code>{@link ProcessEvent}.getASDU()</code>)
+     * @param data the datapoint value as an ASDU byte array (see
+     *            <code>{@link tuwien.auto.calimero.process.ProcessEvent}.getASDU()</code>)
      * @return a command or state of openHAB
      */
     @Nullable
index bbe5e30f18ddd0cfa6c09b754e2f265af91f7a0e..717a41626f3110aee2c9a1a30b656996dd93e6db 100644 (file)
@@ -14,8 +14,6 @@ package org.openhab.binding.knx.internal.channel;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.knx.internal.client.InboundSpec;
-import org.openhab.binding.knx.internal.client.OutboundSpec;
 
 import tuwien.auto.calimero.GroupAddress;
 import tuwien.auto.calimero.KNXFormatException;
@@ -57,7 +55,8 @@ public abstract class AbstractSpec {
     /**
      * Return the data point type.
      * <p>
-     * See {@link InboundSpec#getDPT()} and {@link OutboundSpec#getDPT()}.
+     * See {@link org.openhab.binding.knx.internal.client.InboundSpec#getDPT()} and
+     * {@link org.openhab.binding.knx.internal.client.OutboundSpec#getDPT()}.
      *
      * @return the data point type.
      */
index 1135f1a9e32b7f1a321b4adcd11a6196b0036334..e3b23bfc4a4f62f9c41d5a7a8997b1ad3523fcdc 100644 (file)
@@ -17,6 +17,7 @@ import static java.util.stream.Collectors.toList;
 import java.util.Collections;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.knx.internal.client.InboundSpec;
 
@@ -28,6 +29,7 @@ import tuwien.auto.calimero.GroupAddress;
  * @author Simon Kaufmann - initial contribution and API.
  *
  */
+@NonNullByDefault
 public class ListenSpecImpl extends AbstractSpec implements InboundSpec {
 
     private final List<GroupAddress> listenAddresses;
index 695edb277edfea3ced5148c377fbc3528cfbe272..88e3386c8dd6d61b43910dcab9c1f98d8b0c2c5c 100644 (file)
@@ -244,7 +244,7 @@ public abstract class AbstractKNXClient implements NetworkLinkListener, KNXClien
         });
     }
 
-    private <T> T nullify(T target, @Nullable Consumer<T> lastWill) {
+    private <T> @Nullable T nullify(T target, @Nullable Consumer<T> lastWill) {
         if (target != null && lastWill != null) {
             lastWill.accept(target);
         }
@@ -392,7 +392,8 @@ public abstract class AbstractKNXClient implements NetworkLinkListener, KNXClien
 
     @Override
     public boolean isConnected() {
-        return link != null && link.isOpen();
+        final var tmpLink = link;
+        return tmpLink != null && tmpLink.isOpen();
     }
 
     @Override
index f9359b918305fe9219e98fa73deb36bf10e52934..266b5231f2aa377bfc658e76595cba9e890dbcad 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.knx.internal.client;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 import tuwien.auto.calimero.KNXException;
 import tuwien.auto.calimero.knxnetip.KNXnetIPConnection;
 import tuwien.auto.calimero.link.KNXNetworkLinkIP;
@@ -24,6 +26,7 @@ import tuwien.auto.calimero.link.medium.KNXMediumSettings;
  * @author Simon Kaufmann - initial contribution and API
  *
  */
+@NonNullByDefault
 public class CustomKNXNetworkLinkIP extends KNXNetworkLinkIP {
 
     public static final int TUNNELING = KNXNetworkLinkIP.TUNNELING;
index f9b21170306f23ac4c90ff999c80deb22d86aaed..02830410e6095edf90f559e4464ce988ae9ce4c8 100644 (file)
@@ -100,7 +100,7 @@ public class DeviceInspector {
                     OPERATION_TIMEOUT);
             if ((elements == null ? 0 : toUnsigned(elements)) == 1) {
                 Thread.sleep(OPERATION_INTERVAL);
-                String ManufacturerID = Manufacturer.getName(toUnsigned(getClient().readDeviceProperties(address,
+                String manufacturerID = Manufacturer.getName(toUnsigned(getClient().readDeviceProperties(address,
                         DEVICE_OBJECT, PID.MANUFACTURER_ID, 1, 1, false, OPERATION_TIMEOUT)));
                 Thread.sleep(OPERATION_INTERVAL);
                 String serialNo = toHex(getClient().readDeviceProperties(address, DEVICE_OBJECT, PID.SERIAL_NUMBER, 1,
@@ -112,7 +112,7 @@ public class DeviceInspector {
                 String firmwareRevision = Integer.toString(toUnsigned(getClient().readDeviceProperties(address,
                         DEVICE_OBJECT, PID.FIRMWARE_REVISION, 1, 1, false, OPERATION_TIMEOUT)));
 
-                ret.put(MANUFACTURER_NAME, ManufacturerID);
+                ret.put(MANUFACTURER_NAME, manufacturerID);
                 if (serialNo != null) {
                     ret.put(MANUFACTURER_SERIAL_NO, serialNo);
                 }
@@ -121,7 +121,7 @@ public class DeviceInspector {
                 }
                 ret.put(MANUFACTURER_FIRMWARE_REVISION, firmwareRevision);
                 logger.debug("Identified device {} as a {}, type {}, revision {}, serial number {}", address,
-                        ManufacturerID, hardwareType, firmwareRevision, serialNo);
+                        manufacturerID, hardwareType, firmwareRevision, serialNo);
             } else {
                 logger.debug("The KNX device with address {} does not expose a Device Object", address);
             }
index af44bef4a452ae0d2ff8b35ac352ab5ea214f216..3f6113837c901db078a752f0c01680383c5daa4f 100644 (file)
@@ -15,7 +15,7 @@ package org.openhab.binding.knx.internal.client;
 import java.util.Enumeration;
 import java.util.concurrent.ScheduledExecutorService;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.core.thing.ThingUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,6 +33,7 @@ import tuwien.auto.calimero.link.medium.TPSettings;
  * @author Simon Kaufmann - initial contribution and API.
  *
  */
+@NonNullByDefault
 public class SerialClient extends AbstractKNXClient {
 
     private final Logger logger = LoggerFactory.getLogger(SerialClient.class);
@@ -48,7 +49,7 @@ public class SerialClient extends AbstractKNXClient {
     }
 
     @Override
-    protected @NonNull KNXNetworkLink establishConnection() throws KNXException, InterruptedException {
+    protected KNXNetworkLink establishConnection() throws KNXException, InterruptedException {
         try {
             RXTXVersion.getVersion();
             logger.debug("Establishing connection to KNX bus through FT1.2 on serial port {}.", serialPort);
@@ -59,12 +60,13 @@ public class SerialClient extends AbstractKNXClient {
                     "The serial FT1.2 KNX connection requires the RXTX libraries to be available, but they could not be found!",
                     e);
         } catch (KNXException e) {
-            if (e.getMessage().startsWith("can not open serial port")) {
+            final String msg = e.getMessage();
+            if ((msg != null) && (msg.startsWith("can not open serial port"))) {
                 StringBuilder sb = new StringBuilder("Available ports are:\n");
                 Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
                 while (portList.hasMoreElements()) {
                     CommPortIdentifier id = (CommPortIdentifier) portList.nextElement();
-                    if (id.getPortType() == CommPortIdentifier.PORT_SERIAL) {
+                    if ((id != null) && (id.getPortType() == CommPortIdentifier.PORT_SERIAL)) {
                         sb.append(id.getName());
                         sb.append("\n");
                     }
index 1d12d324f16c428aca726352a99724d85e727c12..3c0909db17c51b2116562f4fe3ceda6e133f1a1a 100644 (file)
@@ -14,19 +14,20 @@ package org.openhab.binding.knx.internal.config;
 
 import java.math.BigDecimal;
 
-import org.openhab.binding.knx.internal.handler.KNXBridgeBaseThingHandler;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 
 /**
- * {@link KNXBridgeBaseThingHandler} configuration
+ * {@link org.openhab.binding.knx.internal.handler.KNXBridgeBaseThingHandler} configuration
  *
  * @author Simon Kaufmann - initial contribution and API
  *
  */
+@NonNullByDefault
 public class BridgeConfiguration {
-    private int autoReconnectPeriod;
-    private BigDecimal readingPause;
-    private BigDecimal readRetriesLimit;
-    private BigDecimal responseTimeout;
+    private int autoReconnectPeriod = 0;
+    private BigDecimal readingPause = BigDecimal.valueOf(0);
+    private BigDecimal readRetriesLimit = BigDecimal.valueOf(0);
+    private BigDecimal responseTimeout = BigDecimal.valueOf(0);
 
     public int getAutoReconnectPeriod() {
         return autoReconnectPeriod;
index 6df1481595ce47048707205ccc977ef734f67945..5f7953e1f676725ffad6c55a923d50a7e84f9a9f 100644 (file)
@@ -14,18 +14,21 @@ package org.openhab.binding.knx.internal.config;
 
 import java.math.BigDecimal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Configuration object for the device thing handler.
  *
  * @author Karel Goderis - Initial contribution
  * @author Simon Kaufmann - refactoring & cleanup
  */
+@NonNullByDefault
 public class DeviceConfig {
 
-    private String address;
-    private boolean fetch;
-    private BigDecimal pingInterval;
-    private BigDecimal readInterval;
+    private String address = "";
+    private boolean fetch = false;
+    private BigDecimal pingInterval = BigDecimal.valueOf(0);
+    private BigDecimal readInterval = BigDecimal.valueOf(0);
 
     public String getAddress() {
         return address;
index b3192f7b826fd68d639f2a32eb90e9271e1b25be..6c6b8816aab715c9f86900536e1a3a9e330b3a50 100644 (file)
@@ -14,20 +14,23 @@ package org.openhab.binding.knx.internal.config;
 
 import java.math.BigDecimal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * IP Bridge handler configuration object.
  *
  * @author Simon Kaufmann - initial contribution and API
  *
  */
+@NonNullByDefault
 public class IPBridgeConfiguration extends BridgeConfiguration {
 
-    private boolean useNAT;
-    private String type;
-    private String ipAddress;
-    private BigDecimal portNumber;
-    private String localIp;
-    private String localSourceAddr;
+    private boolean useNAT = false;
+    private String type = "";
+    private String ipAddress = "";
+    private BigDecimal portNumber = BigDecimal.valueOf(0);
+    private String localIp = "";
+    private String localSourceAddr = "";
 
     public Boolean getUseNAT() {
         return useNAT;
index 8dfcd9cf3a467ae54babb6b23937cfcac096b937..b267ad3338dd0b47666088c6204ac1d70bcebf93 100644 (file)
  */
 package org.openhab.binding.knx.internal.config;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Serial Bridge configuration object.
  *
  * @author Simon Kaufmann - initial contribution and API.
  *
  */
+@NonNullByDefault
 public class SerialBridgeConfiguration extends BridgeConfiguration {
 
-    private String serialPort;
+    private String serialPort = "";
 
     public String getSerialPort() {
         return serialPort;
index 96e6b411fcf5381bfc59120ab5b573a58bdde684..3539144e945f14e88ddbed9acbffb62fc2925527 100644 (file)
@@ -55,8 +55,8 @@ public class KNXHandlerFactory extends BaseThingHandlerFactory {
     public Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, ThingUID thingUID,
             ThingUID bridgeUID) {
         if (THING_TYPE_IP_BRIDGE.equals(thingTypeUID)) {
-            ThingUID IPBridgeUID = getIPBridgeThingUID(thingTypeUID, thingUID, configuration);
-            return super.createThing(thingTypeUID, configuration, IPBridgeUID, null);
+            ThingUID ipBridgeUID = getIPBridgeThingUID(thingTypeUID, thingUID, configuration);
+            return super.createThing(thingTypeUID, configuration, ipBridgeUID, null);
         }
         if (THING_TYPE_SERIAL_BRIDGE.equals(thingTypeUID)) {
             ThingUID serialBridgeUID = getSerialBridgeThingUID(thingTypeUID, thingUID, configuration);
index 7282a95cf2102b10e959d2a4a7bec013620d74ec..318f58f14945ae400498496f6508bb3e31884c71 100644 (file)
@@ -19,7 +19,6 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.knx.internal.client.DeviceInspector;
@@ -118,7 +117,7 @@ public abstract class AbstractKNXThingHandler extends BaseThingHandler implement
     }
 
     @Override
-    public void bridgeStatusChanged(@NonNull ThingStatusInfo bridgeStatusInfo) {
+    public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) {
         if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) {
             attachToClient();
         } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) {
@@ -175,7 +174,7 @@ public abstract class AbstractKNXThingHandler extends BaseThingHandler implement
         }
         DeviceConfig config = getConfigAs(DeviceConfig.class);
         try {
-            if (config.getAddress() != null && !config.getAddress().isEmpty()) {
+            if (!config.getAddress().isEmpty()) {
                 updateStatus(ThingStatus.UNKNOWN);
                 address = new IndividualAddress(config.getAddress());
 
@@ -200,12 +199,14 @@ public abstract class AbstractKNXThingHandler extends BaseThingHandler implement
     }
 
     protected void detachFromClient() {
-        if (pollingJob != null) {
-            pollingJob.cancel(true);
+        final var pollingJobSynced = pollingJob;
+        if (pollingJobSynced != null) {
+            pollingJobSynced.cancel(true);
             pollingJob = null;
         }
-        if (descriptionJob != null) {
-            descriptionJob.cancel(true);
+        final var descriptionJobSynced = descriptionJob;
+        if (descriptionJobSynced != null) {
+            descriptionJobSynced.cancel(true);
             descriptionJob = null;
         }
         cancelReadFutures();
index 4d44225b1a04cce192c429bbbb9f889f23fbaca6..07acde0c72348c8a2c9f16ef80e3e7ae3bf032ba 100644 (file)
  */
 package org.openhab.binding.knx.internal.handler;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * @author Karel Goderis - Initial contribution
  */
+@NonNullByDefault
 public class DeviceConstants {
 
     private DeviceConstants() {
index 2e5ff3c8fd5256ba30cefe9ef1f5cd682d6be40d..d017dca4c6c752bdebf99efa3a7512ac4bfc5917 100644 (file)
@@ -105,7 +105,7 @@ public class DeviceThingHandler extends AbstractKNXThingHandler {
 
     private void cancelChannelFutures() {
         for (ScheduledFuture<?> future : channelFutures.values()) {
-            if (future != null && !future.isDone()) {
+            if (!future.isDone()) {
                 future.cancel(true);
             }
         }
@@ -121,7 +121,7 @@ public class DeviceThingHandler extends AbstractKNXThingHandler {
     @Override
     protected void cancelReadFutures() {
         for (ScheduledFuture<?> future : readFutures.values()) {
-            if (future != null && !future.isDone()) {
+            if (!future.isDone()) {
                 future.cancel(true);
             }
         }
index e40f126f6c40ea115a62582f2c123ddb8e401849..ad935d9e161c9eec4e9dfd1376f982c72b55ebcd 100644 (file)
@@ -72,11 +72,11 @@ public class IPBridgeThingHandler extends KNXBridgeBaseThingHandler {
         boolean useNAT = false;
         int ipConnectionType;
         if (MODE_TUNNEL.equalsIgnoreCase(connectionTypeString)) {
-            useNAT = config.getUseNAT() != null ? config.getUseNAT() : false;
+            useNAT = config.getUseNAT();
             ipConnectionType = CustomKNXNetworkLinkIP.TUNNELING;
         } else if (MODE_ROUTER.equalsIgnoreCase(connectionTypeString)) {
             useNAT = false;
-            if (ip == null || ip.isEmpty()) {
+            if (ip.isEmpty()) {
                 ip = KNXBindingConstants.DEFAULT_MULTICAST_IP;
             }
             ipConnectionType = CustomKNXNetworkLinkIP.ROUTING;
@@ -86,13 +86,8 @@ public class IPBridgeThingHandler extends KNXBridgeBaseThingHandler {
                             connectionTypeString));
             return;
         }
-        if (ip == null) {
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                    "The 'ipAddress' of the gateway must be configured in 'TUNNEL' mode");
-            return;
-        }
 
-        if (config.getLocalIp() != null && !config.getLocalIp().isEmpty()) {
+        if (!config.getLocalIp().isEmpty()) {
             localEndPoint = new InetSocketAddress(config.getLocalIp(), 0);
         } else {
             localEndPoint = new InetSocketAddress(networkAddressService.getPrimaryIpv4HostAddress(), 0);
@@ -103,14 +98,18 @@ public class IPBridgeThingHandler extends KNXBridgeBaseThingHandler {
                 thing.getUID(), config.getResponseTimeout().intValue(), config.getReadingPause().intValue(),
                 config.getReadRetriesLimit().intValue(), getScheduler(), this);
 
-        client.initialize();
+        final var tmpClient = client;
+        if (tmpClient != null) {
+            tmpClient.initialize();
+        }
     }
 
     @Override
     public void dispose() {
         super.dispose();
-        if (client != null) {
-            client.dispose();
+        final var tmpClient = client;
+        if (tmpClient != null) {
+            tmpClient.dispose();
             client = null;
         }
     }
index 3d423084b192ea4d2423752dc4534f6bd0bd3d45..c735844f210a45f70835b21adad79d3b2e057518 100644 (file)
@@ -17,7 +17,7 @@ import static org.junit.jupiter.api.Assertions.*;
 import java.util.Collections;
 import java.util.Set;
 
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -26,17 +26,19 @@ import org.junit.jupiter.api.Test;
  * @author Simon Kaufmann - initial contribution and API.
  *
  */
+@NonNullByDefault
 public class KNXChannelTypeTest {
 
-    private KNXChannelType ct;
+    private KNXChannelType ct = new MyKNXChannelType("");
 
     @BeforeEach
     public void setup() {
         ct = new MyKNXChannelType("");
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_withDPT_multiple_withRead() {
+    public void testParseWithDptMultipleWithRead() {
         ChannelConfiguration res = ct.parse("5.001:<1/3/22+0/3/22+<0/8/15");
 
         assertEquals("5.001", res.getDPT());
@@ -46,8 +48,9 @@ public class KNXChannelTypeTest {
         assertEquals(2, res.getReadGAs().size());
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_withDPT_multiple_withoutRead() {
+    public void testParseWithDptMultipleWithoutRead() {
         ChannelConfiguration res = ct.parse("5.001:1/3/22+0/3/22+0/8/15");
 
         assertEquals("5.001", res.getDPT());
@@ -57,8 +60,9 @@ public class KNXChannelTypeTest {
         assertEquals(0, res.getReadGAs().size());
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_withoutDPT_single_withoutRead() {
+    public void testParseWithoutDptSingleWithoutRead() {
         ChannelConfiguration res = ct.parse("1/3/22");
 
         assertNull(res.getDPT());
@@ -68,8 +72,9 @@ public class KNXChannelTypeTest {
         assertEquals(0, res.getReadGAs().size());
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_withoutDPT_single_witRead() {
+    public void testParseWithoutDptSingleWitRead() {
         ChannelConfiguration res = ct.parse("<1/3/22");
 
         assertNull(res.getDPT());
@@ -79,16 +84,18 @@ public class KNXChannelTypeTest {
         assertEquals(1, res.getReadGAs().size());
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_twoLevel() {
+    public void testParseTwoLevel() {
         ChannelConfiguration res = ct.parse("5.001:<3/1024+<4/1025");
         assertEquals("3/1024", res.getMainGA().getGA());
         assertEquals(2, res.getListenGAs().size());
         assertEquals(2, res.getReadGAs().size());
     }
 
+    @SuppressWarnings("null")
     @Test
-    public void testParse_freeLevel() {
+    public void testParseFreeLevel() {
         ChannelConfiguration res = ct.parse("5.001:<4610+<4611");
         assertEquals("4610", res.getMainGA().getGA());
         assertEquals(2, res.getListenGAs().size());
@@ -101,12 +108,12 @@ public class KNXChannelTypeTest {
         }
 
         @Override
-        protected @NonNull Set<@NonNull String> getAllGAKeys() {
+        protected Set<String> getAllGAKeys() {
             return Collections.emptySet();
         }
 
         @Override
-        protected @NonNull String getDefaultDPT(@NonNull String gaConfigKey) {
+        protected String getDefaultDPT(String gaConfigKey) {
             return "";
         }
     }
index 3e8320edfb8887f3bcbc017f82b221123da03605..fae66e40024f6003b5decc26c100ec0d3df41e05 100644 (file)
@@ -14,6 +14,7 @@ package org.openhab.binding.knx.internal.dpt;
 
 import static org.junit.jupiter.api.Assertions.*;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.junit.jupiter.api.Test;
 import org.openhab.core.library.types.DecimalType;
 
@@ -22,10 +23,11 @@ import org.openhab.core.library.types.DecimalType;
  * @author Simon Kaufmann - initial contribution and API
  *
  */
+@NonNullByDefault
 public class KNXCoreTypeMapperTest {
 
     @Test
-    public void testToDPTValue_trailingZeroesStrippedOff() {
+    public void testToDPTValueTrailingZeroesStrippedOff() {
         assertEquals("3", new KNXCoreTypeMapper().toDPTValue(new DecimalType("3"), "17.001"));
         assertEquals("3", new KNXCoreTypeMapper().toDPTValue(new DecimalType("3.0"), "17.001"));
     }