]> git.basschouten.com Git - openhab-addons.git/commitdiff
[insteon] remove dependency on org.apache.commons.lang.StringUtils (#8630)
authorrobnielsen <rob.nielsen@yahoo.com>
Thu, 1 Oct 2020 21:55:19 +0000 (16:55 -0500)
committerGitHub <noreply@github.com>
Thu, 1 Oct 2020 21:55:19 +0000 (14:55 -0700)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/HubIOStream.java

index 144eb3cfd839eddf1fa07f951c9870d75bbd08b1..ad8d0cd9d8cc15743d066f63b27f0866000f32ca 100644 (file)
@@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 
-import org.apache.commons.lang.StringUtils;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.insteon.internal.driver.IOStream;
@@ -213,7 +212,7 @@ public class HubIOStream extends IOStream implements Runnable {
             return; // XXX why return here????
         }
 
-        if (StringUtils.repeat("0", data.length()).equals(data)) {
+        if (allZeros(data)) {
             logger.trace("skip cleared buffer");
             bufferIdx = 0;
             return;
@@ -223,7 +222,7 @@ public class HubIOStream extends IOStream implements Runnable {
         if (nIdx < bufferIdx) {
             String msgStart = data.substring(bufferIdx, data.length());
             String msgEnd = data.substring(0, nIdx);
-            if (StringUtils.repeat("0", msgStart.length()).equals(msgStart)) {
+            if (allZeros(msgStart)) {
                 logger.trace("discard cleared buffer wrap around msg start");
                 msgStart = "";
             }
@@ -241,6 +240,10 @@ public class HubIOStream extends IOStream implements Runnable {
         bufferIdx = nIdx;
     }
 
+    private boolean allZeros(String s) {
+        return "0".repeat(s.length()).equals(s);
+    }
+
     /**
      * Helper method to fetch url from http server
      *