]> git.basschouten.com Git - openhab-addons.git/commitdiff
[TR064] Fix SAT warnings (#13873)
authorlsiepel <leosiepel@gmail.com>
Thu, 8 Dec 2022 21:44:44 +0000 (22:44 +0100)
committerGitHub <noreply@github.com>
Thu, 8 Dec 2022 21:44:44 +0000 (22:44 +0100)
* Fix SAT warnings
* Fix markdown
* Properly annotate PhonebookProfileTest

Also-by: Wouter Born <github@maindrain.net>
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.tr064/README.md
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/phonebook/Tr064PhonebookImpl.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/CallListType.java
bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java
bundles/org.openhab.binding.tr064/src/test/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfileTest.java

index 16ff47fc7227010686fdde13b36fc8d2ea45965a..9812f390368bc4c4c9325929c385f50e66dc51ca 100644 (file)
@@ -7,10 +7,12 @@ Even though textual configuration is possible, it is strongly recommended to use
 ## Supported Things
 
 Two Bridge things are supported:
+
 - `generic`: the internet gateway device itself (generic device)
 - `fritzbox`: similar to `generic` with extensions for AVM FritzBox devices.
 
 Two kind of Things are supported:
+
 - `subDevice`: a sub-device of the Bridge thing (e.g. a WAN interface) 
 - `subDeviceLan`: a special type of sub-device that supports MAC-detection
 
@@ -198,6 +200,7 @@ Example (use all phonebooks, match 5 digits from right):
 val tr064Actions = getActions("tr064","tr064:fritzbox:2a28aee1ee")
 val result = tr064Actions.phonebookLookup("49157712341234", 5)
 ```
+
 ## A note on textual configuration
 
 Textual configuration through a `.things` file is possible but, at present, strongly discouraged because it is significantly more error-prone
@@ -208,6 +211,7 @@ an automatic scan through the user interface first in order to extract the requi
 needed subdevices).
 
 The definition of the bridge and of the subdevices things is the following
+
 ```
 Bridge tr064:fritzbox:rootuid "Root label" @ "location" [ host="192.168.1.1", user="user", password="passwd",
                                                          phonebookInterval="0"]{
index fbaf5fc8a3b71a2bad3822f1c91f0a073cab5677..49ec8e1054f2932860124b0ba83c836c32a547ba 100644 (file)
@@ -63,7 +63,7 @@ public class Tr064PhonebookImpl implements Phonebook {
     // in case there are multiple phone entries with same number -> name mapping, i.e. in phonebooks exported from
     // mobiles containing multiple accounts like: local, cloudprovider1, messenger1, messenger2,...
     private String mergeSameContactNames(String nameA, String nameB) {
-        if (nameA != null && nameA.equals(nameB)) {
+        if (nameA.equals(nameB)) {
             return nameA;
         }
         throw new IllegalStateException(
index a1f4b980d7a1641c93f4cae03a114b2208a4c860..a49a6d9489391177473e09dac53bb5b361da64b3 100644 (file)
  */
 package org.openhab.binding.tr064.internal.soap;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * The {@link CallListType} is used for post processing the retrieved call list
  *
  * @author Jan N. Klug - Initial contribution
  */
+
+@NonNullByDefault
 public enum CallListType {
     MISSED_COUNT("2"),
     INBOUND_COUNT("1"),
index 1c606123867a6c4c1bfd6f18580fed4f83b0172b..f9ff295ea92be09839bfdc094044cb7287381f30 100644 (file)
@@ -103,11 +103,11 @@ public class SOAPValueConverter {
                 default:
             }
         } else if (command instanceof StringType) {
-            if (dataType.equals("string")) {
+            if ("string".equals(dataType)) {
                 return Optional.of(command.toString());
             }
         } else if (command instanceof OnOffType) {
-            if (dataType.equals("boolean")) {
+            if ("boolean".equals(dataType)) {
                 return Optional.of(OnOffType.ON.equals(command) ? "1" : "0");
             }
         }
@@ -212,7 +212,7 @@ public class SOAPValueConverter {
     private State processDecaDecibel(State state, Tr064ChannelConfig channelConfig) {
         Float value = state.as(DecimalType.class).floatValue() / 10;
 
-        return new QuantityType(value, Units.DECIBEL);
+        return new QuantityType<>(value, Units.DECIBEL);
     }
 
     /**
index 1176f0596130fc5fa051c0a505e47ec9970f2797..527ed022644caa2c3fffd111a32f7d4e99594b7f 100644 (file)
@@ -51,6 +51,7 @@ import org.openhab.core.util.UIDUtils;
  */
 @ExtendWith(MockitoExtension.class)
 @MockitoSettings(strictness = Strictness.LENIENT)
+@NonNullByDefault
 class PhonebookProfileTest {
 
     private static final String INTERNAL_PHONE_NUMBER = "999";
@@ -60,7 +61,6 @@ class PhonebookProfileTest {
     private static final ThingUID THING_UID = new ThingUID(BINDING_ID, THING_TYPE_FRITZBOX.getId(), "test");
     private static final String MY_PHONEBOOK = UIDUtils.encode(THING_UID.getAsString()) + ":MyPhonebook";
 
-    @NonNullByDefault
     public static class ParameterSet {
         public final State state;
         public final State resultingState;
@@ -101,11 +101,10 @@ class PhonebookProfileTest {
         });
     }
 
-    private @Mock ProfileCallback mockCallback;
-    private @Mock ProfileContext mockContext;
-    private @Mock PhonebookProvider mockPhonebookProvider;
+    private @Mock @NonNullByDefault({}) ProfileCallback mockCallback;
+    private @Mock @NonNullByDefault({}) ProfileContext mockContext;
+    private @Mock @NonNullByDefault({}) PhonebookProvider mockPhonebookProvider;
 
-    @NonNullByDefault
     private final Phonebook phonebook = new Phonebook() {
         @Override
         public Optional<String> lookupNumber(String number, int matchCount) {