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,7 @@ import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.russound.internal.RussoundHandlerFactory;
|
||||
import org.openhab.binding.russound.internal.net.SocketChannelSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
@@ -148,7 +148,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
private void discoverControllers() {
|
||||
for (int c = 1; c < 7; c++) {
|
||||
final String type = sendAndGet("GET C[" + c + "].type", RSP_CONTROLLERNOTIFICATION, 3);
|
||||
if (StringUtils.isNotEmpty(type)) {
|
||||
if (type != null && !type.isEmpty()) {
|
||||
logger.debug("Controller #{} found - {}", c, type);
|
||||
|
||||
final ThingUID thingUID = new ThingUID(RioConstants.BRIDGE_TYPE_CONTROLLER,
|
||||
@@ -172,7 +172,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
private void discoverSources() {
|
||||
for (int s = 1; s < 9; s++) {
|
||||
final String type = sendAndGet("GET S[" + s + "].type", RSP_SRCNOTIFICATION, 3);
|
||||
if (StringUtils.isNotEmpty(type)) {
|
||||
if (type != null && !type.isEmpty()) {
|
||||
final String name = sendAndGet("GET S[" + s + "].name", RSP_SRCNOTIFICATION, 3);
|
||||
logger.debug("Source #{} - {}/{}", s, type, name);
|
||||
|
||||
@@ -181,8 +181,8 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
|
||||
final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
|
||||
.withProperty(RioSourceConfig.SOURCE, s).withBridge(sysHandler.getThing().getUID())
|
||||
.withLabel((StringUtils.isEmpty(name) || name.equalsIgnoreCase("null") ? "Source" : name) + " ("
|
||||
+ s + ")")
|
||||
.withLabel((name == null || name.isEmpty() || name.equalsIgnoreCase("null") ? "Source" : name)
|
||||
+ " (" + s + ")")
|
||||
.build();
|
||||
thingDiscovered(discoveryResult);
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
}
|
||||
for (int z = 1; z < 9; z++) {
|
||||
final String name = sendAndGet("GET C[" + c + "].Z[" + z + "].name", RSP_ZONENOTIFICATION, 4);
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
logger.debug("Controller #{}, Zone #{} found - {}", c, z, name);
|
||||
|
||||
final ThingUID thingUID = new ThingUID(RioConstants.THING_TYPE_ZONE, controllerUID, String.valueOf(z));
|
||||
@@ -232,8 +232,8 @@ public class RioSystemDeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
* @throws IllegalArgumentException if message is null or empty, if the pattern is null
|
||||
* @throws IllegalArgumentException if groupNum is less than 0
|
||||
*/
|
||||
private String sendAndGet(String message, Pattern respPattern, int groupNum) {
|
||||
if (StringUtils.isEmpty(message)) {
|
||||
private @Nullable String sendAndGet(String message, Pattern respPattern, int groupNum) {
|
||||
if (message == null || message.isEmpty()) {
|
||||
throw new IllegalArgumentException("message cannot be a null or empty string");
|
||||
}
|
||||
if (respPattern == null) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.net.util.SubnetUtils;
|
||||
import org.openhab.binding.russound.internal.net.SocketChannelSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
@@ -152,7 +151,7 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
|
||||
* @param ipAddress a possibly null, possibly empty ip address (null/empty addresses will be ignored)
|
||||
*/
|
||||
private void scanAddress(String ipAddress) {
|
||||
if (StringUtils.isEmpty(ipAddress)) {
|
||||
if (ipAddress == null || ipAddress.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
|
||||
continue;
|
||||
}
|
||||
final String type = resp.substring(13, resp.length() - 1);
|
||||
if (!StringUtils.isBlank(type)) {
|
||||
if (!type.isBlank()) {
|
||||
logger.debug("Found a RIO type #{}", type);
|
||||
addResult(ipAddress, type);
|
||||
break;
|
||||
@@ -202,10 +201,10 @@ public class RioSystemDiscovery extends AbstractDiscoveryService {
|
||||
* @throws IllegalArgumentException if ipaddress or type is null or empty
|
||||
*/
|
||||
private void addResult(String ipAddress, String type) {
|
||||
if (StringUtils.isEmpty(ipAddress)) {
|
||||
if (ipAddress == null || ipAddress.isEmpty()) {
|
||||
throw new IllegalArgumentException("ipAddress cannot be null or empty");
|
||||
}
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
if (type == null || type.isEmpty()) {
|
||||
throw new IllegalArgumentException("type cannot be null or empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.openhab.binding.russound.internal.rio;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
@@ -165,7 +164,7 @@ public abstract class AbstractBridgeHandler<E extends AbstractRioProtocol> exten
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("clazz cannot be null");
|
||||
}
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (channelId == null || channelId.isEmpty()) {
|
||||
throw new IllegalArgumentException("channelId cannot be null or empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.openhab.binding.russound.internal.rio;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
@@ -56,7 +55,7 @@ public abstract class AbstractRioHandlerCallback implements RioHandlerCallback {
|
||||
* @throws IllegalArgumentException if state is null
|
||||
*/
|
||||
protected void fireStateUpdated(String channelId, State state) {
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (channelId == null || channelId.isEmpty()) {
|
||||
throw new IllegalArgumentException("channelId cannot be null or empty)");
|
||||
}
|
||||
if (state == null) {
|
||||
|
||||
@@ -14,13 +14,14 @@ package org.openhab.binding.russound.internal.rio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.binding.russound.internal.rio.models.GsonUtilities;
|
||||
@@ -258,7 +259,7 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
|
||||
* @throws IllegalArgumentException if source is < 1 or > 8
|
||||
* @throws IllegalArgumentException if presetJson contains more than one preset
|
||||
*/
|
||||
public void setZonePresets(int controller, int zone, int source, String presetJson) {
|
||||
public void setZonePresets(int controller, int zone, int source, @Nullable String presetJson) {
|
||||
if (controller < 1 || controller > 6) {
|
||||
throw new IllegalArgumentException("Controller must be between 1 and 6");
|
||||
}
|
||||
@@ -271,7 +272,7 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
|
||||
throw new IllegalArgumentException("Source must be between 1 and 8");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(presetJson)) {
|
||||
if (presetJson == null || presetJson.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -299,11 +300,11 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
|
||||
|
||||
// re-retrieve to see if the save/delete worked (saving on a zone that's off - valid won't be set to
|
||||
// true)
|
||||
if (!StringUtils.equals(myPreset.getName(), presetName) || myPreset.isValid() != presetValid) {
|
||||
if (!Objects.equals(myPreset.getName(), presetName) || myPreset.isValid() != presetValid) {
|
||||
myPreset.setName(presetName);
|
||||
myPreset.setValid(presetValid);
|
||||
if (presetValid) {
|
||||
if (StringUtils.isEmpty(presetName)) {
|
||||
if (presetName == null || presetName.isEmpty()) {
|
||||
sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!savePreset " + presetId);
|
||||
} else {
|
||||
sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!savePreset \"" + presetName
|
||||
@@ -438,8 +439,8 @@ public class RioPresetsProtocol extends AbstractRioProtocol {
|
||||
* @param a possibly null, possibly empty response
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
public void responseReceived(@Nullable String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,14 @@ package org.openhab.binding.russound.internal.rio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.binding.russound.internal.rio.models.GsonUtilities;
|
||||
@@ -199,7 +200,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
|
||||
* @throws IllegalArgumentException if controller is < 1 or > 6
|
||||
* @throws IllegalArgumentException if zone is < 1 or > 8
|
||||
*/
|
||||
public void setSystemFavorites(int controller, int zone, String favJson) {
|
||||
public void setSystemFavorites(int controller, int zone, @Nullable String favJson) {
|
||||
if (controller < 1 || controller > 6) {
|
||||
throw new IllegalArgumentException("Controller must be between 1 and 6");
|
||||
}
|
||||
@@ -208,7 +209,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
|
||||
throw new IllegalArgumentException("Zone must be between 1 and 8");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(favJson)) {
|
||||
if (favJson == null || favJson.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
|
||||
} else {
|
||||
sendCommand("EVENT C[" + controller + "].Z[" + zone + "]!deleteSystemFavorite " + favId);
|
||||
}
|
||||
} else if (!StringUtils.equals(myFav.getName(), favName)) {
|
||||
} else if (!Objects.equals(myFav.getName(), favName)) {
|
||||
myFav.setName(favName);
|
||||
sendCommand("SET System.favorite[" + favId + "]." + FAV_NAME + "=\"" + favName + "\"");
|
||||
}
|
||||
@@ -311,8 +312,8 @@ public class RioSystemFavoritesProtocol extends AbstractRioProtocol {
|
||||
* @param a possibly null, possibly empty response
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
public void responseReceived(@Nullable String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.types.State;
|
||||
@@ -89,7 +88,7 @@ public class StatefulHandlerCallback implements RioHandlerCallback {
|
||||
*/
|
||||
@Override
|
||||
public void stateChanged(String channelId, State newState) {
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (channelId == null || channelId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,7 +116,7 @@ public class StatefulHandlerCallback implements RioHandlerCallback {
|
||||
* @param channelId the channel id to remove state
|
||||
*/
|
||||
public void removeState(String channelId) {
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (channelId == null || channelId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
state.remove(channelId);
|
||||
|
||||
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.controller;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
|
||||
@@ -155,8 +155,8 @@ class RioControllerProtocol extends AbstractRioProtocol {
|
||||
* @param a possibly null, possibly empty response
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
public void responseReceived(@Nullable String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ package org.openhab.binding.russound.internal.rio.models;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Simple model of a RIO Bank and it's attributes. Please note this class is used to serialize/deserialize to JSON.
|
||||
@@ -50,12 +50,12 @@ public class RioBank {
|
||||
* @param name a possibly null, possibly empty bank name (null or empty will result in a bank name of "Bank "+ id)
|
||||
* @throws IllegalArgumentException if id is < 1 or > 6
|
||||
*/
|
||||
public RioBank(int id, String name) {
|
||||
public RioBank(int id, @Nullable String name) {
|
||||
if (id < 1 || id > 6) {
|
||||
throw new IllegalArgumentException("Bank ID can only be between 1 and 6");
|
||||
}
|
||||
this.id = id;
|
||||
this.name.set(StringUtils.isEmpty(name) ? "Bank " + id : name);
|
||||
this.name.set(name == null || name.isEmpty() ? "Bank " + id : name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class RioBank {
|
||||
*
|
||||
* @param bankName a possibly null, possibly empty bank name
|
||||
*/
|
||||
public void setName(String bankName) {
|
||||
name.set(StringUtils.isEmpty(bankName) ? "Bank " + getId() : bankName);
|
||||
public void setName(@Nullable String bankName) {
|
||||
name.set(bankName == null || bankName.isEmpty() ? "Bank " + getId() : bankName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.models;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Simple model of a RIO Favorite (both system and zone) and it's attributes. Please note this class is used to
|
||||
@@ -59,18 +59,14 @@ public class RioFavorite {
|
||||
* @param name a possibly null, possibly empty favorite name
|
||||
* @throws IllegalArgumentException if id < 1 or > 32
|
||||
*/
|
||||
public RioFavorite(int id, boolean isValid, String name) {
|
||||
public RioFavorite(int id, boolean isValid, @Nullable String name) {
|
||||
if (id < 1 || id > 32) {
|
||||
throw new IllegalArgumentException("Favorite ID must be between 1 and 32");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = "Favorite " + id;
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.valid.set(isValid);
|
||||
this.name.set(name);
|
||||
this.name.set(name == null || name.isEmpty() ? "Favorite " + id : name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,8 +101,8 @@ public class RioFavorite {
|
||||
*
|
||||
* @param favName a possibly null, possibly empty favorite name
|
||||
*/
|
||||
public void setName(String favName) {
|
||||
name.set(StringUtils.isEmpty(favName) ? "Favorite " + getId() : favName);
|
||||
public void setName(@Nullable String favName) {
|
||||
name.set(favName == null || favName.isEmpty() ? "Favorite " + getId() : favName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ package org.openhab.binding.russound.internal.rio.models;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Simple model of a RIO Preset and it's attributes. Please note this class is used to
|
||||
@@ -59,18 +59,14 @@ public class RioPreset {
|
||||
* @param name a possibly null, possibly empty preset name
|
||||
* @throws IllegalArgumentException if id < 1 or > 32
|
||||
*/
|
||||
public RioPreset(int id, boolean valid, String name) {
|
||||
public RioPreset(int id, boolean valid, @Nullable String name) {
|
||||
if (id < 1 || id > 36) {
|
||||
throw new IllegalArgumentException("Preset ID can only be between 1 and 36");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = "Preset " + id;
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.valid.set(valid);
|
||||
this.name.set(name);
|
||||
this.name.set(name == null || name.isEmpty() ? "Preset " + id : name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +119,8 @@ public class RioPreset {
|
||||
*
|
||||
* @param presetName a possibly null, possibly empty preset name
|
||||
*/
|
||||
public void setName(String presetName) {
|
||||
name.set(StringUtils.isEmpty(presetName) ? "Preset " + getId() : presetName);
|
||||
public void setName(@Nullable String presetName) {
|
||||
name.set(presetName == null || presetName.isEmpty() ? "Preset " + getId() : presetName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractRioHandlerCallback;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractThingHandler;
|
||||
@@ -84,7 +83,7 @@ public class RioSourceHandler extends AbstractThingHandler<RioSourceProtocol> im
|
||||
@Override
|
||||
public String getName() {
|
||||
final String name = sourceName.get();
|
||||
return StringUtils.isEmpty(name) ? ("Source " + getId()) : name;
|
||||
return name == null || name.isEmpty() ? "Source " + getId() : name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,14 +15,14 @@ package org.openhab.binding.russound.internal.rio.source;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
@@ -367,7 +367,7 @@ class RioSourceProtocol extends AbstractRioProtocol {
|
||||
*/
|
||||
Runnable setBanks(String bankJson) {
|
||||
// If null or empty - simply return a do nothing runnable
|
||||
if (StringUtils.isEmpty(bankJson)) {
|
||||
if (bankJson == null || bankJson.isEmpty()) {
|
||||
return () -> {
|
||||
};
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class RioSourceProtocol extends AbstractRioProtocol {
|
||||
} else {
|
||||
final RioBank myBank = banks[bankId - 1];
|
||||
|
||||
if (!StringUtils.equals(myBank.getName(), bank.getName())) {
|
||||
if (!Objects.equals(myBank.getName(), bank.getName())) {
|
||||
myBank.setName(bank.getName());
|
||||
sendCommand(
|
||||
"SET S[" + source + "].B[" + bankId + "]." + BANK_NAME + "=\"" + bank.getName() + "\"");
|
||||
@@ -431,8 +431,8 @@ class RioSourceProtocol extends AbstractRioProtocol {
|
||||
* @throws IllegalArgumentException if channelID is null or empty
|
||||
*/
|
||||
private void handleMMChange(String channelId, String value) {
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
throw new NullArgumentException("channelId cannot be null or empty");
|
||||
if (channelId == null || channelId.isEmpty()) {
|
||||
throw new IllegalArgumentException("channelId cannot be null or empty");
|
||||
}
|
||||
|
||||
final AtomicInteger ai = mmSeqNbrs.get(channelId);
|
||||
@@ -688,8 +688,8 @@ class RioSourceProtocol extends AbstractRioProtocol {
|
||||
* @param a possibly null, possibly empty response
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
public void responseReceived(@Nullable String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
|
||||
@@ -245,8 +245,8 @@ class RioSystemProtocol extends AbstractRioProtocol {
|
||||
* @param a possibly null, possibly empty response
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
public void responseReceived(@Nullable String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractBridgeHandler;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractRioHandlerCallback;
|
||||
@@ -108,7 +107,7 @@ public class RioZoneHandler extends AbstractThingHandler<RioZoneProtocol>
|
||||
@Override
|
||||
public String getName() {
|
||||
final String name = zoneName.get();
|
||||
return StringUtils.isEmpty(name) ? ("Zone " + getId()) : name;
|
||||
return name == null || name.isEmpty() ? "Zone " + getId() : name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,11 +14,11 @@ package org.openhab.binding.russound.internal.rio.zone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.russound.internal.net.SocketSession;
|
||||
import org.openhab.binding.russound.internal.net.SocketSessionListener;
|
||||
import org.openhab.binding.russound.internal.rio.AbstractRioProtocol;
|
||||
@@ -529,7 +529,7 @@ class RioZoneProtocol extends AbstractRioProtocol
|
||||
* @return a non-null {@link Runnable} that should be run after the call
|
||||
*/
|
||||
Runnable setZoneFavorites(String favJson) {
|
||||
if (StringUtils.isEmpty(favJson)) {
|
||||
if (favJson.isEmpty()) {
|
||||
return () -> {
|
||||
};
|
||||
}
|
||||
@@ -550,7 +550,7 @@ class RioZoneProtocol extends AbstractRioProtocol
|
||||
final boolean favValid = fav.isValid();
|
||||
final String favName = fav.getName();
|
||||
|
||||
if (!StringUtils.equals(myFav.getName(), favName) || myFav.isValid() != favValid) {
|
||||
if (!Objects.equals(myFav.getName(), favName) || myFav.isValid() != favValid) {
|
||||
myFav.setName(favName);
|
||||
myFav.setValid(favValid);
|
||||
if (favValid) {
|
||||
@@ -923,7 +923,7 @@ class RioZoneProtocol extends AbstractRioProtocol
|
||||
*/
|
||||
@Override
|
||||
public void responseReceived(String response) {
|
||||
if (StringUtils.isEmpty(response)) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user