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

@@ -18,7 +18,6 @@ import java.io.IOException;
import java.util.concurrent.ScheduledFuture;
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.openhab.binding.ambientweather.internal.config.BridgeConfig;
@@ -128,7 +127,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
*/
private boolean hasApplicationKey() {
String configApplicationKey = getConfigAs(BridgeConfig.class).applicationKey;
if (StringUtils.isEmpty(configApplicationKey)) {
if (configApplicationKey == null || configApplicationKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing application key");
return false;
}
@@ -141,7 +140,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
*/
private boolean hasApiKey() {
String configApiKey = getConfigAs(BridgeConfig.class).apiKey;
if (StringUtils.isEmpty(configApiKey)) {
if (configApiKey == null || configApiKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing API key");
return false;
}

View File

@@ -18,7 +18,6 @@ import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.openhab.binding.ambientweather.internal.model.DeviceJson;
import org.openhab.binding.ambientweather.internal.model.EventDataGenericJson;
@@ -318,8 +317,9 @@ public class AmbientWeatherEventListener {
logger.debug("Listener: Data: {}", jsonData);
try {
EventDataGenericJson data = gson.fromJson(jsonData, EventDataGenericJson.class);
if (StringUtils.isNotEmpty(data.macAddress)) {
sendWeatherDataToHandler(data.macAddress, jsonData);
String macAddress = data == null ? null : data.macAddress;
if (macAddress != null && !macAddress.isEmpty()) {
sendWeatherDataToHandler(macAddress, jsonData);
}
} catch (JsonSyntaxException e) {
logger.info("Listener: Exception parsing subscribed event: {}", e.getMessage());