[plugwise] Remove org.apache.common (#14432)
Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
@@ -22,7 +22,6 @@ import java.util.TooManyListenersException;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.plugwise.internal.protocol.AcknowledgementMessage;
|
import org.openhab.binding.plugwise.internal.protocol.AcknowledgementMessage;
|
||||||
@@ -95,7 +94,7 @@ public class PlugwiseMessageProcessor implements SerialPortEventListener {
|
|||||||
*/
|
*/
|
||||||
private void parseAndQueue(ByteBuffer readBuffer) {
|
private void parseAndQueue(ByteBuffer readBuffer) {
|
||||||
String response = new String(readBuffer.array(), 0, readBuffer.limit());
|
String response = new String(readBuffer.array(), 0, readBuffer.limit());
|
||||||
response = StringUtils.chomp(response);
|
response = response.replaceAll("\r", "").replaceAll("\n", "");
|
||||||
|
|
||||||
Matcher matcher = RESPONSE_PATTERN.matcher(response);
|
Matcher matcher = RESPONSE_PATTERN.matcher(response);
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import java.time.ZoneId;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.plugwise.internal.protocol.InformationResponseMessage;
|
import org.openhab.binding.plugwise.internal.protocol.InformationResponseMessage;
|
||||||
@@ -102,8 +100,19 @@ public final class PlugwiseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String upperUnderscoreToLowerCamel(String text) {
|
public static String upperUnderscoreToLowerCamel(String text) {
|
||||||
String upperCamel = StringUtils.remove(WordUtils.capitalizeFully(text, new char[] { '_' }), "_");
|
final String delimiter = "_";
|
||||||
return upperCamel.substring(0, 1).toLowerCase() + upperCamel.substring(1);
|
StringBuilder upperCamelBuilder = new StringBuilder(text.length());
|
||||||
|
for (String str : text.split(delimiter)) {
|
||||||
|
if (upperCamelBuilder.isEmpty() && str.length() > 0) {
|
||||||
|
upperCamelBuilder.append(str.substring(0, 1).toLowerCase());
|
||||||
|
} else if (str.length() > 0) {
|
||||||
|
upperCamelBuilder.append(str.substring(0, 1).toUpperCase());
|
||||||
|
}
|
||||||
|
if (str.length() > 1) {
|
||||||
|
upperCamelBuilder.append(str.substring(1).toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return upperCamelBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean updateProperties(Map<String, String> properties, InformationResponseMessage message) {
|
public static boolean updateProperties(Map<String, String> properties, InformationResponseMessage message) {
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openhab.binding.plugwise.internal;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link PlugwiseUtilsTest} class tests some static string utility methods
|
||||||
|
*
|
||||||
|
* @author Leo Siepel - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class PlugwiseUtilsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void upperUnderscoreToLowerCamelBaseTest() {
|
||||||
|
assertEquals("nodelimiterpresent", PlugwiseUtils.upperUnderscoreToLowerCamel("NoDelimiterPresent"));
|
||||||
|
assertEquals("delimiterIsPresent", PlugwiseUtils.upperUnderscoreToLowerCamel("DeliMiter_iS_PreSent"));
|
||||||
|
assertEquals("doubleDelimitersDouble", PlugwiseUtils.upperUnderscoreToLowerCamel("DOUBLE__DELIMITERS__DOUBLE"));
|
||||||
|
assertEquals("helloWorld", PlugwiseUtils.upperUnderscoreToLowerCamel("HELLO_WORLD"));
|
||||||
|
assertEquals("", PlugwiseUtils.upperUnderscoreToLowerCamel(""));
|
||||||
|
assertEquals("", PlugwiseUtils.upperUnderscoreToLowerCamel("_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user