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:
@@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.PercentType;
|
||||
@@ -184,7 +183,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingArtist(String artist) {
|
||||
StringType newVal = StringUtils.isBlank(artist) ? StringType.EMPTY : StringType.valueOf(artist);
|
||||
StringType newVal = artist == null || artist.isBlank() ? StringType.EMPTY : StringType.valueOf(artist);
|
||||
if (!newVal.equals(this.artist)) {
|
||||
this.artist = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ARTIST, this.artist);
|
||||
@@ -192,7 +191,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingAlbum(String album) {
|
||||
StringType newVal = StringUtils.isBlank(album) ? StringType.EMPTY : StringType.valueOf(album);
|
||||
StringType newVal = album == null || album.isBlank() ? StringType.EMPTY : StringType.valueOf(album);
|
||||
if (!newVal.equals(this.album)) {
|
||||
this.album = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ALBUM, this.album);
|
||||
@@ -200,7 +199,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingTrack(String track) {
|
||||
StringType newVal = StringUtils.isBlank(track) ? StringType.EMPTY : StringType.valueOf(track);
|
||||
StringType newVal = track == null || track.isBlank() ? StringType.EMPTY : StringType.valueOf(track);
|
||||
if (!newVal.equals(this.track)) {
|
||||
this.track = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_TRACK, this.track);
|
||||
|
||||
@@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.util.StreamReaderDelegate;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
@@ -169,7 +168,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
@Override
|
||||
protected void internalSendCommand(String command) {
|
||||
logger.debug("Sending command '{}'", command);
|
||||
if (StringUtils.isBlank(command)) {
|
||||
if (command == null || command.isBlank()) {
|
||||
logger.warn("Trying to send empty command");
|
||||
return;
|
||||
}
|
||||
@@ -306,7 +305,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
String result = HttpUtil.executeUrl("GET", uri, REQUEST_TIMEOUT_MS);
|
||||
logger.trace("result of getDocument for uri '{}':\r\n{}", uri, result);
|
||||
|
||||
if (StringUtils.isNotBlank(result)) {
|
||||
if (result != null && !result.isBlank()) {
|
||||
JAXBContext jc = JAXBContext.newInstance(response);
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
|
||||
@@ -341,7 +340,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(sw.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String result = HttpUtil.executeUrl("POST", uri, inputStream, CONTENT_TYPE_XML, REQUEST_TIMEOUT_MS);
|
||||
|
||||
if (StringUtils.isNotBlank(result)) {
|
||||
if (result != null && !result.isBlank()) {
|
||||
JAXBContext jcResponse = JAXBContext.newInstance(response);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -74,7 +73,7 @@ public class DenonMarantzTelnetClientThread extends Thread {
|
||||
break;
|
||||
}
|
||||
logger.trace("Received from {}: {}", config.getHost(), line);
|
||||
if (!StringUtils.isBlank(line)) {
|
||||
if (!line.isBlank()) {
|
||||
listener.receivedLine(line);
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openhab.binding.denonmarantz.internal.DenonMarantzState;
|
||||
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
|
||||
import org.openhab.binding.denonmarantz.internal.connector.DenonMarantzConnector;
|
||||
@@ -263,7 +263,7 @@ public class DenonMarantzTelnetConnector extends DenonMarantzConnector implement
|
||||
@Override
|
||||
protected void internalSendCommand(String command) {
|
||||
logger.debug("Sending command '{}'", command);
|
||||
if (StringUtils.isBlank(command)) {
|
||||
if (command == null || command.isBlank()) {
|
||||
logger.warn("Trying to send empty command");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ package org.openhab.binding.denonmarantz.internal.xml.adapters;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Adapter to clean up string values
|
||||
|
||||
Reference in New Issue
Block a user