[insteon] remove dependency on org.apache.commons.lang.StringUtils (#8630)

Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
This commit is contained in:
robnielsen 2020-10-01 16:55:19 -05:00 committed by GitHub
parent 817e02b53f
commit 3abe27b224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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
*