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:
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
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.eclipse.jetty.client.HttpClient;
|
||||
@@ -95,14 +94,15 @@ public class EnturNoHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Stop place id: {}", stopId);
|
||||
boolean configValid = true;
|
||||
if (StringUtils.trimToNull(stopId) == null) {
|
||||
if (stopId == null || stopId.isBlank()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"@text/offline.conf-error-missing-stopId");
|
||||
configValid = false;
|
||||
}
|
||||
|
||||
logger.debug("Line code: {}", config.getLineCode());
|
||||
if (StringUtils.trimToNull(config.getLineCode()) == null) {
|
||||
String lineCode = config.getLineCode();
|
||||
logger.debug("Line code: {}", lineCode);
|
||||
if (lineCode == null || lineCode.isBlank()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"@text/offline.conf-error-missing-lineCode");
|
||||
configValid = false;
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
@@ -96,9 +96,9 @@ public class EnturNoConnection {
|
||||
*/
|
||||
public synchronized List<DisplayData> getEnturTimeTable(@Nullable String stopPlaceId, @Nullable String lineCode)
|
||||
throws JsonSyntaxException, EnturConfigurationException, EnturCommunicationException {
|
||||
if (StringUtils.isBlank(stopPlaceId)) {
|
||||
if (stopPlaceId == null || stopPlaceId.isBlank()) {
|
||||
throw new EnturConfigurationException("Stop place id cannot be empty or null");
|
||||
} else if (lineCode == null || StringUtils.isBlank(lineCode)) {
|
||||
} else if (lineCode == null || lineCode.isBlank()) {
|
||||
throw new EnturConfigurationException("Line code cannot be empty or null");
|
||||
}
|
||||
|
||||
@@ -115,8 +115,9 @@ public class EnturNoConnection {
|
||||
|
||||
private Map<String, String> getRequestParams(EnturNoConfiguration config) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(PARAM_STOPID, StringUtils.trimToEmpty(config.getStopPlaceId()));
|
||||
params.put(PARAM_START_DATE_TIME, StringUtils.trimToEmpty(LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString()));
|
||||
String stopPlaceId = config.getStopPlaceId();
|
||||
params.put(PARAM_STOPID, stopPlaceId == null ? "" : stopPlaceId.trim());
|
||||
params.put(PARAM_START_DATE_TIME, LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString());
|
||||
|
||||
return params;
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public class EnturNoConnection {
|
||||
|
||||
int httpStatus = contentResponse.getStatus();
|
||||
String content = contentResponse.getContentAsString();
|
||||
String errorMessage = StringUtils.EMPTY;
|
||||
String errorMessage = "";
|
||||
logger.trace("Entur response: status = {}, content = '{}'", httpStatus, content);
|
||||
switch (httpStatus) {
|
||||
case OK_200:
|
||||
|
||||
Reference in New Issue
Block a user