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:
@@ -16,7 +16,6 @@ import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.squeezebox.internal.handler.SqueezeBoxPlayerHandler;
|
||||
import org.openhab.core.audio.AudioFormat;
|
||||
import org.openhab.core.audio.AudioHTTPServer;
|
||||
@@ -66,8 +65,8 @@ public class SqueezeBoxAudioSink implements AudioSink {
|
||||
this.playerHandler = playerHandler;
|
||||
this.audioHTTPServer = audioHTTPServer;
|
||||
this.callbackUrl = callbackUrl;
|
||||
if (StringUtils.isNotEmpty(callbackUrl)) {
|
||||
logger.debug("SqueezeBox AudioSink created with callback URL {}", callbackUrl);
|
||||
if (callbackUrl != null && !callbackUrl.isEmpty()) {
|
||||
logger.debug("SqueezeBox AudioSink created with callback URL: {}", callbackUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ public class SqueezeBoxAudioSink implements AudioSink {
|
||||
|
||||
// Form the URL for streaming the notification from the OH2 web server
|
||||
// Use the callback URL if it is set in the binding configuration
|
||||
String host = StringUtils.isEmpty(callbackUrl) ? playerHandler.getHostAndPort() : callbackUrl;
|
||||
String host = callbackUrl == null || callbackUrl.isEmpty() ? playerHandler.getHostAndPort() : callbackUrl;
|
||||
if (host == null) {
|
||||
logger.warn("Unable to get host/port from which to stream notification");
|
||||
return;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
*/
|
||||
package org.openhab.binding.squeezebox.internal.config;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* Configuration of a server.
|
||||
*
|
||||
@@ -19,11 +21,12 @@ package org.openhab.binding.squeezebox.internal.config;
|
||||
* @author Mark Hilbush - Added user ID and password
|
||||
*
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class SqueezeBoxServerConfig {
|
||||
/**
|
||||
* Server ip address
|
||||
*/
|
||||
public String ipAddress;
|
||||
public String ipAddress = "";
|
||||
/**
|
||||
* Server web port for REST calls
|
||||
*/
|
||||
@@ -35,13 +38,13 @@ public class SqueezeBoxServerConfig {
|
||||
/**
|
||||
* Language for TTS
|
||||
*/
|
||||
public String language;
|
||||
public String language = "";
|
||||
/*
|
||||
* User ID (when authentication enabled in LMS)
|
||||
*/
|
||||
public String userId;
|
||||
public String userId = "";
|
||||
/*
|
||||
* User ID (when authentication enabled in LMS)
|
||||
*/
|
||||
public String password;
|
||||
public String password = "";
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.openhab.binding.squeezebox.internal.SqueezeBoxStateDescriptionOptionsProvider;
|
||||
import org.openhab.binding.squeezebox.internal.config.SqueezeBoxPlayerConfig;
|
||||
@@ -276,7 +275,7 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
|
||||
squeezeBoxServerHandler.playUrl(mac, command.toString());
|
||||
break;
|
||||
case CHANNEL_SYNC:
|
||||
if (StringUtils.isBlank(command.toString())) {
|
||||
if (command.toString().isBlank()) {
|
||||
squeezeBoxServerHandler.unSyncPlayer(mac);
|
||||
} else {
|
||||
squeezeBoxServerHandler.syncPlayer(mac, command.toString());
|
||||
@@ -444,7 +443,7 @@ public class SqueezeBoxPlayerHandler extends BaseThingHandler implements Squeeze
|
||||
private RawType downloadImage(String mac, String url) {
|
||||
// Only get the image if this is my PlayerHandler instance
|
||||
if (isMe(mac)) {
|
||||
if (StringUtils.isNotEmpty(url)) {
|
||||
if (url != null && !url.isEmpty()) {
|
||||
String sanitizedUrl = sanitizeUrl(url);
|
||||
RawType image = IMAGE_CACHE.putIfAbsentAndGet(url, () -> {
|
||||
logger.debug("Trying to download the content of URL {}", sanitizedUrl);
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.squeezebox.internal.config.SqueezeBoxServerConfig;
|
||||
import org.openhab.binding.squeezebox.internal.dto.ButtonDTO;
|
||||
import org.openhab.binding.squeezebox.internal.dto.ButtonDTODeserializer;
|
||||
@@ -333,7 +332,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
||||
* Login to server
|
||||
*/
|
||||
public void login() {
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
if (userId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Create basic auth string for jsonrpc interface
|
||||
@@ -390,7 +389,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
||||
this.userId = config.userId;
|
||||
this.password = config.password;
|
||||
|
||||
if (StringUtils.isEmpty(this.host)) {
|
||||
if (host.isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "host is not set");
|
||||
return;
|
||||
}
|
||||
@@ -836,7 +835,7 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
||||
|
||||
private String constructCoverArtUrl(String mac, boolean coverart, String coverid, String artwork_url) {
|
||||
String hostAndPort;
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
if (!userId.isEmpty()) {
|
||||
hostAndPort = "http://" + encode(userId) + ":" + encode(password) + "@" + host + ":" + webport;
|
||||
} else {
|
||||
hostAndPort = "http://" + host + ":" + webport;
|
||||
|
||||
Reference in New Issue
Block a user