Rework more commons-lang usages (#10314)

* Reworks many commons-lang usages to use standard Java
* Updates all remaining commons.lang imports to commons.lang3

Related to openhab/openhab-addons#7722

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-03-16 12:38:16 +01:00
committed by GitHub
parent 16fba31556
commit f3503430b4
257 changed files with 906 additions and 1125 deletions

View File

@@ -23,7 +23,6 @@ import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
@@ -131,8 +130,8 @@ public class KM200Cryption {
* @author Markus Eckhardt
*/
public void recreateKeys() {
if (StringUtils.isNotBlank(remoteDevice.getGatewayPassword())
&& StringUtils.isNotBlank(remoteDevice.getPrivatePassword()) && remoteDevice.getMD5Salt().length > 0) {
if (!remoteDevice.getGatewayPassword().isBlank() && !remoteDevice.getPrivatePassword().isBlank()
&& remoteDevice.getMD5Salt().length > 0) {
byte[] md5K1 = null;
byte[] md5K2Init = null;
byte[] md5K2Private = null;

View File

@@ -19,8 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
@@ -84,7 +83,7 @@ public class KM200Device {
}
public Boolean isConfigured() {
return StringUtils.isNotBlank(ip4Address) && cryptKeyPriv.length > 0;
return !ip4Address.isBlank() && cryptKeyPriv.length > 0;
}
public String getIP4Address() {

View File

@@ -30,7 +30,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
@@ -177,7 +176,7 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
switch (key) {
case "ip4Address":
String ip = (String) configuration.get("ip4Address");
if (StringUtils.isNotBlank(ip)) {
if (ip != null && !ip.isBlank()) {
try {
InetAddress.getByName(ip);
} catch (UnknownHostException e) {
@@ -190,25 +189,25 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
break;
case "privateKey":
String privateKey = (String) configuration.get("privateKey");
if (StringUtils.isNotBlank(privateKey)) {
if (privateKey != null && !privateKey.isBlank()) {
getDevice().setCryptKeyPriv(privateKey);
}
break;
case "md5Salt":
String md5Salt = (String) configuration.get("md5Salt");
if (StringUtils.isNotBlank(md5Salt)) {
if (md5Salt != null && !md5Salt.isBlank()) {
getDevice().setMD5Salt(md5Salt);
}
break;
case "gatewayPassword":
String gatewayPassword = (String) configuration.get("gatewayPassword");
if (StringUtils.isNotBlank(gatewayPassword)) {
if (gatewayPassword != null && !gatewayPassword.isBlank()) {
getDevice().setGatewayPassword(gatewayPassword);
}
break;
case "privatePassword":
String privatePassword = (String) configuration.get("privatePassword");
if (StringUtils.isNotBlank(privatePassword)) {
if (privatePassword != null && !privatePassword.isBlank()) {
getDevice().setPrivatePassword(privatePassword);
}
break;