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:
@@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
@@ -156,7 +155,7 @@ public class FoobotApiConnector {
|
||||
apiKeyLimitRemaining = API_RATE_LIMIT_EXCEEDED;
|
||||
throw new FoobotApiException(response.getStatus(), API_RATE_LIMIT_EXCEEDED_MESSAGE);
|
||||
case HttpStatus.OK_200:
|
||||
if (StringUtils.trimToNull(content) == null) {
|
||||
if (content == null || content.isBlank()) {
|
||||
throw new FoobotApiException(0, "No data returned");
|
||||
}
|
||||
return content;
|
||||
|
||||
@@ -15,12 +15,14 @@ package org.openhab.binding.foobot.internal.handler;
|
||||
import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.foobot.internal.FoobotApiConnector;
|
||||
@@ -93,10 +95,12 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
final FoobotAccountConfiguration accountConfig = getConfigAs(FoobotAccountConfiguration.class);
|
||||
final List<String> missingParams = new ArrayList<>();
|
||||
|
||||
if (StringUtils.trimToNull(accountConfig.apiKey) == null) {
|
||||
String apiKey = accountConfig.apiKey;
|
||||
if (apiKey.isBlank()) {
|
||||
missingParams.add("'apikey'");
|
||||
}
|
||||
if (StringUtils.trimToNull(accountConfig.username) == null) {
|
||||
String username = accountConfig.username;
|
||||
if (username.isBlank()) {
|
||||
missingParams.add("'username'");
|
||||
}
|
||||
|
||||
@@ -104,13 +108,13 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
final boolean oneParam = missingParams.size() == 1;
|
||||
final String errorMsg = String.format(
|
||||
"Parameter%s [%s] %s mandatory and must be configured and not be empty", oneParam ? "" : "s",
|
||||
StringUtils.join(missingParams, ", "), oneParam ? "is" : "are");
|
||||
String.join(", ", missingParams), oneParam ? "is" : "are");
|
||||
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, errorMsg);
|
||||
return;
|
||||
}
|
||||
username = accountConfig.username;
|
||||
connector.setApiKey(accountConfig.apiKey);
|
||||
this.username = username;
|
||||
connector.setApiKey(apiKey);
|
||||
refreshInterval = accountConfig.refreshInterval;
|
||||
if (this.refreshInterval < MINIMUM_REFRESH_PERIOD_MINUTES) {
|
||||
logger.warn(
|
||||
@@ -118,8 +122,7 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
accountConfig.refreshInterval, MINIMUM_REFRESH_PERIOD_MINUTES, DEFAULT_REFRESH_PERIOD_MINUTES);
|
||||
refreshInterval = DEFAULT_REFRESH_PERIOD_MINUTES;
|
||||
}
|
||||
logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", accountConfig.username,
|
||||
refreshInterval);
|
||||
logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", username, refreshInterval);
|
||||
|
||||
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "Wait to get associated devices");
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Map;
|
||||
|
||||
import javax.measure.Unit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.foobot.internal.FoobotApiConnector;
|
||||
@@ -93,7 +92,7 @@ public class FoobotDeviceHandler extends BaseThingHandler {
|
||||
logger.debug("Initializing Foobot handler.");
|
||||
uuid = (String) getConfig().get(FoobotBindingConstants.CONFIG_UUID);
|
||||
|
||||
if (StringUtils.trimToNull(uuid) == null) {
|
||||
if (uuid.isBlank()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"Parameter 'uuid' is mandatory and must be configured");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user