From 3abe27b2245ba82147a958ef3909910ec5aef787 Mon Sep 17 00:00:00 2001 From: robnielsen Date: Thu, 1 Oct 2020 16:55:19 -0500 Subject: [PATCH] [insteon] remove dependency on org.apache.commons.lang.StringUtils (#8630) Signed-off-by: Rob Nielsen --- .../binding/insteon/internal/driver/hub/HubIOStream.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/HubIOStream.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/HubIOStream.java index 144eb3cfd83..ad8d0cd9d8c 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/HubIOStream.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/hub/HubIOStream.java @@ -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 *