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.openhab.binding.ambientweather.internal.config.BridgeConfig;
*/
private boolean hasApplicationKey() {
String configApplicationKey = getConfigAs(BridgeConfig.class).applicationKey;
- if (StringUtils.isEmpty(configApplicationKey)) {
+ if (configApplicationKey == null || configApplicationKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing application key");
return false;
}
*/
private boolean hasApiKey() {
String configApiKey = getConfigAs(BridgeConfig.class).apiKey;
- if (StringUtils.isEmpty(configApiKey)) {
+ if (configApiKey == null || configApiKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing API key");
return false;
}
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.openhab.binding.ambientweather.internal.model.DeviceJson;
import org.openhab.binding.ambientweather.internal.model.EventDataGenericJson;
logger.debug("Listener: Data: {}", jsonData);
try {
EventDataGenericJson data = gson.fromJson(jsonData, EventDataGenericJson.class);
- if (StringUtils.isNotEmpty(data.macAddress)) {
- sendWeatherDataToHandler(data.macAddress, jsonData);
+ String macAddress = data == null ? null : data.macAddress;
+ if (macAddress != null && !macAddress.isEmpty()) {
+ sendWeatherDataToHandler(macAddress, jsonData);
}
} catch (JsonSyntaxException e) {
logger.info("Listener: Exception parsing subscribed event: {}", e.getMessage());
import javax.measure.quantity.Angle;
-import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.astro.internal.action.AstroActions;
import static java.util.Calendar.SECOND;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
-import static org.apache.commons.lang.time.DateUtils.truncatedEquals;
+import static org.apache.commons.lang3.time.DateUtils.truncatedEquals;
import static org.openhab.binding.astro.internal.AstroBindingConstants.*;
import static org.openhab.binding.astro.internal.util.DateTimeUtils.*;
import java.util.Date;
import java.util.regex.Pattern;
-import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.lang3.time.DateUtils;
import org.openhab.binding.astro.internal.config.AstroChannelConfig;
import org.openhab.binding.astro.internal.model.Range;
import org.slf4j.Logger;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
String username = configuration.user;
String password = configuration.password;
- if (StringUtils.isBlank(username)) {
+ if (username == null || username.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "username must not be empty");
return;
}
- if (StringUtils.isBlank(password)) {
+ if (password == null || password.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "password must not be empty");
return;
}
- if (StringUtils.isBlank(host)) {
+ if (host == null || host.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "hostname must not be empty");
return;
}
}
}
- if (StringUtils.isEmpty((value))) {
+ if (value == null || value.isEmpty()) {
continue;
}
*/
package org.openhab.binding.bigassfan.internal;
-import org.apache.commons.lang.StringUtils;
-
/**
* The {@link BigAssFanConfig} is responsible for storing the BigAssFan thing configuration.
*
}
public boolean isValid() {
- if (StringUtils.isBlank(label)) {
+ if (label == null || label.isBlank()) {
return false;
}
- if (StringUtils.isBlank(ipAddress)) {
+ if (ipAddress == null || ipAddress.isBlank()) {
return false;
}
- if (StringUtils.isBlank(macAddress)) {
+ if (macAddress == null || macAddress.isBlank()) {
return false;
}
return true;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.bigassfan.internal.BigAssFanConfig;
import org.openhab.binding.bigassfan.internal.utils.BigAssFanConverter;
import org.openhab.core.common.ThreadPoolManager;
}
private void processMessage(String incomingMessage) {
- if (StringUtils.isEmpty(incomingMessage)) {
+ if (incomingMessage == null || incomingMessage.isEmpty()) {
return;
}
private boolean isMe(String idFromDevice) {
// Check match on MAC address
- if (StringUtils.equalsIgnoreCase(idFromDevice, macAddress)) {
+ if (macAddress.equalsIgnoreCase(idFromDevice)) {
return true;
}
// Didn't match MAC address, check match for label
- if (StringUtils.equalsIgnoreCase(idFromDevice, label)) {
+ if (label.equalsIgnoreCase(idFromDevice)) {
return true;
}
return false;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import javax.measure.quantity.Power;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bluetooth.BluetoothDevice.ConnectionState;
if (device != null) {
BluetoothAdapter adapter = device.getAdapter();
String location = adapter.getLocation();
- if (location != null || StringUtils.isBlank(location)) {
+ if (location != null && !location.isBlank()) {
updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, new StringType(location));
} else {
updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, UnDefType.NULL);
*/
package org.openhab.binding.bluetooth;
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.openhab.core.types.StateOption;
import com.google.gson.annotations.Expose;
*/
package org.openhab.binding.bsblan.internal.api;
-import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
+import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.API_TIMEOUT;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
-import java.util.HashSet;
import java.util.Set;
+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.bsblan.internal.api.dto.BsbLanApiContentDTO;
}
public @Nullable BsbLanApiParameterQueryResponseDTO queryParameter(Integer parameterId) {
- Set<Integer> parameters = new HashSet<>();
-
- parameters.add(parameterId);
- return queryParameters(parameters);
+ return queryParameters(Set.of(parameterId));
}
public @Nullable BsbLanApiParameterQueryResponseDTO queryParameters(Set<Integer> parameterIds) {
// note: make the request even if parameterIds is empty as
// thing OFFLINE/ONLINE detection relies on a response
-
- String apiPath = String.format("/JQ=%s", StringUtils.join(parameterIds, ","));
+ String apiPath = String.format("/JQ=%s",
+ parameterIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
return makeRestCall(BsbLanApiParameterQueryResponseDTO.class, "GET", apiPath, null);
}
}
private String createApiBaseUrl() {
- final String host = StringUtils.trimToEmpty(bridgeConfig.host);
- final String username = StringUtils.trimToEmpty(bridgeConfig.username);
- final String password = StringUtils.trimToEmpty(bridgeConfig.password);
- final String passkey = StringUtils.trimToEmpty(bridgeConfig.passkey);
+ final String host = bridgeConfig.host == null ? "" : bridgeConfig.host.trim();
+ final String username = bridgeConfig.username == null ? "" : bridgeConfig.username.trim();
+ final String password = bridgeConfig.password == null ? "" : bridgeConfig.password.trim();
+ final String passkey = bridgeConfig.passkey == null ? "" : bridgeConfig.passkey.trim();
StringBuilder url = new StringBuilder();
url.append("http://");
- if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
+ if (!username.isBlank() && !password.isBlank()) {
url.append(username).append(":").append(password).append("@");
}
url.append(host);
if (bridgeConfig.port != 80) {
url.append(":").append(bridgeConfig.port);
}
- if (StringUtils.isNotBlank(passkey)) {
+ if (!passkey.isBlank()) {
url.append("/").append(passkey);
}
return url.toString();
if (request != null) {
String content = BsbLanApiContentConverter.toJson(request);
logger.trace("api request content: '{}'", content);
- if (StringUtils.isNotBlank(content)) {
+ if (!content.isBlank()) {
contentStream = new ByteArrayInputStream(content.getBytes(Charset.forName("UTF-8")));
contentType = "application/json";
}
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.stream.*;
+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.bsblan.internal.api.BsbLanApiCaller;
bridgeConfig = getConfigAs(BsbLanBridgeConfiguration.class);
// validate 'host' configuration
- if (StringUtils.isBlank(bridgeConfig.host)) {
+ String host = bridgeConfig.host;
+ if (host == null || host.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Parameter 'host' is mandatory and must be configured");
return;
BsbLanApiCaller apiCaller = new BsbLanApiCaller(bridgeConfig);
// refresh all parameters
- Set<Integer> parameterIds = things.stream().filter(thing -> thing instanceof BsbLanParameterHandler)
- .map(thing -> (BsbLanParameterHandler) thing).map(thing -> thing.getParameterId())
+ Set<Integer> parameterIds = things.stream() //
+ .filter(thing -> thing instanceof BsbLanParameterHandler) //
+ .map(thing -> (BsbLanParameterHandler) thing) //
+ .map(thing -> thing.getParameterId()) //
.collect(Collectors.toSet());
cachedParameterQueryResponse = apiCaller.queryParameters(parameterIds);
import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
+import org.openhab.binding.bsblan.internal.handler.BsbLanParameterHandler;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
}
private static State getStateForUnitChannel(BsbLanApiParameterDTO parameter) {
- String value = StringEscapeUtils.unescapeHtml(parameter.unit);
+ String value = StringEscapeUtils.unescapeHtml4(parameter.unit);
return new StringType(value);
}
/**
* Converts a Command back to a value which is sent to the BSB-LAN device afterwards.
- *
+ *
* @param channelId
* @param command
* @return null if conversion fails or channel is readonly.
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI;
import org.openhab.binding.buienradar.internal.buienradarapi.Prediction;
this.config = getConfigAs(BuienradarConfiguration.class);
boolean configValid = true;
- if (StringUtils.trimToNull(config.location) == null) {
+ if (config.location == null || config.location.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error-missing-location");
configValid = false;
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;
}
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);
}
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);
}
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);
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;
@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;
}
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);
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")
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;
break;
}
logger.trace("Received from {}: {}", config.getHost(), line);
- if (!StringUtils.isBlank(line)) {
+ if (!line.isBlank()) {
listener.receivedLine(line);
}
} catch (SocketTimeoutException e) {
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;
@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;
}
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
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.discovery.DiscoveryServiceManager;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
import org.openhab.binding.digitalstrom.internal.handler.CircuitHandler;
private ThingUID getDeviceUID(ThingTypeUID thingTypeUID, ThingUID thingUID, Configuration configuration,
ThingUID bridgeUID) {
- if (thingUID == null && StringUtils.isNotBlank((String) configuration.get(DEVICE_DSID))) {
- return new ThingUID(thingTypeUID, bridgeUID, configuration.get(DEVICE_DSID).toString());
+ String id = (String) configuration.get(DEVICE_DSID);
+ if (thingUID == null && id != null && !id.isBlank()) {
+ return new ThingUID(thingTypeUID, bridgeUID, id);
}
return thingUID;
}
return thingUID;
}
String dSID;
- if (StringUtils.isBlank((String) configuration.get(DS_ID))) {
+ String configValue = (String) configuration.get(DS_ID);
+ if (configValue == null || configValue.isBlank()) {
dSID = getDSSid(configuration);
if (dSID != null) {
configuration.put(DS_ID, dSID);
private String getDSSid(Configuration configuration) {
String dSID = null;
- if (StringUtils.isNotBlank((String) configuration.get(HOST))) {
- String host = configuration.get(HOST).toString();
+ String hostConfigValue = (String) configuration.get(HOST);
+ if (hostConfigValue != null && !hostConfigValue.isBlank()) {
+ String host = hostConfigValue;
String applicationToken = null;
String user = null;
String pw = null;
- if (StringUtils.isNotBlank((String) configuration.get(APPLICATION_TOKEN))) {
+ String atConfigValue = (String) configuration.get(APPLICATION_TOKEN);
+ if (atConfigValue != null && !atConfigValue.isBlank()) {
applicationToken = configuration.get(APPLICATION_TOKEN).toString();
}
}
private boolean checkUserPassword(Configuration configuration) {
- return StringUtils.isNotBlank((String) configuration.get(USER_NAME))
- && StringUtils.isNotBlank((String) configuration.get(PASSWORD));
+ String userName = (String) configuration.get(USER_NAME);
+ String password = (String) configuration.get(PASSWORD);
+ return userName != null && !userName.isBlank() && password != null && !password.isBlank();
}
@Override
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.GeneralDeviceInformation;
+import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.OutputModeEnum;
import org.openhab.binding.digitalstrom.internal.providers.DsDeviceThingTypeProvider;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
+import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.slf4j.Logger;
if (thingUID != null) {
Map<String, Object> properties = new HashMap<>(1);
properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue());
- String deviceName = null;
- if (StringUtils.isNotBlank(device.getName())) {
- deviceName = device.getName();
- } else {
+ String deviceName = device.getName();
+ if (deviceName == null || deviceName.isBlank()) {
// if no name is set, the dSID will be used as name
deviceName = device.getDSID().getValue();
}
import java.util.HashSet;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
+import org.openhab.binding.digitalstrom.internal.handler.ZoneTemperatureControlHandler;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
Map<String, Object> properties = new HashMap<>();
properties.put(DigitalSTROMBindingConstants.ZONE_ID, tempControlStatus.getZoneID());
String zoneName = tempControlStatus.getZoneName();
- if (StringUtils.isBlank(zoneName)) {
+ if (zoneName == null || zoneName.isBlank()) {
zoneName = tempControlStatus.getZoneID().toString();
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
if (versions != null) {
properties.putAll(versions);
}
- if (StringUtils.isBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT))
- && StringUtils.isNotBlank(config.getCert())) {
- properties.put(DigitalSTROMBindingConstants.SERVER_CERT, config.getCert());
+ String certProperty = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
+ String certConfig = config.getCert();
+ if ((certProperty == null || certProperty.isBlank()) && (certConfig != null && !certConfig.isBlank())) {
+ properties.put(DigitalSTROMBindingConstants.SERVER_CERT, certConfig);
}
logger.debug("update properties");
updateProperties(properties);
}
private boolean checkLoginConfig(Config config) {
- if ((StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword()))
- || StringUtils.isNotBlank(config.getAppToken())) {
+ String userName = config.getUserName();
+ String password = config.getPassword();
+ String appToken = config.getAppToken();
+
+ if (((userName != null && !userName.isBlank()) && (password != null && !password.isBlank()))
+ || (appToken != null && !appToken.isBlank())) {
return true;
}
onConnectionStateChange(CONNECTION_LOST, NO_USER_PASSWORD);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, excText + " have to be a number.");
return null;
}
- if (StringUtils.isNotBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT))) {
- config.setCert(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT));
+ String servertCert = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
+ if (servertCert != null && !servertCert.isBlank()) {
+ config.setCert(servertCert);
}
return config;
}
this.config = new Config();
}
// load and check connection and authorization data
- if (StringUtils.isNotBlank((String) thingConfig.get(HOST))) {
- config.setHost(thingConfig.get(HOST).toString());
+ String host = (String) thingConfig.get(HOST);
+ if (host != null && !host.isBlank()) {
+ config.setHost(host);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"The connection to the digitalSTROM-Server can't established, because the host address is missing. Please set the host address.");
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.listener.DeviceStatusListener;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
@Override
public void initialize() {
logger.debug("Initializing CircuitHandler.");
- if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) {
- dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString();
+ dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
+ if (dSID != null && !dSID.isBlank()) {
final Bridge bridge = getBridge();
if (bridge != null) {
bridgeStatusChanged(bridge.getStatusInfo());
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@Override
public void initialize() {
logger.debug("Initializing DeviceHandler.");
- if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) {
- dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString();
+ dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
+ if (dSID != null && !dSID.isBlank()) {
final Bridge bridge = getBridge();
if (bridge != null) {
bridgeStatusChanged(bridge.getStatusInfo());
import java.net.HttpURLConnection;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
import org.openhab.binding.digitalstrom.internal.lib.listener.ConnectionListener;
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
@Override
public String getNewSessionToken() {
if (this.genAppToken) {
- if (StringUtils.isNotBlank(config.getAppToken())) {
- sessionToken = this.digitalSTROMClient.loginApplication(config.getAppToken());
+ String token = config.getAppToken();
+ if (token != null && !token.isBlank()) {
+ sessionToken = this.digitalSTROMClient.loginApplication(token);
} else if (codeIsAuthentificationFaild()) {
onNotAuthenticated();
}
private void onNotAuthenticated() {
String applicationToken = null;
boolean isAuthenticated = false;
- if (StringUtils.isNotBlank(config.getAppToken())) {
- sessionToken = digitalSTROMClient.loginApplication(config.getAppToken());
+ String token = config.getAppToken();
+ if (token != null && !token.isBlank()) {
+ sessionToken = digitalSTROMClient.loginApplication(token);
if (sessionToken != null) {
isAuthenticated = true;
} else {
logger.debug(
"no application-token for application {} found, generate a application-token {}",
config.getApplicationName(), applicationToken);
- if (StringUtils.isNotBlank(applicationToken)) {
+ if (applicationToken != null && !applicationToken.isBlank()) {
// enable applicationToken
if (!digitalSTROMClient.enableApplicationToken(applicationToken,
digitalSTROMClient.login(config.getUserName(), config.getPassword()))) {
}
private boolean checkUserPassword() {
- if (StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword())) {
- return true;
- }
- return false;
+ String userName = config.getUserName();
+ String password = config.getPassword();
+ return userName != null && !userName.isBlank() && password != null && !password.isBlank();
}
/**
@Override
public boolean removeApplicationToken() {
- if (StringUtils.isNotBlank(config.getAppToken())) {
- return digitalSTROMClient.revokeToken(config.getAppToken(), null);
+ String token = config.getAppToken();
+ if (token != null && !token.isBlank()) {
+ return digitalSTROMClient.revokeToken(token, null);
}
return true;
}
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseSensorValues;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.AssignedSensors;
}
private boolean checkRequiredZone(Integer zoneID, String zoneName) {
- return zoneID != null && zoneID > -1 || StringUtils.isNotBlank(zoneName);
+ return zoneID != null && zoneID > -1 || (zoneName != null && !zoneName.isBlank());
}
private boolean checkRequiredDevice(DSID dsid, String dSUID, String name) {
- return StringUtils.isNotBlank(SimpleRequestBuilder.objectToString(dsid)) || StringUtils.isNotBlank(name)
- || StringUtils.isNotBlank(dSUID);
+ String objectString = SimpleRequestBuilder.objectToString(dsid);
+ return (objectString != null && !objectString.isBlank()) || (name != null && !name.isBlank())
+ || (dSUID != null && !dSUID.isBlank());
}
@Override
@Override
public boolean subscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
int readTimeout) {
- if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
+ if ((name != null && !name.isBlank()) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
String response;
response = transport.execute(
SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.SUBSCRIBE)
@Override
public boolean unsubscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
int readTimeout) {
- if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
+ if (name != null && !name.isBlank() && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
String response;
response = transport.execute(
SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.UNSUBSCRIBE)
@Override
public String loginApplication(String loginToken) {
- if (StringUtils.isNotBlank(loginToken)) {
+ if (loginToken != null && !loginToken.isBlank()) {
String response = transport.execute(SimpleRequestBuilder.buildNewRequest(InterfaceKeys.JSON)
.addRequestClass(ClassKeys.SYSTEM).addFunction(FunctionKeys.LOGIN_APPLICATION)
.addParameter(ParameterKeys.LOGIN_TOKEN, loginToken).buildRequestString());
import javax.net.ssl.X509TrustManager;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport;
if (config != null) {
cert = config.getCert();
logger.debug("generate SSLcontext from config cert");
- if (StringUtils.isNotBlank(cert)) {
+ if (cert != null && !cert.isBlank()) {
sslSocketFactory = generateSSLContextFromPEMCertString(cert);
} else {
- if (StringUtils.isNotBlank(config.getTrustCertPath())) {
+ String trustCertPath = config.getTrustCertPath();
+ if (trustCertPath != null && !trustCertPath.isBlank()) {
logger.debug("generate SSLcontext from config cert path");
- cert = readPEMCertificateStringFromFile(config.getTrustCertPath());
- if (StringUtils.isNotBlank(cert)) {
+ cert = readPEMCertificateStringFromFile(trustCertPath);
+ if (cert != null && !cert.isBlank()) {
sslSocketFactory = generateSSLContextFromPEMCertString(cert);
}
} else {
private HttpsURLConnection getConnection(String request, int connectTimeout, int readTimeout) throws IOException {
String correctedRequest = request;
- if (StringUtils.isNotBlank(correctedRequest)) {
+ if (correctedRequest != null && !correctedRequest.isBlank()) {
correctedRequest = fixRequest(correctedRequest);
URL url = new URL(this.uri + correctedRequest);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
}
private String readPEMCertificateStringFromFile(String path) {
- if (StringUtils.isBlank(path)) {
+ if (path == null || path.isBlank()) {
logger.error("Path is empty.");
} else {
File dssCert = new File(path);
@Override
public String writePEMCertFile(String path) {
- String correctedPath = StringUtils.trimToEmpty(path);
+ String correctedPath = path == null ? "" : path.trim();
File certFilePath;
- if (StringUtils.isNotBlank(correctedPath)) {
+ if (!correctedPath.isBlank()) {
certFilePath = new File(correctedPath);
boolean pathExists = certFilePath.exists();
if (!pathExists) {
}
private SSLSocketFactory generateSSLContextFromPEMCertString(String pemCert) {
- if (StringUtils.isNotBlank(pemCert) && pemCert.startsWith(BEGIN_CERT)) {
+ if (pemCert != null && !pemCert.isBlank() && pemCert.startsWith(BEGIN_CERT)) {
try {
InputStream certInputStream = IOUtils.toInputStream(pemCert);
final X509Certificate trustedCert = (X509Certificate) CertificateFactory.getInstance("X.509")
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.commons.lang.NullArgumentException;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ExeptionConstants;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.InterfaceKeys;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ParameterKeys;
* @return simpleRequestBuilder with chosen interface
* @throws NullArgumentException if the interfaceKey is null
*/
- public static SimpleRequestBuilder buildNewRequest(String interfaceKey) throws NullArgumentException {
+ public static SimpleRequestBuilder buildNewRequest(String interfaceKey) throws IllegalArgumentException {
if (builder == null) {
builder = new SimpleRequestBuilder();
}
* @throws IllegalArgumentException if a requestClass is already chosen
* @throws NullArgumentException if the requestClassKey is null
*/
- public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey)
- throws NullArgumentException, IllegalArgumentException {
+ public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey) throws IllegalArgumentException {
return buildNewRequest(InterfaceKeys.JSON).addRequestClass(requestClassKey);
}
private SimpleRequestBuilder buildNewRequestInt(String interfaceKey) {
if (interfaceKey == null) {
- throw new NullArgumentException("interfaceKey");
+ throw new IllegalArgumentException("interfaceKey is null");
}
request = "/" + interfaceKey + "/";
classIsChosen = false;
* @throws IllegalArgumentException if a requestClass is already chosen
* @throws NullArgumentException if the requestClassKey is null
*/
- public SimpleRequestBuilder addRequestClass(String requestClassKey)
- throws IllegalArgumentException, NullArgumentException {
+ public SimpleRequestBuilder addRequestClass(String requestClassKey) throws IllegalArgumentException {
return builder.addRequestClassInt(requestClassKey);
}
if (!classIsChosen) {
throw new IllegalArgumentException(ExeptionConstants.CLASS_ALREADY_ADDED);
} else {
- throw new NullArgumentException("requestClassKey");
+ throw new IllegalArgumentException("requestClassKey is null");
}
}
return this;
* @throws IllegalArgumentException if a function is already chosen
* @throws NullArgumentException if the functionKey is null
*/
- public SimpleRequestBuilder addFunction(String functionKey) throws IllegalArgumentException, NullArgumentException {
+ public SimpleRequestBuilder addFunction(String functionKey) throws IllegalArgumentException {
return builder.addFunctionInt(functionKey);
}
functionIsChosen = true;
request = request + functionKey;
} else {
- throw new NullArgumentException("functionKey");
+ throw new IllegalArgumentException("functionKey is null");
}
} else {
throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED);
* @throws NullArgumentException if the parameterKey is null
*/
public SimpleRequestBuilder addParameter(String parameterKey, String parameterValue)
- throws IllegalArgumentException, NullArgumentException {
+ throws IllegalArgumentException {
return builder.addParameterInt(parameterKey, parameterValue);
}
* @throws NullArgumentException if the parameterKey is null
*/
public SimpleRequestBuilder addDefaultZoneParameter(String sessionToken, Integer zoneID, String zoneName)
- throws IllegalArgumentException, NullArgumentException {
+ throws IllegalArgumentException {
return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.ID, objectToString(zoneID))
.addParameter(ParameterKeys.NAME, zoneName);
}
* @throws NullArgumentException if the parameterKey is null
*/
public SimpleRequestBuilder addDefaultGroupParameter(String sessionToken, Short groupID, String groupName)
- throws IllegalArgumentException, NullArgumentException {
+ throws IllegalArgumentException {
return addParameter(ParameterKeys.TOKEN, sessionToken)
.addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
.addParameter(ParameterKeys.GROUP_NAME, groupName);
* @throws NullArgumentException if the parameterKey is null
*/
public SimpleRequestBuilder addDefaultZoneGroupParameter(String sessionToken, Integer zoneID, String zoneName,
- Short groupID, String groupName) throws IllegalArgumentException, NullArgumentException {
+ Short groupID, String groupName) throws IllegalArgumentException {
return addDefaultZoneParameter(sessionToken, zoneID, zoneName)
.addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
.addParameter(ParameterKeys.GROUP_NAME, groupName);
* @throws NullArgumentException if the parameterKey is null
*/
public SimpleRequestBuilder addDefaultDeviceParameter(String sessionToken, DSID dsid, String dSUID, String name)
- throws IllegalArgumentException, NullArgumentException {
+ throws IllegalArgumentException {
return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.DSID, objectToString(dsid))
.addParameter(ParameterKeys.DSUID, dSUID).addParameter(ParameterKeys.NAME, name);
}
private SimpleRequestBuilder addParameterInt(String parameterKey, String parameterValue) {
if (allRight()) {
if (parameterKey == null) {
- throw new NullArgumentException("parameterKey");
+ throw new IllegalArgumentException("parameterKey is null");
}
if (parameterValue != null) {
if (!parameterIsAdded) {
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.config.Config;
short sceneID = Short.parseShort((String) key
.subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length()));
sceneSave = propertries.get(key);
- if (StringUtils.isNotBlank(sceneSave)) {
+ if (sceneSave != null && !sceneSave.isBlank()) {
logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid,
key);
String[] sceneParm = sceneSave.replace(" ", "").split(",");
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.lib.listener.SceneStatusListener;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
import org.openhab.binding.digitalstrom.internal.lib.structure.scene.constants.SceneTypes;
this.zoneID = zoneID;
}
this.internalSceneID = this.zoneID + "-" + this.groupID + "-" + this.sceneID;
- if (StringUtils.isBlank(sceneName)) {
+ if (sceneName == null || sceneName.isBlank()) {
this.sceneName = this.internalSceneID;
} else {
this.sceneName = sceneName;
package org.openhab.binding.digitalstrom.internal.providers;
import java.util.Locale;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.i18n.TranslationProvider;
import org.osgi.framework.Bundle;
import org.osgi.service.component.ComponentContext;
* @return key
*/
public static String buildIdentifier(Object... parts) {
- return StringUtils.join(parts, SEPERATOR).toLowerCase();
+ return Stream.of(parts) //
+ .map(Object::toString) //
+ .map(String::toLowerCase) //
+ .collect(Collectors.joining(SEPERATOR));
}
}
import java.util.Set;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
logger.debug("EcobeeAuth: Got null authorize response from Ecobee API");
setState(EcobeeAuthState.NEED_PIN);
} else {
- if (StringUtils.isNotEmpty(authResponse.error)) {
- throw new EcobeeAuthException(authResponse.error + ": " + authResponse.errorDescription);
+ String error = authResponse.error;
+ if (error != null && !error.isEmpty()) {
+ throw new EcobeeAuthException(error + ": " + authResponse.errorDescription);
}
code = authResponse.code;
writeLogMessage(authResponse.pin, authResponse.expiresIn);
setState(isPinExpired() ? EcobeeAuthState.NEED_PIN : EcobeeAuthState.NEED_TOKEN);
return;
}
- if (StringUtils.isNotEmpty(tokenResponse.error)) {
- throw new EcobeeAuthException(tokenResponse.error + ": " + tokenResponse.errorDescription);
+ String error = tokenResponse.error;
+ if (error != null && !error.isEmpty()) {
+ throw new EcobeeAuthException(error + ": " + tokenResponse.errorDescription);
}
AccessTokenResponse accessTokenResponse = new AccessTokenResponse();
accessTokenResponse.setRefreshToken(tokenResponse.refreshToken);
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.text.WordUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration;
import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO;
import javax.measure.Unit;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.text.WordUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ecobee.internal.action.EcobeeActions;
import java.util.List;
import java.util.TooManyListenersException;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPort;
import org.openhab.core.io.transport.serial.SerialPortEvent;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.util.UrlEncoded;
} catch (ParserConfigurationException e) {
logger.warn("Failed setting parser features against XXE attacks!", e);
}
- if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
+ if (user != null && !user.isEmpty() && password != null && !password.isEmpty()) {
this.host = "http://" + user + ":" + password + "@" + host;
} else {
this.host = "http://" + host;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
-import org.apache.commons.lang3.NotImplementedException;
import org.openhab.binding.enocean.internal.config.EnOceanBaseConfig;
import org.openhab.binding.enocean.internal.eep.EEP;
import org.openhab.binding.enocean.internal.eep.EEPFactory;
}
protected void sendRequestResponse() {
- throw new NotImplementedException("Sensor cannot send responses");
+ throw new UnsupportedOperationException("Sensor cannot send responses");
}
@Override
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;
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;
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;
*/
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");
}
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;
}
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:
*/
package org.openhab.binding.evohome.internal.handler;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.evohome.internal.api.models.v2.response.Locations;
import org.openhab.binding.evohome.internal.configuration.EvohomeThingConfiguration;
import org.openhab.core.thing.Bridge;
if (configuration == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Configuration is missing or corrupted");
- } else if (StringUtils.isEmpty(configuration.id)) {
+ } else if (configuration.id == null || configuration.id.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Id not configured");
}
}
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.evohome.internal.RunnableWithTimeout;
import org.openhab.binding.evohome.internal.api.EvohomeApiClient;
if (configuration == null) {
errorMessage = "Configuration is missing or corrupted";
- } else if (StringUtils.isEmpty(configuration.username)) {
+ } else if (configuration.username == null || configuration.username.isEmpty()) {
errorMessage = "Username not configured";
- } else if (StringUtils.isEmpty(configuration.password)) {
+ } else if (configuration.password == null || configuration.password.isEmpty()) {
errorMessage = "Password not configured";
} else {
return true;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-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.openhab.binding.exec.internal.ExecWhitelistWatchService;
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;
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;
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;
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'");
}
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(
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");
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;
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;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.thing.Bridge;
boolean validConfig = true;
String errorMsg = null;
- if (StringUtils.trimToNull(config.hostname) == null) {
+
+ String hostname = config.hostname;
+ if (hostname == null || hostname.isBlank()) {
errorMsg = "Parameter 'hostname' is mandatory and must be configured";
validConfig = false;
}
+
if (config.refreshInterval != null && config.refreshInterval <= 0) {
errorMsg = "Parameter 'refresh' must be at least 1 second";
validConfig = false;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.fronius.internal.FroniusBaseDeviceConfiguration;
import org.openhab.binding.fronius.internal.FroniusBindingConstants;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
*/
package org.openhab.binding.fronius.internal.handler;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.fronius.internal.FroniusBaseDeviceConfiguration;
import org.openhab.binding.fronius.internal.FroniusBindingConstants;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
import java.math.BigDecimal;
import java.util.concurrent.ScheduledFuture;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.fsinternetradio.internal.radio.FrontierSiliconRadio;
import org.openhab.core.library.types.DecimalType;
final BigDecimal port = (BigDecimal) getThing().getConfiguration().get(CONFIG_PROPERTY_PORT);
final String pin = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_PIN);
- if (ip == null || StringUtils.isEmpty(pin) || port.intValue() == 0) {
+ if (ip == null || pin == null || pin.isEmpty() || port.intValue() == 0) {
// configuration incomplete
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Configuration incomplete");
} else {
import java.io.IOException;
import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.servlet.ServletHolder;
BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString());
String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.toString());
- if (ip == null || port.compareTo(BigDecimal.ZERO) == 0 || StringUtils.isEmpty(pin)) {
+ if (ip == null || port.compareTo(BigDecimal.ZERO) == 0 || pin == null || pin.isEmpty()) {
return false;
}
return true;
import java.util.Dictionary;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.apache.ftpserver.DataConnectionConfigurationFactory;
import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
if (properties.get("port") != null) {
String strPort = properties.get("port").toString();
- if (StringUtils.isNotEmpty(strPort)) {
+ if (!strPort.isEmpty()) {
try {
port = Integer.valueOf(strPort);
} catch (NumberFormatException e) {
if (properties.get("idleTimeout") != null) {
String strIdleTimeout = properties.get("idleTimeout").toString();
- if (StringUtils.isNotEmpty(strIdleTimeout)) {
+ if (!strIdleTimeout.isEmpty()) {
try {
idleTimeout = Integer.valueOf(strIdleTimeout);
} catch (NumberFormatException e) {
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
import org.openhab.binding.globalcache.internal.command.CommandGetstate;
}
String mapFile = (String) thing.getConfiguration().get(THING_CONFIG_MAP_FILENAME);
- if (StringUtils.isEmpty(mapFile)) {
+ if (mapFile == null || mapFile.isEmpty()) {
logger.warn("MAP file is not defined in configuration of thing {}", thingID());
return null;
}
String code;
try {
code = transformService.transform(mapFile, command.toString());
-
} catch (TransformationException e) {
logger.error("Failed to transform {} for thing {} using map file '{}', exception={}", command, thingID(),
mapFile, e.getMessage());
return null;
}
- if (StringUtils.isEmpty(code)) {
+ if (code == null || code.isEmpty()) {
logger.warn("No entry for {} in map file '{}' for thing {}", command, mapFile, thingID());
return null;
}
private String getIPAddress() {
String ipAddress = ((GlobalCacheHandler) thing.getHandler()).getIP();
- if (StringUtils.isEmpty(ipAddress)) {
+ if (ipAddress == null || ipAddress.isEmpty()) {
logger.debug("Handler for thing {} could not get IP address from config", thingID());
markThingOfflineWithError(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "IP address not set");
}
if (Boolean.TRUE.equals(enableTwoWay)) {
// Get the end of message delimiter from the config, URL decode it, and convert it to a byte array
String endOfMessageString = (String) thing.getConfiguration().get(endOfMessageDelimiterConfig);
- if (StringUtils.isNotEmpty(endOfMessageString)) {
+ if (endOfMessageString != null && !endOfMessageString.isEmpty()) {
logger.debug("End of message is {} for thing {} {}", endOfMessageString, thingID(), serialDevice);
byte[] endOfMessage;
try {
import javax.measure.quantity.ElectricCurrent;
import javax.measure.quantity.Energy;
-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;
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.openhab.binding.harmonyhub.internal.HarmonyHubHandlerFactory;
// earlier versions required a name and used network discovery to find the hub and retrieve the host,
// this section is to not break that and also update older configurations to use the host configuration
// option instead of name
- if (StringUtils.isBlank(host)) {
+ if (host == null || host.isBlank()) {
host = getThing().getProperties().get(HUB_PROPERTY_HOST);
- if (StringUtils.isNotBlank(host)) {
+ if (host != null && !host.isBlank()) {
Configuration genericConfig = getConfig();
genericConfig.put(HUB_PROPERTY_HOST, host);
updateConfiguration(genericConfig);
*/
package org.openhab.binding.hdanywhere.internal.handler;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
String content = "{tag:ptn}";
InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
- if (isNotBlank(httpMethod) && isNotBlank(url)) {
- String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
- response = response.trim();
- response = response.substring(1, response.length() - 1);
+ String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
+ response = response.trim();
+ response = response.substring(1, response.length() - 1);
- if (response != null) {
- updateStatus(ThingStatus.ONLINE);
+ if (response != null) {
+ updateStatus(ThingStatus.ONLINE);
- java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
- }.getType();
- Map<String, String> map = gson.fromJson(response, type);
+ java.lang.reflect.Type type = new TypeToken<Map<String, String>>() {
+ }.getType();
+ Map<String, String> map = gson.fromJson(response, type);
- String inputChannel = map.get("Inputchannel");
+ String inputChannel = map.get("Inputchannel");
- for (int i = 0; i < numberOfPorts; i++) {
- DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
- updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
- }
- } else {
- updateStatus(ThingStatus.OFFLINE);
+ for (int i = 0; i < numberOfPorts; i++) {
+ DecimalType decimalType = new DecimalType(String.valueOf(inputChannel.charAt(i)));
+ updateState(new ChannelUID(getThing().getUID(), Port.get(i + 1).channelID()), decimalType);
}
+ } else {
+ updateStatus(ThingStatus.OFFLINE);
}
} catch (Exception e) {
logger.debug("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
*/
package org.openhab.binding.hdanywhere.internal.handler;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
import java.io.IOException;
import java.math.BigDecimal;
import java.util.concurrent.ScheduledFuture;
String httpMethod = "GET";
String url = "http://" + host + "/status_show.shtml";
- if (isNotBlank(httpMethod) && isNotBlank(url)) {
- String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
+ String response = HttpUtil.executeUrl(httpMethod, url, null, null, null, timeout);
- if (response != null) {
- updateStatus(ThingStatus.ONLINE);
+ if (response != null) {
+ updateStatus(ThingStatus.ONLINE);
- for (int i = 1; i <= numberOfPorts; i++) {
- Pattern p = Pattern.compile("var out" + i + "var = (.*);");
- Matcher m = p.matcher(response);
+ for (int i = 1; i <= numberOfPorts; i++) {
+ Pattern p = Pattern.compile("var out" + i + "var = (.*);");
+ Matcher m = p.matcher(response);
- while (m.find()) {
- DecimalType decimalType = new DecimalType(m.group(1));
- updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
- }
+ while (m.find()) {
+ DecimalType decimalType = new DecimalType(m.group(1));
+ updateState(new ChannelUID(getThing().getUID(), Port.get(i).channelID()), decimalType);
}
- } else {
- updateStatus(ThingStatus.OFFLINE);
}
+ } else {
+ updateStatus(ThingStatus.OFFLINE);
}
} catch (Exception e) {
logger.warn("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
import static org.openhab.binding.heos.internal.HeosBindingConstants.*;
import static org.openhab.binding.heos.internal.handler.FutureUtil.cancel;
-import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.GROUP;
-import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.PLAYER;
+import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.*;
import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*;
+import static org.openhab.binding.heos.internal.resources.HeosConstants.*;
import static org.openhab.core.thing.ThingStatus.*;
import java.io.IOException;
import javax.measure.quantity.Time;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.heos.internal.HeosChannelHandlerFactory;
import org.openhab.binding.heos.internal.exception.HeosFunctionalException;
import org.openhab.binding.heos.internal.exception.HeosNotConnectedException;
import org.openhab.binding.heos.internal.exception.HeosNotFoundException;
-import org.openhab.binding.heos.internal.json.dto.*;
+import org.openhab.binding.heos.internal.json.dto.HeosCommandTuple;
+import org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute;
+import org.openhab.binding.heos.internal.json.dto.HeosError;
+import org.openhab.binding.heos.internal.json.dto.HeosEvent;
+import org.openhab.binding.heos.internal.json.dto.HeosEventObject;
+import org.openhab.binding.heos.internal.json.dto.HeosObject;
+import org.openhab.binding.heos.internal.json.dto.HeosResponseObject;
import org.openhab.binding.heos.internal.json.payload.Media;
import org.openhab.binding.heos.internal.json.payload.Player;
import org.openhab.binding.heos.internal.resources.HeosEventListener;
import org.openhab.binding.heos.internal.resources.Telnet.ReadException;
import org.openhab.core.io.net.http.HttpUtil;
-import org.openhab.core.library.types.*;
+import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.PlayPauseType;
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.types.RawType;
+import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.Units;
-import org.openhab.core.thing.*;
+import org.openhab.core.thing.Bridge;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
+import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
}
private void handleImageUrl(Media info) {
- if (StringUtils.isNotBlank(info.imageUrl)) {
+ String imageUrl = info.imageUrl;
+ if (imageUrl != null && !imageUrl.isBlank()) {
try {
- URL url = new URL(info.imageUrl); // checks if String is proper URL
+ URL url = new URL(imageUrl); // checks if String is proper URL
RawType cover = HttpUtil.downloadImage(url.toString());
if (cover != null) {
updateState(CH_ID_COVER, cover);
return;
}
} catch (MalformedURLException e) {
- logger.debug("Cover can't be loaded. No proper URL: {}", info.imageUrl, e);
+ logger.debug("Cover can't be loaded. No proper URL: {}", imageUrl, e);
}
}
updateState(CH_ID_COVER, UnDefType.NULL);
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
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.openhab.binding.hydrawise.internal.api.HydrawiseAuthenticationException;
updateGroupState(group, CHANNEL_ZONE_TYPE, new DecimalType(r.type));
updateGroupState(group, CHANNEL_ZONE_TIME,
r.runTimeSeconds != null ? new DecimalType(r.runTimeSeconds) : UnDefType.UNDEF);
- if (StringUtils.isNotBlank(r.icon)) {
- updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + r.icon));
+ String icon = r.icon;
+ if (icon != null && !icon.isBlank()) {
+ updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + icon));
}
if (r.time >= MAX_RUN_TIME) {
updateGroupState(group, CHANNEL_ZONE_NEXT_RUN_TIME_TIME, UnDefType.UNDEF);
import javax.measure.Unit;
import javax.measure.quantity.Temperature;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
String confSerialId = configuration.serialId;
String confApiKey = configuration.apiKey;
- if (StringUtils.isNotBlank(confApiKey)) {
+ if (confApiKey != null && !confApiKey.isBlank()) {
this.apiKey = confApiKey;
} else {
this.apiKey = DEFAULT_API_KEY;
return;
}
- if (StringUtils.isNotBlank(confSerialId)) {
+ if (confSerialId != null && !confSerialId.isBlank()) {
serialNumber = confSerialId.replaceAll("[^a-zA-Z0-9]", "").toLowerCase();
if (!Arrays.stream(devices).anyMatch(device -> device.getSerialNumber().equals(serialNumber))) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
*/
private State toState(String name, @Nullable String type, @Nullable String value) {
try {
- // @nullable checker does not recognize isBlank as checking null here, so must use == null to make happy
- if (value == null || StringUtils.isBlank(value)) {
+ if (value == null || value.isBlank()) {
return UnDefType.UNDEF;
}
import java.util.Set;
import java.util.function.Predicate;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.ihc.internal.config.ChannelParams;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.core.config.core.Configuration;
private static String createDescription(String name1, String name2, String name3, String name4) {
String description = "";
- if (StringUtils.isNotEmpty(name1)) {
+ if (name1 != null && !name1.isEmpty()) {
description = name1;
}
- if (StringUtils.isNotEmpty(name2)) {
+ if (name2 != null && !name2.isEmpty()) {
description += String.format(" - %s", name2);
}
- if (StringUtils.isNotEmpty(name3)) {
+ if (name3 != null && !name3.isEmpty()) {
description += String.format(" - %s", name3);
}
- if (StringUtils.isNotEmpty(name4)) {
+ if (name4 != null && !name4.isEmpty()) {
description += String.format(" - %s", name4);
}
return description;
import javax.xml.xpath.XPathExpressionException;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.XPathUtils;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
// parse resource id
String resourceId = XPathUtils.getSpeficValueFromNode(n, "ns1:resourceID");
- if (StringUtils.isNotBlank(resourceId)) {
+ if (resourceId != null && !resourceId.isBlank()) {
int id = Integer.parseInt(resourceId);
// Parse floating point value
String floatingPointValue = getValue(n, "floatingPointValue");
- if (StringUtils.isNotBlank(floatingPointValue)) {
+ if (floatingPointValue != null && !floatingPointValue.isBlank()) {
String min = getValue(n, "minimumValue");
String max = getValue(n, "maximumValue");
return new WSFloatingPointValue(id, Double.valueOf(floatingPointValue), Double.valueOf(min),
// Parse boolean value
String value = getValue(n, "value");
- if (StringUtils.isNotBlank(value)) {
+ if (value != null && !value.isBlank()) {
return new WSBooleanValue(id, Boolean.valueOf(value));
}
// Parse integer value
String integer = getValue(n, "integer");
- if (StringUtils.isNotBlank(integer)) {
+ if (integer != null && !integer.isBlank()) {
String min = getValue(n, "minimumValue");
String max = getValue(n, "maximumValue");
return new WSIntegerValue(id, Integer.valueOf(integer), Integer.valueOf(min), Integer.valueOf(max));
// Parse timer value
String milliseconds = getValue(n, "milliseconds");
- if (StringUtils.isNotBlank(milliseconds)) {
+ if (milliseconds != null && !milliseconds.isBlank()) {
return new WSTimerValue(id, Integer.valueOf(milliseconds));
}
// Parse time value
String hours = getValue(n, "hours");
- if (StringUtils.isNotBlank(hours)) {
+ if (hours != null && !hours.isBlank()) {
String minutes = getValue(n, "minutes");
String seconds = getValue(n, "seconds");
return new WSTimeValue(id, Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds));
// Parse date value
String year = getValue(n, "year");
- if (StringUtils.isNotBlank(year)) {
+ if (year != null && !year.isBlank()) {
String month = getValue(n, "month");
String day = getValue(n, "day");
return new WSDateValue(id, Short.valueOf(year), Byte.valueOf(month), Byte.valueOf(day));
// Parse enum value
String definitionTypeID = getValue(n, "definitionTypeID");
- if (StringUtils.isNotBlank(definitionTypeID)) {
+ if (definitionTypeID != null && !definitionTypeID.isBlank()) {
String enumValueID = getValue(n, "enumValueID");
String enumName = getValue(n, "enumName");
return new WSEnumValue(id, Integer.valueOf(definitionTypeID), Integer.valueOf(enumValueID), enumName);
// Parse week day value
value = getValue(n, "weekdayNumber");
- if (StringUtils.isNotBlank(value)) {
+ if (value != null && !value.isBlank()) {
return new WSWeekdayValue(id, Integer.valueOf(value));
}
import java.io.IOException;
import java.net.URI;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
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.eclipse.jetty.client.HttpClient;
} catch (OAuthException | OAuthResponseException e) {
throw new AuthenticationException("Error fetching access token: " + e.getMessage());
}
- if (accessTokenResponse == null || StringUtils.isBlank(accessTokenResponse.getAccessToken())) {
+ if (accessTokenResponse == null || accessTokenResponse.getAccessToken() == null
+ || accessTokenResponse.getAccessToken().isBlank()) {
throw new AuthenticationException("No innogy accesstoken. Is this thing authorized?");
}
return accessTokenResponse;
import java.net.URI;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
-import java.util.*;
-import java.util.concurrent.*;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
* @return true if success
*/
private boolean checkOnAuthCode() {
- if (StringUtils.isNotBlank(bridgeConfiguration.authcode)) {
+ if (!bridgeConfiguration.authcode.isBlank()) {
logger.debug("Trying to get access and refresh tokens");
try {
oAuthService.getAccessTokenResponseByAuthorizationCode(bridgeConfiguration.authcode,
/**
* Sends the command to start or stop moving the rollershutter (ISR2) in a specified direction
- *
+ *
* @param deviceId
* @param action
*/
/**
* Checks if the job is already (re-)scheduled.
- *
+ *
* @param job job to check
* @return true, when the job is already (re-)scheduled, otherwise false
*/
import static org.openhab.binding.irtrans.internal.IRtransBindingConstants.CHANNEL_IO;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led;
import org.openhab.binding.irtrans.internal.IrCommand;
import org.openhab.core.library.types.StringType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.irtrans.internal.IRtransBindingConstants;
import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher;
import org.openhab.binding.jeelink.internal.RollingAveragePublisher;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher;
*/
package org.openhab.binding.kaleidescape.internal.communication;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
// I.e. characters with accent, umlaut, etc., they need to be restored to the correct character
// example: Noel (with umlaut 'o') comes in as N\d246el
input = input.replaceAll("(?i)\\\\d([0-9]{3})", "\\&#$1;"); // first convert to html escaped codes
- // then convert with unescapeHtml, not sure how to do this without the Apache libraries :(
- return StringEscapeUtils.unescapeHtml(input);
+ // then convert with unescapeHtml4, not sure how to do this without the Apache libraries :(
+ return StringEscapeUtils.unescapeHtml4(input);
}
}
return input;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
import javax.measure.quantity.Power;
import javax.measure.quantity.Time;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaSeries;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType;
import org.openhab.core.cache.ExpiringCacheMap;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
* @author Markus Eckhardt
*/
public void recreateKeys() {
- if (StringUtils.isNotBlank(remoteDevice.getGatewayPassword())
- && StringUtils.isNotBlank(remoteDevice.getPrivatePassword()) && remoteDevice.getMD5Salt().length > 0) {
+ if (!remoteDevice.getGatewayPassword().isBlank() && !remoteDevice.getPrivatePassword().isBlank()
+ && remoteDevice.getMD5Salt().length > 0) {
byte[] md5K1 = null;
byte[] md5K2Init = null;
byte[] md5K2Private = null;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
}
public Boolean isConfigured() {
- return StringUtils.isNotBlank(ip4Address) && cryptKeyPriv.length > 0;
+ return !ip4Address.isBlank() && cryptKeyPriv.length > 0;
}
public String getIP4Address() {
import java.util.concurrent.ScheduledExecutorService;
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;
switch (key) {
case "ip4Address":
String ip = (String) configuration.get("ip4Address");
- if (StringUtils.isNotBlank(ip)) {
+ if (ip != null && !ip.isBlank()) {
try {
InetAddress.getByName(ip);
} catch (UnknownHostException e) {
break;
case "privateKey":
String privateKey = (String) configuration.get("privateKey");
- if (StringUtils.isNotBlank(privateKey)) {
+ if (privateKey != null && !privateKey.isBlank()) {
getDevice().setCryptKeyPriv(privateKey);
}
break;
case "md5Salt":
String md5Salt = (String) configuration.get("md5Salt");
- if (StringUtils.isNotBlank(md5Salt)) {
+ if (md5Salt != null && !md5Salt.isBlank()) {
getDevice().setMD5Salt(md5Salt);
}
break;
case "gatewayPassword":
String gatewayPassword = (String) configuration.get("gatewayPassword");
- if (StringUtils.isNotBlank(gatewayPassword)) {
+ if (gatewayPassword != null && !gatewayPassword.isBlank()) {
getDevice().setGatewayPassword(gatewayPassword);
}
break;
case "privatePassword":
String privatePassword = (String) configuration.get("privatePassword");
- if (StringUtils.isNotBlank(privatePassword)) {
+ if (privatePassword != null && !privatePassword.isBlank()) {
getDevice().setPrivatePassword(privatePassword);
}
break;
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.lametrictime.api.Configuration;
import org.openhab.binding.lametrictime.api.LaMetricTime;
import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
String host = config.host;
String apiKey = config.apiKey;
- if (StringUtils.isEmpty(host)) {
+ if (host == null || host.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(HOST)
.withMessageKeySuffix(LaMetricTimeConfigStatusMessage.HOST_MISSING).withArguments(HOST).build());
}
- if (StringUtils.isEmpty(apiKey)) {
+ if (apiKey == null || apiKey.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(API_KEY)
.withMessageKeySuffix(LaMetricTimeConfigStatusMessage.API_KEY_MISSING).withArguments(API_KEY)
.build());
*/
package org.openhab.binding.lutron.internal.config;
-import org.openhab.binding.lutron.internal.StringUtils;
+import java.util.Objects;
/**
* Configuration settings for an {@link org.openhab.binding.lutron.internal.handler.IPBridgeHandler}.
public int delay = 0;
public boolean sameConnectionParameters(IPBridgeConfig config) {
- return StringUtils.equals(ipAddress, config.ipAddress) && StringUtils.equals(user, config.user)
- && StringUtils.equals(password, config.password) && (reconnect == config.reconnect)
+ return Objects.equals(ipAddress, config.ipAddress) && Objects.equals(user, config.user)
+ && Objects.equals(password, config.password) && (reconnect == config.reconnect)
&& (heartbeat == config.heartbeat) && (delay == config.delay);
}
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.openhab.binding.lutron.internal.StringUtils;
import org.openhab.binding.lutron.internal.config.IPBridgeConfig;
import org.openhab.binding.lutron.internal.discovery.LutronDeviceDiscoveryService;
import org.openhab.binding.lutron.internal.net.TelnetSession;
return false;
}
- if (StringUtils.isEmpty(config.ipAddress)) {
+ String ipAddress = config.ipAddress;
+ if (ipAddress == null || ipAddress.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "bridge address not specified");
return false;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.Device;
import java.util.Base64;
import java.util.List;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.DeviceType;
logger.debug("RoomID: {}", roomId);
for (String key : properties.keySet()) {
if (!key.startsWith("Unknown")) {
- String propertyName = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(key), ' ');
+ String propertyName = String.join(" ", StringUtils.splitByCharacterTypeCamelCase(key));
logger.debug("{}: {}", propertyName, properties.get(key));
} else {
logger.debug("{}: {}", key, properties.get(key));
*/
package org.openhab.binding.meteoblue.internal;
-import org.apache.commons.lang.StringUtils;
-
/**
* Model for the meteoblue binding configuration.
*
String a2 = split.length > 1 ? split[1] : null;
String a3 = split.length > 2 ? split[2] : null;
- if (!StringUtils.isBlank(a1)) {
+ if (a1 != null && !a1.isBlank()) {
latitude = tryGetDouble(a1);
}
- if (!StringUtils.isBlank(a2)) {
+ if (a2 != null && !a2.isBlank()) {
longitude = tryGetDouble(a2);
}
- if (!StringUtils.isBlank(a3)) {
+ if (a3 != null && !a3.isBlank()) {
altitude = tryGetDouble(a3);
}
}
import java.util.Collections;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.meteoblue.internal.MeteoBlueBridgeConfig;
import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.thing.Bridge;
MeteoBlueBridgeConfig config = getConfigAs(MeteoBlueBridgeConfig.class);
String apiKeyTemp = config.getApiKey();
- if (StringUtils.isBlank(apiKeyTemp)) {
+ if (apiKeyTemp == null || apiKeyTemp.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Cannot initialize meteoblue bridge. No apiKey provided.");
return;
import javax.imageio.ImageIO;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.meteoblue.internal.Forecast;
import org.openhab.binding.meteoblue.internal.MeteoBlueConfiguration;
import org.openhab.binding.meteoblue.internal.json.JsonData;
MeteoBlueConfiguration config = getConfigAs(MeteoBlueConfiguration.class);
- if (StringUtils.isBlank(config.serviceType)) {
+ if (config.serviceType == null || config.serviceType.isBlank()) {
config.serviceType = MeteoBlueConfiguration.SERVICETYPE_NONCOMM;
logger.debug("Using default service type ({}).", config.serviceType);
return;
}
- if (StringUtils.isBlank(config.location)) {
+ if (config.location == null || config.location.isBlank()) {
flagBadConfig("The location was not configured.");
return;
}
if (config.altitude != null) {
builder.append("&asl=" + config.altitude);
}
- if (StringUtils.isNotBlank(config.timeZone)) {
+ if (config.timeZone != null && !config.timeZone.isBlank()) {
builder.append("&tz=" + config.timeZone);
}
url = url.replace("#FORMAT_PARAMS#", builder.toString());
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.miele.internal.handler.ApplianceStatusListener;
import org.openhab.binding.miele.internal.handler.MieleApplianceHandler;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler;
*/
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener {
+ private static final String MIELE_APPLIANCE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance";
+ private static final String MIELE_CLASS = "com.miele.xgw3000.gateway.hdm.deviceclasses.Miele";
+
private final Logger logger = LoggerFactory.getLogger(MieleApplianceDiscoveryService.class);
private static final int SEARCH_TIME = 60;
properties.put(APPLIANCE_ID, appliance.getApplianceId());
for (JsonElement dc : appliance.DeviceClasses) {
- if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
- && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
- properties.put(DEVICE_CLASS, StringUtils.right(dc.getAsString(), dc.getAsString().length()
- - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()));
+ String dcStr = dc.getAsString();
+ if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
+ properties.put(DEVICE_CLASS, dcStr.substring(MIELE_CLASS.length()));
break;
}
}
String modelID = null;
for (JsonElement dc : appliance.DeviceClasses) {
- if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
- && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
- modelID = StringUtils.right(dc.getAsString(), dc.getAsString().length()
- - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
+ String dcStr = dc.getAsString();
+ if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
+ modelID = dcStr.substring(MIELE_CLASS.length());
break;
}
}
if (modelID != null) {
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID,
- StringUtils.lowerCase(modelID.replaceAll("[^a-zA-Z0-9_]", "_")));
+ modelID.replaceAll("[^a-zA-Z0-9_]", "_").toLowerCase());
if (getSupportedThingTypes().contains(thingTypeUID)) {
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getId());
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.core.common.NamedThreadFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import java.util.Map.Entry;
import java.util.TimeZone;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
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.openhab.binding.mqtt.generic.values.TextValue;
this.channelStateUpdateListener = channelStateUpdateListener;
this.channelUID = channelUID;
this.cachedValue = cachedValue;
- this.readOnly = StringUtils.isBlank(config.commandTopic);
+ this.readOnly = config.commandTopic.isBlank();
}
public boolean isReadOnly() {
*/
public CompletableFuture<@Nullable Void> stop() {
final MqttBrokerConnection connection = this.connection;
- if (connection != null && StringUtils.isNotBlank(config.stateTopic)) {
+ if (connection != null && !config.stateTopic.isBlank()) {
return connection.unsubscribe(config.stateTopic, this).thenRun(this::internalStop);
} else {
internalStop();
this.connection = connection;
- if (StringUtils.isBlank(config.stateTopic)) {
+ if (config.stateTopic.isBlank()) {
return CompletableFuture.completedFuture(null);
}
import java.util.stream.Collectors;
import java.util.stream.Stream;
-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.openhab.binding.mqtt.generic.AbstractMQTTThingHandler;
Value value = ValueFactory.createValueState(channelConfig, channelTypeUID.getId());
ChannelState channelState = createChannelState(channelConfig, channel.getUID(), value);
channelStateByChannelUID.put(channel.getUID(), channelState);
- StateDescription description = value
- .createStateDescription(StringUtils.isBlank(channelConfig.commandTopic)).build()
- .toStateDescription();
+ StateDescription description = value.createStateDescription(channelConfig.commandTopic.isBlank())
+ .build().toStateDescription();
if (description != null) {
stateDescProvider.setDescription(channel.getUID(), description);
}
*/
package org.openhab.binding.mqtt.generic.values;
+import static java.util.function.Predicate.not;
+
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.CoreItemFactory;
*/
public TextValue(String[] states) {
super(CoreItemFactory.STRING, Collections.singletonList(StringType.class));
- Set<String> s = Stream.of(states).filter(e -> StringUtils.isNotBlank(e)).collect(Collectors.toSet());
+ Set<String> s = Stream.of(states).filter(not(String::isBlank)).collect(Collectors.toSet());
if (!s.isEmpty()) {
this.states = s;
} else {
*/
package org.openhab.binding.mqtt.generic.values;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.mqtt.generic.ChannelConfig;
import org.openhab.binding.mqtt.generic.internal.MqttBindingConstants;
Value value;
switch (channelTypeID) {
case MqttBindingConstants.STRING:
- value = StringUtils.isBlank(config.allowedStates) ? new TextValue()
+ value = config.allowedStates.isBlank() ? new TextValue()
: new TextValue(config.allowedStates.split(","));
break;
case MqttBindingConstants.DATETIME:
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.MqttChannelTypeProvider;
}
private boolean isHomeassistantDynamicType(ThingTypeUID thingTypeUID) {
- return StringUtils.equals(MqttBindingConstants.BINDING_ID, thingTypeUID.getBindingId())
- && StringUtils.startsWith(thingTypeUID.getId(), MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId());
+ return MqttBindingConstants.BINDING_ID.equals(thingTypeUID.getBindingId())
+ && thingTypeUID.getId().startsWith(MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId());
}
@Activate
import java.util.Map;
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.Thing;
protected @Nullable String name;
protected @Nullable String sw_version;
- @Nullable
- public String getId() {
- return StringUtils.join(identifiers, "_");
+ public @Nullable String getId() {
+ List<String> identifiers = this.identifiers;
+ return identifiers == null ? null : String.join("_", identifiers);
}
}
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.ChannelConfigBuilder;
public Builder stateTopic(@Nullable String state_topic, @Nullable String... templates) {
this.state_topic = state_topic;
- if (StringUtils.isNotBlank(state_topic)) {
+ if (state_topic != null && !state_topic.isBlank()) {
for (String template : templates) {
- if (StringUtils.isNotBlank(template)) {
+ if (template != null && !template.isBlank()) {
this.templateIn = template;
break;
}
.withCommandTopic(command_topic).makeTrigger(trigger).build(),
channelUID, valueState, channelStateUpdateListener);
- if (StringUtils.isBlank(state_topic) || this.trigger) {
+ String localStateTopic = state_topic;
+ if (localStateTopic == null || localStateTopic.isBlank() || this.trigger) {
type = ChannelTypeBuilder.trigger(channelTypeUID, label)
.withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL)).build();
} else {
import java.io.IOException;
import java.lang.reflect.Field;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
final String oldValue = (String) field.get(config);
String newValue = oldValue;
- if (StringUtils.isNotBlank(oldValue)) {
+ if (oldValue != null && !oldValue.isBlank()) {
if (oldValue.charAt(0) == '~') {
newValue = tilde + oldValue.substring(1);
} else if (oldValue.charAt(oldValue.length() - 1) == '~') {
*/
package org.openhab.binding.mqtt.homeassistant.internal;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.values.OnOffValue;
super(componentConfiguration, ChannelConfiguration.class);
// We do not support all HomeAssistant quirks
- if (channelConfiguration.optimistic && StringUtils.isNotBlank(channelConfiguration.state_topic)) {
+ if (channelConfiguration.optimistic && !channelConfiguration.state_topic.isBlank()) {
throw new UnsupportedOperationException("Component:Lock does not support forced optimistic mode");
}
import java.util.List;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener;
String uom = channelConfiguration.unit_of_measurement;
- if (uom != null && StringUtils.isNotBlank(uom)) {
+ if (uom != null && !uom.isBlank()) {
value = new NumberValue(null, null, null, uom);
} else {
value = new TextValue();
*/
package org.openhab.binding.mqtt.homeassistant.internal;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.values.OnOffValue;
super(componentConfiguration, ChannelConfiguration.class);
boolean optimistic = channelConfiguration.optimistic != null ? channelConfiguration.optimistic
- : StringUtils.isBlank(channelConfiguration.state_topic);
+ : channelConfiguration.state_topic.isBlank();
- if (optimistic && StringUtils.isNotBlank(channelConfiguration.state_topic)) {
+ if (optimistic && !channelConfiguration.state_topic.isBlank()) {
throw new UnsupportedOperationException("Component:Switch does not support forced optimistic mode");
}
import java.util.ArrayList;
import java.util.Collection;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.core.Configuration;
private static final String createTopic(HaID id) {
StringBuilder str = new StringBuilder();
str.append(id.baseTopic).append('/').append(id.component).append('/');
- if (StringUtils.isNotBlank(id.nodeID)) {
+ if (!id.nodeID.isBlank()) {
str.append(id.nodeID).append('/');
}
str.append(id.objectID).append('/');
*/
public String toShortTopic() {
String objectID = this.objectID;
- if (StringUtils.isNotBlank(nodeID)) {
+ if (!nodeID.isBlank()) {
objectID = nodeID + "/" + objectID;
}
String result = uniqueId;
// the null test is only here so the compile knows, result is not null afterwards
- if (result == null || StringUtils.isBlank(result)) {
+ if (result == null || result.isBlank()) {
StringBuilder str = new StringBuilder();
- if (StringUtils.isNotBlank(nodeID)) {
+ if (!nodeID.isBlank()) {
str.append(nodeID).append('_');
}
str.append(objectID).append('_').append(component);
import javax.net.ssl.TrustManager;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.internal.ssl.Pin;
super.connectionStateChanged(state, error);
// Store generated client ID if none was set by the user
final MqttBrokerConnection connection = this.connection;
- if (connection != null && state == MqttConnectionState.CONNECTED && StringUtils.isBlank(config.clientID)) {
- config.clientID = connection.getClientId();
+ String clientID = config.clientID;
+ if (connection != null && state == MqttConnectionState.CONNECTED && (clientID == null || clientID.isBlank())) {
+ clientID = connection.getClientId();
+ config.clientID = clientID;
Configuration editConfig = editConfiguration();
- editConfig.put("clientid", config.clientID);
+ editConfig.put("clientid", clientID);
updateConfiguration(editConfig);
}
}
if (config.certificatepin) {
try {
Pin pin;
- if (StringUtils.isBlank(config.certificate)) {
+ if (config.certificate.isBlank()) {
pin = Pin.LearningPin(PinType.CERTIFICATE_TYPE);
} else {
String[] split = config.certificate.split(":");
if (config.publickeypin) {
try {
Pin pin;
- if (StringUtils.isBlank(config.publickey)) {
+ if (config.publickey.isBlank()) {
pin = Pin.LearningPin(PinType.PUBLIC_KEY_TYPE);
} else {
String[] split = config.publickey.split(":");
*/
protected MqttBrokerConnection createBrokerConnection() throws IllegalArgumentException {
String host = config.host;
- if (StringUtils.isBlank(host) || host == null) {
+ if (host == null || host.isBlank()) {
throw new IllegalArgumentException("Host is empty!");
}
final String username = config.username;
final String password = config.password;
- if (StringUtils.isNotBlank(username) && password != null) {
+ if (username != null && !username.isBlank() && password != null) {
connection.setCredentials(username, password); // Empty passwords are allowed
}
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.neato.internal.CouldNotFindRobotException;
import org.openhab.binding.neato.internal.NeatoBindingConstants;
import java.util.Set;
import java.util.stream.Collectors;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.net.util.SubnetUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
*/
public ArpPingUtilEnum determineNativeARPpingMethod(String arpToolPath) {
String result = ExecUtil.executeCommandLineAndWaitResponse(Duration.ofMillis(100), arpToolPath, "--help");
- if (StringUtils.isBlank(result)) {
+ if (result == null || result.isBlank()) {
return ArpPingUtilEnum.UNKNOWN_TOOL;
} else if (result.contains("Thomas Habets")) {
if (result.matches("(?s)(.*)w sec Specify a timeout(.*)")) {
*/
package org.openhab.binding.nibeheatpump.internal.protocol;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
/**
*/
package org.openhab.binding.nibeuplink.internal.config;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-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.openhab.binding.oceanic.internal.NetworkOceanicBindingConfiguration;
import java.util.Arrays;
import java.util.Enumeration;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.oceanic.internal.SerialOceanicBindingConfiguration;
import org.openhab.binding.oceanic.internal.Throttler;
import org.openhab.core.thing.Thing;
import java.net.Socket;
import java.nio.ByteBuffer;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* The {@link ApiConfiguration} defines the model for a API bridge configuration.
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.CHANNEL_CONFIG_OFFSET;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* The {@link ChannelConfig} defines the model for a channel configuration.
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.ROUTE_CONFIG_ROUTE_ID;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* The {@link RouteConfiguration} defines the model for a route stop configuration.
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* The {@link StopConfiguration} defines the model for a stop bridge configuration.
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.onewiregpio.internal.OneWireGPIOBindingConstants;
import org.openhab.binding.onewiregpio.internal.OneWireGpioConfiguration;
import org.openhab.core.library.types.QuantityType;
* When invalid parameter is found, default value is assigned.
*/
private boolean checkConfiguration() {
- if (StringUtils.isEmpty(gpioBusFile)) {
+ if (gpioBusFile == null || gpioBusFile.isEmpty()) {
logger.debug("GPIO_BUS_FILE not set. Please check configuration, and set proper path to w1_slave file.");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"The path to the w1_slave sensor data file is missing.");
import java.util.Map;
import java.util.Set;
-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.jupnp.model.meta.RemoteDevice;
protected void activate(ComponentContext componentContext) {
if (componentContext.getProperties() != null) {
String autoDiscoveryPropertyValue = (String) componentContext.getProperties().get("enableAutoDiscovery");
- if (StringUtils.isNotEmpty(autoDiscoveryPropertyValue)) {
+ if (autoDiscoveryPropertyValue != null && !autoDiscoveryPropertyValue.isEmpty()) {
isAutoDiscoveryEnabled = Boolean.valueOf(autoDiscoveryPropertyValue);
}
}
DiscoveryResult result = null;
ThingUID thingUid = getThingUID(device);
if (thingUid != null) {
- String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
- : device.getDetails().getFriendlyName();
+ String friendlyName = device.getDetails().getFriendlyName();
+ String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
Map<String, Object> properties = new HashMap<>(2, 1);
properties.put(HOST_PARAMETER, device.getIdentity().getDescriptorURL().getHost());
properties.put(UDN_PARAMETER, device.getIdentity().getUdn().getIdentifierString());
public @Nullable ThingUID getThingUID(RemoteDevice device) {
ThingUID result = null;
if (isAutoDiscoveryEnabled) {
- if (StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
- MANUFACTURER)) {
- logger.debug("Manufacturer matched: search: {}, device value: {}.", MANUFACTURER,
- device.getDetails().getManufacturerDetails().getManufacturer());
- if (StringUtils.containsIgnoreCase(device.getType().getType(), UPNP_DEVICE_TYPE)) {
- logger.debug("Device type matched: search: {}, device value: {}.", UPNP_DEVICE_TYPE,
- device.getType().getType());
+ String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+ if (manufacturer != null && manufacturer.toLowerCase().contains(MANUFACTURER.toLowerCase())) {
+ logger.debug("Manufacturer matched: search: {}, device value: {}.", MANUFACTURER, manufacturer);
+ String type = device.getType().getType();
+ if (type != null && type.toLowerCase().contains(UPNP_DEVICE_TYPE.toLowerCase())) {
+ logger.debug("Device type matched: search: {}, device value: {}.", UPNP_DEVICE_TYPE, type);
String deviceModel = device.getDetails().getModelDetails() != null
? device.getDetails().getModelDetails().getModelName()
* @return
*/
private boolean isSupportedDeviceModel(final @Nullable String deviceModel) {
- return StringUtils.isNotBlank(deviceModel) && Arrays.stream(OnkyoModel.values())
+ return deviceModel != null && !deviceModel.isBlank() && Arrays.stream(OnkyoModel.values())
.anyMatch(model -> StringUtils.startsWithIgnoreCase(deviceModel, model.getId()));
}
}
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.orvibo.internal.OrviboBindingConstants;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
private DiscoveryResult createDiscoveryResult(Socket socket) {
ThingUID thingUID = getUID(socket);
String label = socket.getLabel();
- if (StringUtils.isBlank(label)) {
+ if (label == null || label.isBlank()) {
label = "S20";
}
return DiscoveryResultBuilder.create(thingUID).withLabel(label)
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@Override
public void socketDidChangeLabel(Socket socket, String label) {
- if (!StringUtils.isBlank(label)) {
+ if (label != null && !label.isBlank()) {
logger.debug("Updating thing label to {}", label);
thing.setLabel(label);
}
*/
package org.openhab.binding.pentair.internal.config;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Configuration parameters for IP Bridge
*/
package org.openhab.binding.pentair.internal.config;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Configuration parameters for Serial Bridge
*/
package org.openhab.binding.phc.internal;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledThreadPoolExecutor;
-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.openhab.binding.phc.internal.PHCBindingConstants;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.jupnp.model.meta.RemoteDevice;
import org.openhab.binding.pioneeravr.internal.PioneerAvrBindingConstants;
import org.openhab.core.config.discovery.DiscoveryResult;
protected void activate(ComponentContext componentContext) {
if (componentContext.getProperties() != null) {
String autoDiscoveryPropertyValue = (String) componentContext.getProperties().get("enableAutoDiscovery");
- if (StringUtils.isNotEmpty(autoDiscoveryPropertyValue)) {
+ if (autoDiscoveryPropertyValue != null && !autoDiscoveryPropertyValue.isEmpty()) {
isAutoDiscoveryEnabled = Boolean.valueOf(autoDiscoveryPropertyValue);
}
}
DiscoveryResult result = null;
ThingUID thingUid = getThingUID(device);
if (thingUid != null) {
- String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
- : device.getDetails().getFriendlyName();
+ String friendlyName = device.getDetails().getFriendlyName();
+ String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
Map<String, Object> properties = new HashMap<>(2, 1);
properties.put(PioneerAvrBindingConstants.HOST_PARAMETER,
device.getIdentity().getDescriptorURL().getHost());
public ThingUID getThingUID(RemoteDevice device) {
ThingUID result = null;
if (isAutoDiscoveryEnabled) {
- if (StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
- PioneerAvrBindingConstants.MANUFACTURER)) {
+ String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+ if (manufacturer != null
+ && manufacturer.toLowerCase().contains(PioneerAvrBindingConstants.MANUFACTURER.toLowerCase())) {
logger.debug("Manufacturer matched: search: {}, device value: {}.",
- PioneerAvrBindingConstants.MANUFACTURER,
- device.getDetails().getManufacturerDetails().getManufacturer());
- if (StringUtils.containsIgnoreCase(device.getType().getType(),
- PioneerAvrBindingConstants.UPNP_DEVICE_TYPE)) {
+ PioneerAvrBindingConstants.MANUFACTURER, manufacturer);
+ String type = device.getType().getType();
+ if (type != null
+ && type.toLowerCase().contains(PioneerAvrBindingConstants.UPNP_DEVICE_TYPE.toLowerCase())) {
logger.debug("Device type matched: search: {}, device value: {}.",
- PioneerAvrBindingConstants.UPNP_DEVICE_TYPE, device.getType().getType());
+ PioneerAvrBindingConstants.UPNP_DEVICE_TYPE, type);
String deviceModel = device.getDetails().getModelDetails() != null
? device.getDetails().getModelDetails().getModelName()
* @return
*/
private boolean isSupportedDeviceModel(String deviceModel, Set<String> supportedDeviceModels) {
- return StringUtils.isNotBlank(deviceModel) && supportedDeviceModels.stream()
- .anyMatch(input -> StringUtils.startsWithIgnoreCase(deviceModel, input));
+ return deviceModel != null && !deviceModel.isBlank() && supportedDeviceModels.stream()
+ .anyMatch(input -> deviceModel.toLowerCase().startsWith(input.toLowerCase()));
}
}
*/
package org.openhab.binding.pioneeravr.internal.protocol;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrCommand;
import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrConnectionException;
"The parameter of the command " + super.getCommand() + " must not be null.");
}
- if (StringUtils.isNotEmpty(parameterPattern) && !parameter.matches(parameterPattern)) {
+ if (parameterPattern != null && !parameterPattern.isEmpty() && !parameter.matches(parameterPattern)) {
throw new AvrConnectionException("The parameter value " + parameter + " of the command "
+ super.getCommand() + " does not match the pattern " + parameterPattern);
}
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.pioneeravr.internal.protocol.avr.AvrConnectionException;
import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrResponse;
private String[] responsePrefixZone;
- private String parameterPattern;
+ private @Nullable String parameterPattern;
private Pattern[] matchPatternZone;
- private ResponseType(String parameterPattern, String... responsePrefixZone) {
+ private ResponseType(@Nullable String parameterPattern, String... responsePrefixZone) {
this.responsePrefixZone = responsePrefixZone;
this.parameterPattern = parameterPattern;
for (int zoneIndex = 0; zoneIndex < responsePrefixZone.length; zoneIndex++) {
String responsePrefix = responsePrefixZone[zoneIndex];
- matchPatternZone[zoneIndex] = Pattern.compile(responsePrefix + "("
- + (StringUtils.isNotEmpty(parameterPattern) ? parameterPattern : "") + ")");
+ matchPatternZone[zoneIndex] = Pattern
+ .compile(responsePrefix + "(" + (parameterPattern == null ? "" : parameterPattern) + ")");
}
}
@Override
public boolean hasParameter() {
- return StringUtils.isNotEmpty(parameterPattern);
+ return parameterPattern != null && !parameterPattern.isEmpty();
}
@Override
- public String getParameterPattern() {
+ public @Nullable String getParameterPattern() {
return parameterPattern;
}
private String parameter;
public Response(String responseData) throws AvrConnectionException {
- if (StringUtils.isEmpty(responseData)) {
+ if (responseData == null || responseData.isEmpty()) {
throw new AvrConnectionException("responseData is empty. Cannot parse the response.");
}
*/
package org.openhab.binding.pioneeravr.internal.protocol.avr;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.pioneeravr.internal.protocol.Response.ResponseType;
/**
*
* @return
*/
- public String getParameterPattern();
+ public @Nullable String getParameterPattern();
/**
* Return the zone number if the responseData matches a zone of this responseType.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-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.openhab.binding.plugwise.internal.protocol.AcknowledgementMessage;
import java.time.format.DateTimeFormatter;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.WordUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.plugwise.internal.protocol.InformationResponseMessage;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.pulseaudio.internal.cli.Parser;
import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig;
import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig.State;
sendRawCommand(CMD_UNLOAD_MODULE + " " + combinedSink.getModule().getId());
// 2. add new combined-sink with same name and all slaves
sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSink.getPaName()
- + " slaves=" + StringUtils.join(slaves, ","));
+ + " slaves=" + String.join(",", slaves));
// 3. update internal data structure because the combined sink has a new number + other slaves
update();
}
}
// add new combined-sink with same name and all slaves
sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSinkName + " slaves="
- + StringUtils.join(slaves, ","));
+ + String.join(",", slaves));
// update internal data structure because the combined sink is new
update();
}
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig;
import org.openhab.binding.pulseaudio.internal.items.Sink;
import org.openhab.binding.pulseaudio.internal.items.SinkInput;
: new StringType("-"));
}
if (device instanceof Sink && ((Sink) device).isCombinedSink()) {
- updateState(SLAVES_CHANNEL,
- new StringType(StringUtils.join(((Sink) device).getCombinedSinkNames(), ",")));
+ updateState(SLAVES_CHANNEL, new StringType(String.join(",", ((Sink) device).getCombinedSinkNames())));
}
}
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.rme.internal.RMEBindingConstants.DataField;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.library.types.DecimalType;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Authentication;
import org.eclipse.jetty.client.api.AuthenticationStore;
this.value = value;
}
+ @Override
public URI getURI() {
return this.uri;
}
+ @Override
public void apply(Request request) {
request.header(this.header, this.value);
}
+ @Override
public String toString() {
return String.format("Basic authentication result for %s", this.uri);
}
String responseString = null;
// jetty uses UTF-8 as default encoding. However, HTTP 1.1 specifies ISO_8859_1
- if (StringUtils.isBlank(response.getEncoding())) {
+ if (response.getEncoding() == null || response.getEncoding().isBlank()) {
responseString = new String(response.getContent(), StandardCharsets.ISO_8859_1);
} else {
// currently v0.9e Robonect does not specifiy the encoding. But if later versions will
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;
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,
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);
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);
}
}
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));
* @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) {
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;
* @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;
}
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;
* @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");
}
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;
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");
}
import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.types.State;
/**
* @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) {
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;
* @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");
}
throw new IllegalArgumentException("Source must be between 1 and 8");
}
- if (StringUtils.isEmpty(presetJson)) {
+ if (presetJson == null || presetJson.isEmpty()) {
return;
}
// 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
* @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;
}
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;
* @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");
}
throw new IllegalArgumentException("Zone must be between 1 and 8");
}
- if (StringUtils.isEmpty(favJson)) {
+ if (favJson == null || favJson.isEmpty()) {
return;
}
} 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 + "\"");
}
* @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;
}
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;
*/
@Override
public void stateChanged(String channelId, State newState) {
- if (StringUtils.isEmpty(channelId)) {
+ if (channelId == null || channelId.isEmpty()) {
return;
}
* @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);
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;
* @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;
}
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.
* @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);
}
/**
*
* @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);
}
}
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
* @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);
}
/**
*
* @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);
}
/**
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
* @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);
}
/**
*
* @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);
}
/**
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;
@Override
public String getName() {
final String name = sourceName.get();
- return StringUtils.isEmpty(name) ? ("Source " + getId()) : name;
+ return name == null || name.isEmpty() ? "Source " + getId() : name;
}
/**
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;
*/
Runnable setBanks(String bankJson) {
// If null or empty - simply return a do nothing runnable
- if (StringUtils.isEmpty(bankJson)) {
+ if (bankJson == null || bankJson.isEmpty()) {
return () -> {
};
}
} 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() + "\"");
* @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);
* @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;
}
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;
* @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;
}
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;
@Override
public String getName() {
final String name = zoneName.get();
- return StringUtils.isEmpty(name) ? ("Zone " + getId()) : name;
+ return name == null || name.isEmpty() ? "Zone " + getId() : name;
}
/**
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;
* @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 () -> {
};
}
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) {
*/
@Override
public void responseReceived(String response) {
- if (StringUtils.isEmpty(response)) {
+ if (response == null || response.isEmpty()) {
return;
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.satel.internal.protocol.SatelMessage;
-import org.openhab.binding.satel.internal.util.StringUtils;
/**
* Base class for all commands that return result code in the response.
}
protected static byte[] userCodeToBytes(String userCode) {
- if (StringUtils.isEmpty(userCode)) {
+ if (userCode.isEmpty()) {
throw new IllegalArgumentException("User code is empty");
}
if (userCode.length() > 8) {
public static final String HOST = "host";
- private @Nullable String host;
+ private String host = "";
private int port;
private @Nullable String encryptionKey;
* @return IP or hostname of the bridge
*/
public String getHost() {
- final String host = this.host;
- return host == null ? "" : host;
+ return host;
}
/**
package org.openhab.binding.satel.internal.config;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link IntRSConfig} contains configuration values for Satel INT-RS bridge.
public static final String PORT = "port";
- private @Nullable String port;
+ private String port = "";
/**
* @return serial port to which the module is connected
*/
- public @Nullable String getPort() {
+ public String getPort() {
return port;
}
}
import org.openhab.binding.satel.internal.config.Ethm1Config;
import org.openhab.binding.satel.internal.protocol.Ethm1Module;
import org.openhab.binding.satel.internal.protocol.SatelModule;
-import org.openhab.binding.satel.internal.util.StringUtils;
import org.openhab.core.config.core.status.ConfigStatusMessage;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ThingStatus;
logger.debug("Initializing handler");
Ethm1Config config = getConfigAs(Ethm1Config.class);
- if (StringUtils.isNotBlank(config.getHost())) {
+ if (!config.getHost().isBlank()) {
SatelModule satelModule = new Ethm1Module(config.getHost(), config.getPort(), config.getTimeout(),
config.getEncryptionKey(), config.hasExtCommandsSupport());
super.initialize(satelModule);
Collection<ConfigStatusMessage> configStatusMessages;
// Check whether an IP address is provided
- if (StringUtils.isBlank(host)) {
+ if (host.isBlank()) {
configStatusMessages = Collections.singletonList(ConfigStatusMessage.Builder.error(HOST)
.withMessageKeySuffix("hostEmpty").withArguments(HOST).build());
} else {
import org.openhab.binding.satel.internal.config.IntRSConfig;
import org.openhab.binding.satel.internal.protocol.IntRSModule;
import org.openhab.binding.satel.internal.protocol.SatelModule;
-import org.openhab.binding.satel.internal.util.StringUtils;
import org.openhab.core.config.core.status.ConfigStatusMessage;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.thing.Bridge;
final IntRSConfig config = getConfigAs(IntRSConfig.class);
final String port = config.getPort();
- if (port != null && StringUtils.isNotBlank(port)) {
+ if (!port.isBlank()) {
SatelModule satelModule = new IntRSModule(port, serialPortManager, config.getTimeout(),
config.hasExtCommandsSupport());
super.initialize(satelModule);
Collection<ConfigStatusMessage> configStatusMessages;
// Check whether a serial port is provided
- if (StringUtils.isBlank(port)) {
+ if (port.isBlank()) {
configStatusMessages = Collections.singletonList(ConfigStatusMessage.Builder.error(PORT)
.withMessageKeySuffix("portEmpty").withArguments(PORT).build());
} else {
import org.openhab.binding.satel.internal.event.SatelEventListener;
import org.openhab.binding.satel.internal.protocol.SatelModule;
import org.openhab.binding.satel.internal.types.IntegraType;
-import org.openhab.binding.satel.internal.util.StringUtils;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.ThingStatus;
* @return current user code, either from the configuration or set later using {@link #setUserCode(String)}
*/
public String getUserCode() {
- if (StringUtils.isNotEmpty(userCodeOverride)) {
+ if (!userCodeOverride.isEmpty()) {
return userCodeOverride;
} else {
return config.getUserCode();
import org.openhab.binding.satel.internal.event.IntegraStateEvent;
import org.openhab.binding.satel.internal.event.NewStatesEvent;
import org.openhab.binding.satel.internal.types.StateType;
-import org.openhab.binding.satel.internal.util.StringUtils;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
this.requiresRefresh.set(true);
} else {
withBridgeHandlerPresent(bridgeHandler -> {
- if (StringUtils.isEmpty(bridgeHandler.getUserCode())) {
+ if (bridgeHandler.getUserCode().isEmpty()) {
logger.info("Cannot control devices without providing valid user code. Command has not been sent.");
} else {
convertCommand(channelUID, command)
import java.util.Random;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.satel.internal.util.StringUtils;
import org.openhab.core.util.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
protected CommunicationChannel connect() throws ConnectionFailureException {
- logger.info("Connecting to ETHM-1 module at {}:{}", this.host, this.port);
+ logger.info("Connecting to ETHM-1 module at {}:{}", host, port);
try {
Socket socket = new Socket();
- socket.connect(new InetSocketAddress(this.host, this.port), this.getTimeout());
+ socket.connect(new InetSocketAddress(host, port), this.getTimeout());
logger.info("ETHM-1 module connected successfully");
- if (StringUtils.isBlank(this.encryptionKey)) {
+ if (encryptionKey.isBlank()) {
return new TCPCommunicationChannel(socket);
} else {
- return new EncryptedCommunicationChannel(socket, this.encryptionKey);
+ return new EncryptedCommunicationChannel(socket, encryptionKey);
}
} catch (SocketTimeoutException e) {
throw new ConnectionFailureException("Connection timeout", e);
+++ /dev/null
-/**
- * Copyright (c) 2010-2021 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.satel.internal.util;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Replacement class for Apache's StringUtils.
- *
- * @author Krzysztof Goworek - Initial contribution
- *
- */
-@NonNullByDefault
-public class StringUtils {
-
- /**
- * Checks if a string is empty or null.
- *
- * @param str the string to check
- * @return <code>true</code> if given string is empty or null
- */
- public static boolean isEmpty(@Nullable String str) {
- return str == null || str.isEmpty();
- }
-
- /**
- * Checks if a string is not empty and not null.
- *
- * @param str the string to check
- * @return <code>true</code> if given string is not empty and not null
- */
- public static boolean isNotEmpty(@Nullable String str) {
- return !isEmpty(str);
- }
-
- /**
- * Checks if a string is null or empty or all characters are whitespace.
- *
- * @param str the string to check
- * @return <code>true</code> if given string is blank
- */
- public static boolean isBlank(@Nullable String str) {
- return str == null || str.isBlank();
- }
-
- /**
- * Checks if a string is not null, not empty and contains at least one non-whitespace character.
- *
- * @param str the string to check
- * @return <code>true</code> if given string is not blank
- */
- public static boolean isNotBlank(@Nullable String str) {
- return !isBlank(str);
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2021 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.satel.internal.util;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Krzysztof Goworek - Initial contribution
- */
-public class StringUtilsTest {
-
- @Test
- public void testIsEmpty() {
- assertFalse(StringUtils.isEmpty("foobar"));
- assertFalse(StringUtils.isEmpty(" "));
- assertTrue(StringUtils.isEmpty(""));
- assertTrue(StringUtils.isEmpty(null));
- }
-
- @Test
- public void testIsNotEmpty() {
- assertTrue(StringUtils.isNotEmpty("foobar"));
- assertTrue(StringUtils.isNotEmpty(" "));
- assertFalse(StringUtils.isNotEmpty(""));
- assertFalse(StringUtils.isNotEmpty(null));
- }
-
- @Test
- public void testIsBlank() {
- assertFalse(StringUtils.isBlank("foobar"));
- assertTrue(StringUtils.isBlank(" "));
- assertTrue(StringUtils.isBlank(""));
- assertTrue(StringUtils.isBlank(null));
- }
-
- @Test
- public void testIsNotBlank() {
- assertTrue(StringUtils.isNotBlank("foobar"));
- assertFalse(StringUtils.isNotBlank(" "));
- assertFalse(StringUtils.isNotBlank(""));
- assertFalse(StringUtils.isNotBlank(null));
- }
-}
import javax.measure.UnitConverter;
import javax.measure.quantity.Temperature;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.commons.lang3.text.WordUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.sensibo.internal.CallbackChannelsTypeProvider;
import java.util.List;
import java.util.Optional;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
import javax.measure.Unit;
import javax.measure.quantity.Temperature;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.sensibo.internal.SensiboTemperatureUnitConverter;
import org.openhab.binding.sensibo.internal.dto.poddetails.ModeCapabilityDTO;
*/
package org.openhab.binding.sleepiq.internal.config;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* Configuration class for the SleepIQ cloud.
*
* @author Gregory Moyer - Initial contribution
*/
+@NonNullByDefault
public class SleepIQCloudConfiguration {
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String POLLING_INTERVAL = "pollingInterval";
- public String username;
- public String password;
+ public String username = "";
+ public String password = "";
public int pollingInterval;
}
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.sleepiq.api.Configuration;
import org.openhab.binding.sleepiq.api.LoginException;
import org.openhab.binding.sleepiq.api.SleepIQ;
String username = config.username;
String password = config.password;
- if (StringUtils.isEmpty(username)) {
+ if (username.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(USERNAME)
.withMessageKeySuffix(SleepIQConfigStatusMessage.USERNAME_MISSING).withArguments(USERNAME).build());
}
- if (StringUtils.isEmpty(password)) {
+ if (password.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(PASSWORD)
.withMessageKeySuffix(SleepIQConfigStatusMessage.PASSWORD_MISSING).withArguments(PASSWORD).build());
}
import javax.measure.Quantity;
import javax.measure.Unit;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.DefaultLocation;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
cancelRead();
SmartMeterConfiguration config = getConfigAs(SmartMeterConfiguration.class);
- logger.debug("config port = {}", config.port);
- boolean validConfig = true;
- String errorMsg = null;
+ String port = config.port;
+ logger.debug("config port = {}", port);
- if (StringUtils.trimToNull(config.port) == null) {
- errorMsg = "Parameter 'port' is mandatory and must be configured";
- validConfig = false;
- }
-
- if (validConfig) {
+ if (port == null || port.isBlank()) {
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
+ "Parameter 'port' is mandatory and must be configured");
+ } else {
byte[] pullSequence = config.initMessage == null ? null
: HexUtils.hexToBytes(StringUtils.deleteWhitespace(config.initMessage));
int baudrate = config.baudrate == null ? Baudrate.AUTO.getBaudrate()
: Baudrate.fromString(config.baudrate).getBaudrate();
this.conformity = config.conformity == null ? Conformity.NONE : Conformity.valueOf(config.conformity);
this.smlDevice = MeterDeviceFactory.getDevice(serialPortManagerSupplier, config.mode,
- this.thing.getUID().getAsString(), config.port, pullSequence, baudrate, config.baudrateChangeDelay);
+ this.thing.getUID().getAsString(), port, pullSequence, baudrate, config.baudrateChangeDelay);
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.HANDLER_CONFIGURATION_PENDING,
"Waiting for messages from device");
smlDevice.addValueChangeListener(channelTypeProvider);
updateOBISValue();
- } else {
- updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, errorMsg);
}
}
*/
package org.openhab.binding.smartmeter.internal.helper;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.io.transport.serial.SerialPort;
*/
package org.openhab.binding.solaredge.internal.config;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
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;
public synchronized void login() {
String url;
- if (StringUtils.isEmpty(thingConfig.getEmail()) || StringUtils.isEmpty(thingConfig.getPassword())) {
+ if (thingConfig.getEmail().isEmpty() || thingConfig.getPassword().isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Can not access device as username and/or password are null");
return;
throws InterruptedException, ExecutionException, TimeoutException {
logger.trace("Sending {} to url: {} with data: {}", method.asString(), url, urlParameters);
Request request = sendRequestBuilder(url, method);
- if (StringUtils.isNotEmpty(urlParameters)) {
+ if (!urlParameters.isEmpty()) {
request = request.content(new StringContentProvider(urlParameters), "application/json;charset=UTF-8");
}
import java.io.Serializable;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.jupnp.model.meta.RemoteDevice;
import org.openhab.binding.sonyaudio.internal.SonyAudioBindingConstants;
import org.openhab.core.config.discovery.DiscoveryResult;
ThingUID thingUid = getThingUID(device);
if (thingUid != null) {
- String label = StringUtils.isEmpty(device.getDetails().getFriendlyName()) ? device.getDisplayString()
- : device.getDetails().getFriendlyName();
- String host = device.getIdentity().getDescriptorURL().getHost();
- int port = device.getIdentity().getDescriptorURL().getPort();
- String path = device.getIdentity().getDescriptorURL().getPath();
+ String friendlyName = device.getDetails().getFriendlyName();
+ String label = friendlyName == null || friendlyName.isEmpty() ? device.getDisplayString() : friendlyName;
+ URL descriptorURL = device.getIdentity().getDescriptorURL();
+ String host = descriptorURL.getHost();
+ int port = descriptorURL.getPort();
+ String path = descriptorURL.getPath();
try {
Map<String, Object> properties = getDescription(host, port, path);
- properties.put(SonyAudioBindingConstants.HOST_PARAMETER,
- device.getIdentity().getDescriptorURL().getHost());
+ properties.put(SonyAudioBindingConstants.HOST_PARAMETER, descriptorURL.getHost());
result = DiscoveryResultBuilder.create(thingUid).withLabel(label).withProperties(properties).build();
} catch (IOException e) {
return null;
public ThingUID getThingUID(RemoteDevice device) {
ThingUID result = null;
- if (!StringUtils.containsIgnoreCase(device.getDetails().getManufacturerDetails().getManufacturer(),
- SonyAudioBindingConstants.MANUFACTURER)) {
+ String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer();
+ if (manufacturer == null
+ || !manufacturer.toLowerCase().contains(SonyAudioBindingConstants.MANUFACTURER.toLowerCase())) {
return result;
}
logger.debug("Manufacturer matched: search: {}, device value: {}.", SonyAudioBindingConstants.MANUFACTURER,
- device.getDetails().getManufacturerDetails().getManufacturer());
- if (!StringUtils.containsIgnoreCase(device.getType().getType(), SonyAudioBindingConstants.UPNP_DEVICE_TYPE)) {
+ manufacturer);
+ String type = device.getType().getType();
+ if (type == null || !type.toLowerCase().contains(SonyAudioBindingConstants.UPNP_DEVICE_TYPE.toLowerCase())) {
return result;
}
logger.debug("Device type matched: search: {}, device value: {}.", SonyAudioBindingConstants.UPNP_DEVICE_TYPE,
- device.getType().getType());
+ type);
logger.debug("Device services: {}", device.getServices().toString());
String deviceModel = device.getDetails().getModelDetails() != null
? device.getDetails().getModelDetails().getModelName()
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;
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);
}
}
// 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;
*/
package org.openhab.binding.squeezebox.internal.config;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* Configuration of a server.
*
* @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
*/
/**
* 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 = "";
}
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;
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());
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);
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;
* Login to server
*/
public void login() {
- if (StringUtils.isEmpty(userId)) {
+ if (userId.isEmpty()) {
return;
}
// Create basic auth string for jsonrpc interface
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;
}
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;
import java.math.BigDecimal;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.DecimalType;
*/
package org.openhab.binding.unifi.internal;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.unifi.internal.handler.UniFiClientThingHandler;
/**
}
public UniFiClientThingConfig tidy() {
- cid = StringUtils.lowerCase(StringUtils.strip(cid));
- site = StringUtils.lowerCase(StringUtils.strip(site));
+ cid = cid.trim().toLowerCase();
+ site = site.trim().toLowerCase();
return this;
}
public boolean isValid() {
- return StringUtils.isNotBlank(cid);
+ return !cid.isBlank();
}
@Override
*/
package org.openhab.binding.unifi.internal;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler;
/**
}
public boolean isValid() {
- return StringUtils.isNotBlank(host) && StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password);
+ return !host.isBlank() && !username.isBlank() && !password.isBlank();
}
@Override
import java.util.Map;
import java.util.stream.Collectors;
-import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final void put(T value) {
for (String prefix : prefixes) {
String suffix = getSuffix(value, prefix);
- if (StringUtils.isNotBlank(suffix)) {
+ if (suffix != null && !suffix.isBlank()) {
String key = prefix + SEPARATOR + suffix;
map.put(key, value);
}
import java.util.Calendar;
-import org.apache.commons.lang.BooleanUtils;
import org.openhab.binding.unifi.internal.api.UniFiException;
import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
import org.openhab.binding.unifi.internal.api.util.UniFiTimestampDeserializer;
public abstract Boolean isWired();
public final Boolean isWireless() {
- return BooleanUtils.negate(isWired());
+ return isWired() == null ? null : (isWired().booleanValue() ? Boolean.FALSE : Boolean.TRUE);
}
protected abstract String getDeviceMac();
import java.util.Collection;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
public @Nullable UniFiSite getSite(@Nullable String id) {
UniFiSite site = null;
- if (StringUtils.isNotBlank(id)) {
+ if (id != null && !id.isBlank()) {
synchronized (this) {
site = sitesCache.get(id);
}
public @Nullable UniFiDevice getDevice(@Nullable String id) {
UniFiDevice device = null;
- if (StringUtils.isNotBlank(id)) {
+ if (id != null && !id.isBlank()) {
synchronized (this) {
device = devicesCache.get(id);
}
public @Nullable UniFiClient getClient(@Nullable String id) {
UniFiClient client = null;
- if (StringUtils.isNotBlank(id)) {
+ if (id != null && !id.isBlank()) {
synchronized (this) {
// mgb: first check active clients and fallback to insights if not found
client = clientsCache.get(id);
*/
package org.openhab.binding.unifi.internal.api.model;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
import com.google.gson.annotations.JsonAdapter;
}
public String getName() {
- return StringUtils.defaultIfBlank(name, mac);
+ return name == null || name.isBlank() ? mac : name;
}
public String getMac() {
*/
package org.openhab.binding.unifi.internal.api.model;
-import org.apache.commons.lang.StringUtils;
-
import com.google.gson.annotations.SerializedName;
/**
}
public boolean matchesName(String siteName) {
- return StringUtils.equalsIgnoreCase(desc, siteName) || StringUtils.equalsIgnoreCase(name, siteName)
- || StringUtils.equalsIgnoreCase(id, siteName);
+ return siteName.equalsIgnoreCase(desc) || siteName.equalsIgnoreCase(name) || siteName.equalsIgnoreCase(id);
}
@Override
import java.lang.reflect.Type;
-import org.apache.commons.lang.StringUtils;
-
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
public String deserialize(JsonElement json, Type type, JsonDeserializationContext context)
throws JsonParseException {
String s = json.getAsJsonPrimitive().getAsString();
- return StringUtils.lowerCase(StringUtils.strip(s));
+ return s.trim().toLowerCase();
}
}
import java.time.ZonedDateTime;
import java.util.Calendar;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.unifi.internal.UniFiBindingConstants;
private static boolean belongsToSite(UniFiClient client, String siteName) {
boolean result = true; // mgb: assume true = proof by contradiction
- if (StringUtils.isNotEmpty(siteName)) {
+ if (!siteName.isEmpty()) {
UniFiSite site = client.getSite();
// mgb: if the 'site' can't be found or the name doesn't match...
if (site == null || !site.matchesName(siteName)) {
// :site
case CHANNEL_SITE:
- if (clientHome && site != null && StringUtils.isNotBlank(site.getDescription())) {
+ if (clientHome && site != null && site.getDescription() != null && !site.getDescription().isBlank()) {
state = StringType.valueOf(site.getDescription());
}
break;
// :macAddress
case CHANNEL_MAC_ADDRESS:
- if (clientHome && StringUtils.isNotBlank(client.getMac())) {
+ if (clientHome && client.getMac() != null && !client.getMac().isBlank()) {
state = StringType.valueOf(client.getMac());
}
break;
// :ipAddress
case CHANNEL_IP_ADDRESS:
- if (clientHome && StringUtils.isNotBlank(client.getIp())) {
+ if (clientHome && client.getIp() != null && !client.getIp().isBlank()) {
state = StringType.valueOf(client.getIp());
}
break;
// :ap
case CHANNEL_AP:
UniFiDevice device = client.getDevice();
- if (clientHome && device != null && StringUtils.isNotBlank(device.getName())) {
+ if (clientHome && device != null && device.getName() != null && !device.getName().isBlank()) {
state = StringType.valueOf(device.getName());
}
break;
// :essid
case CHANNEL_ESSID:
- if (clientHome && StringUtils.isNotBlank(client.getEssid())) {
+ if (clientHome && client.getEssid() != null && !client.getEssid().isBlank()) {
state = StringType.valueOf(client.getEssid());
}
break;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntry;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Temperature;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
public Collection<ConfigStatusMessage> getConfigStatus() {
Collection<ConfigStatusMessage> status = new ArrayList<>();
VenstarThermostatConfiguration config = getConfigAs(VenstarThermostatConfiguration.class);
- if (StringUtils.isBlank(config.username)) {
+ if (config.username.isBlank()) {
log.warn("username is empty");
status.add(ConfigStatusMessage.Builder.error(CONFIG_USERNAME).withMessageKeySuffix(EMPTY_INVALID)
.withArguments(CONFIG_USERNAME).build());
}
- if (StringUtils.isBlank(config.password)) {
+ if (config.password.isBlank()) {
log.warn("password is empty");
status.add(ConfigStatusMessage.Builder.error(CONFIG_PASSWORD).withMessageKeySuffix(EMPTY_INVALID)
.withArguments(CONFIG_PASSWORD).build());
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpResponseException;
import javax.imageio.ImageIO;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
private boolean isValidLocation() {
boolean validLocation = false;
- String locationType = getConfigAs(WeatherCompanyForecastConfig.class).locationType;
+ WeatherCompanyForecastConfig config = getConfigAs(WeatherCompanyForecastConfig.class);
+ String locationType = config.locationType;
if (locationType == null) {
return validLocation;
}
switch (locationType) {
case CONFIG_LOCATION_TYPE_POSTAL_CODE:
- String postalCode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).postalCode);
- if (postalCode == null) {
+ String postalCode = config.postalCode;
+ if (postalCode == null || postalCode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Postal code is not set");
} else {
locationQueryString = "&postalKey=" + postalCode.replace(" ", "");
}
break;
case CONFIG_LOCATION_TYPE_GEOCODE:
- String geocode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).geocode);
- if (geocode == null) {
+ String geocode = config.geocode;
+ if (geocode == null || geocode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Geocode is not set");
} else {
locationQueryString = "&geocode=" + geocode.replace(" ", "");
}
break;
case CONFIG_LOCATION_TYPE_IATA_CODE:
- String iataCode = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).iataCode);
- if (iataCode == null) {
+ String iataCode = config.iataCode;
+ if (iataCode == null || iataCode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "IATA code is not set");
} else {
locationQueryString = "&iataCode=" + iataCode.replace(" ", "").toUpperCase();
}
private void setLanguage() {
- String language = StringUtils.trimToNull(getConfigAs(WeatherCompanyForecastConfig.class).language);
- if (language == null) {
+ WeatherCompanyForecastConfig config = getConfigAs(WeatherCompanyForecastConfig.class);
+ String language = config.language;
+ if (language == null || language.isBlank()) {
// Nothing in the thing config, so try to get a match from the openHAB locale
String derivedLanguage = WeatherCompanyAbstractHandler.lookupLanguage(localeProvider.getLocale());
languageQueryString = "&language=" + derivedLanguage;
logger.debug("Language not set in thing config, using {}", derivedLanguage);
} else {
// Use what is set in the thing config
- languageQueryString = "&language=" + language;
+ languageQueryString = "&language=" + language.trim();
}
}
import java.util.concurrent.Future;
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;
* Build the URL for requesting the PWS current observations
*/
private @Nullable String buildPwsUrl() {
- if (StringUtils.isEmpty(getConfigAs(WeatherCompanyObservationsConfig.class).pwsStationId)) {
+ WeatherCompanyObservationsConfig config = getConfigAs(WeatherCompanyObservationsConfig.class);
+ String pwsStationId = config.pwsStationId;
+ if (pwsStationId == null || pwsStationId.isEmpty()) {
return null;
}
String apiKey = getApiKey();
// Set response type as JSON
sb.append("&format=json");
// Set PWS station Id from config
- sb.append("&stationId=").append(getConfigAs(WeatherCompanyObservationsConfig.class).pwsStationId);
+ sb.append("&stationId=").append(pwsStationId);
// Set API key from config
sb.append("&apiKey=").append(apiKey);
String url = sb.toString();
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.handler.WemoBridgeHandler;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.net.http.HttpUtil;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.wemo.internal.http.WemoHttpCall;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.upnp.UpnpIOParticipant;
import java.util.Optional;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
public Optional<String> getHostWithPort() {
final String str = host;
- if (StringUtils.isEmpty(str)) {
+ if (str == null || str.isEmpty()) {
return Optional.empty();
}
return Optional.of(str + ":" + port);
import java.util.function.Predicate;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
import org.openhab.binding.yamahareceiver.internal.config.YamahaUtils;
elements.forEach(e -> {
String tag = e.getAttribute("YNC_Tag");
- if (StringUtils.isNotEmpty(tag)) {
+ if (!tag.isEmpty()) {
T key = converter.apply(tag);
if (key != null) {
V value = factory.apply(key, e);
import java.lang.ref.WeakReference;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
// Retrieve Main_Zone basic status, from which we will know this AVR supports Zone_B feature.
Node basicStatusNode = getZoneResponse(con, Main_Zone, ZONE_BASIC_STATUS_CMD, ZONE_BASIC_STATUS_PATH);
String power = getNodeContentOrEmpty(basicStatusNode, "Power_Control/Zone_B_Power_Info");
- if (StringUtils.isNotEmpty(power)) {
+ if (!power.isEmpty()) {
logger.debug("Zone_2 emulation enabled via Zone_B");
state.zones.add(Zone_2);
state.features.add(Feature.ZONE_B);
import java.util.Set;
import java.util.stream.Stream;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
import org.openhab.binding.yamahareceiver.internal.protocol.InputConverter;
private Map<String, String> createMapFromSetting(String setting) {
Map<String, String> map = new HashMap<>();
- if (!StringUtils.isEmpty(setting)) {
+ if (setting != null && !setting.isEmpty()) {
String[] entries = setting.split(","); // will contain KEY=VALUE entires
for (String entry : entries) {
String[] keyValue = entry.split("="); // split the KEY=VALUE string
import java.io.IOException;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.config.YamahaBridgeConfig;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPlayControl;
// Spotify and NET RADIO input supports song cover image (at least on RX-S601D)
String songImageUrl = getNodeContentOrEmpty(node, "Play_Info/Album_ART/URL");
- msg.songImageUrl = StringUtils.isNotEmpty(songImageUrl)
- ? String.format("http://%s%s", con.getHost(), songImageUrl)
+ msg.songImageUrl = !songImageUrl.isEmpty() ? String.format("http://%s%s", con.getHost(), songImageUrl)
: bridgeConfig.getAlbumUrl();
logger.trace("Playback: {}, Station: {}, Artist: {}, Album: {}, Song: {}, SongImageUrl: {}", msg.playbackMode,
import java.io.IOException;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPresetControl;
import org.openhab.binding.yamahareceiver.internal.protocol.ReceivedMessageParseException;
String value = getNodeContentOrDefault(itemNode, "Param", String.valueOf(i));
// For RX-V3900 when a preset slot is not used, this is how it looks
- if (StringUtils.isEmpty(title) && "Not Used".equalsIgnoreCase(value)) {
+ if (title.isEmpty() && "Not Used".equalsIgnoreCase(value)) {
continue;
}
String presetValue = getNodeContentOrEmpty(response, preset.getPath());
// fall back to second method of obtaining current preset (works for Tuner on RX-V3900)
- if (StringUtils.isEmpty(presetValue)) {
+ if (presetValue.isEmpty()) {
try {
Node presetResponse = getResponse(con, wrInput(preset.apply(GET_PARAM)), inputElement);
presetValue = getNodeContentOrEmpty(presetResponse, preset.getPath());
}
private int convertToPresetNumber(String presetValue) {
- if (StringUtils.isNotEmpty(presetValue)) {
+ if (!presetValue.isEmpty()) {
if (StringUtils.isNumeric(presetValue)) {
return Integer.parseInt(presetValue);
} else {
import java.io.IOException;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
import org.openhab.binding.yamahareceiver.internal.protocol.InputWithPresetControl;
import org.openhab.binding.yamahareceiver.internal.protocol.InputWithTunerBandControl;
// store last state of band
bandState = msgForBand;
- if (StringUtils.isEmpty(msgForBand.band)) {
+ if (msgForBand.band.isEmpty()) {
logger.warn("Band is unknown for input {}, therefore preset and playback information will not be available",
inputID);
} else {
import java.util.Arrays;
import java.util.Optional;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.filter(x -> x.toLowerCase().startsWith(HEADER_CHARSET_PART))
.map(x -> x.substring(HEADER_CHARSET_PART.length() + 1, x.length() - 1)).findFirst();
- if (charsetName.isPresent() && !StringUtils.isEmpty(charsetName.get())) {
+ if (charsetName.isPresent() && !charsetName.get().isEmpty()) {
try {
charset = Charset.forName(charsetName.get());
} catch (UnsupportedCharsetException | IllegalCharsetNameException e) {
import java.lang.ref.WeakReference;
import java.util.function.Supplier;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
import org.openhab.binding.yamahareceiver.internal.config.YamahaZoneConfig;
import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
ZONE_BASIC_STATUS_PATH);
String surroundProgram = getNodeContentOrEmpty(basicStatusNode, "Surr/Pgm_Sel/Pgm");
- if (StringUtils.isNotEmpty(surroundProgram)) {
+ if (!surroundProgram.isEmpty()) {
surroundSelProgram = new CommandTemplate(
"<Surr><Pgm_Sel><Straight>Off</Straight><Pgm>%s</Pgm></Pgm_Sel></Surr>", "Surr/Pgm_Sel/Pgm");
logger.debug("Zone {} - adjusting command to: {}", getZone(), surroundSelProgram);
value = getNodeContentOrEmpty(statusNode, inputSel.getPath());
state.inputID = inputConverterSupplier.get().fromStateName(value);
- if (StringUtils.isBlank(state.inputID)) {
+ if (state.inputID == null || state.inputID.isBlank()) {
throw new ReceivedMessageParseException("Expected inputID. Failed to read Input/Input_Sel");
}
*/
package org.openhab.binding.yamahareceiver.internal.state;
-import org.apache.commons.lang.StringUtils;
import org.openhab.binding.yamahareceiver.internal.protocol.xml.InputWithNavigationControlXML;
/**
public String getAllItemLabels() {
StringBuilder sb = new StringBuilder();
for (String item : items) {
- if (StringUtils.isNotEmpty(item)) {
+ if (item != null && !item.isEmpty()) {
sb.append(item);
sb.append(',');
}
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.zway.internal.config.ZWayBridgeConfiguration;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.Bridge;
****************************************/
// Z-Way IP address
- if (StringUtils.trimToNull(config.getZWayIpAddress()) == null) {
+ String zWayIpAddress = config.getZWayIpAddress();
+ if (zWayIpAddress == null || zWayIpAddress.isBlank()) {
config.setZWayIpAddress("localhost"); // default value
}
}
// Z-Way Protocol
- if (StringUtils.trimToNull(config.getZWayProtocol()) == null) {
+ String zWayProtocol = config.getZWayProtocol();
+ if (zWayProtocol == null || zWayProtocol.isBlank()) {
config.setZWayProtocol("http");
}
// Z-Way Password
- if (StringUtils.trimToNull(config.getZWayPassword()) == null) {
+ String zWayPassword = config.getZWayPassword();
+ if (zWayPassword == null || zWayPassword.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"The connection to the Z-Way Server can't established, because the Z-Way password is missing. Please set a Z-Way password.");
return null;
}
// Z-Way Username
- if (StringUtils.trimToNull(config.getZWayUsername()) == null) {
+ String zWayUsername = config.getZWayUsername();
+ if (zWayUsername == null || zWayUsername.isBlank()) {
config.setZWayUsername("admin"); // default value
}
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.zway.internal.config.ZWayZAutomationDeviceConfiguration;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
private ZWayZAutomationDeviceConfiguration loadAndCheckConfiguration() {
ZWayZAutomationDeviceConfiguration config = getConfigAs(ZWayZAutomationDeviceConfiguration.class);
- if (StringUtils.trimToNull(config.getDeviceId()) == null) {
+ String deviceId = config.getDeviceId();
+ if (deviceId == null || deviceId.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Z-Wave device couldn't create, because the device id is missing.");
return null;
*/
package org.openhab.io.imperihome.internal.action;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.items.Item;
import org.openhab.core.items.events.ItemCommandEvent;
if (device.getType() != DeviceType.THERMOSTAT) {
return false;
}
- return StringUtils.isNotBlank(device.getLinks().get("curmode"));
+ String curmode = device.getLinks().get("curmode");
+ return curmode != null && !curmode.isBlank();
}
@Override
*/
package org.openhab.io.imperihome.internal.action;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.items.Item;
import org.openhab.core.items.events.ItemCommandEvent;
@Override
public boolean supports(AbstractDevice device, Item item) {
- return device.getType() == DeviceType.SHUTTER && StringUtils.isNotBlank(device.getLinks().get("stopper"));
+ String stopper = device.getLinks().get("stopper");
+ return device.getType() == DeviceType.SHUTTER && stopper != null && !stopper.isBlank();
}
@Override
*/
package org.openhab.io.imperihome.internal.model.device;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.types.State;
public void stateUpdated(Item item, State newState) {
super.stateUpdated(item, newState);
- DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+ DecimalType value = item.getStateAs(DecimalType.class);
if (getLinks().containsKey(LINK_WATTS) || getUnit().equalsIgnoreCase(LINK_KWH)) {
addParam(new NumericValueParam(ParamType.KWH, getUnit(), value));
}
NumericValueParam wattsParam = new NumericValueParam(ParamType.WATTS, valueParam.getUnit(), null);
- if (StringUtils.isEmpty(wattsParam.getUnit())) {
+ String unit = wattsParam.getUnit();
+ if (unit == null || unit.isEmpty()) {
wattsParam.setUnit("W");
}
wattsParam.setValue(valueParam.getValue());
}
NumericValueParam kwhParam = new NumericValueParam(ParamType.KWH, valueParam.getUnit(), null);
- if (StringUtils.isEmpty(kwhParam.getUnit())) {
+ String unit = kwhParam.getUnit();
+ if (unit == null || unit.isEmpty()) {
kwhParam.setUnit("KWh");
}
kwhParam.setValue(valueParam.getValue());
*/
package org.openhab.io.imperihome.internal.model.device;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.types.State;
}
NumericValueParam accumParam = new NumericValueParam(ParamType.ACCUMULATION, valueParam.getUnit(), null);
- if (StringUtils.isEmpty(accumParam.getUnit())) {
+ String unit = accumParam.getUnit();
+ if (unit == null || unit.isBlank()) {
accumParam.setUnit("mm");
}
public void stateUpdated(Item item, State newState) {
super.stateUpdated(item, newState);
- DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+ DecimalType value = item.getStateAs(DecimalType.class);
addParam(new NumericValueParam(ParamType.RAIN_VALUE, getUnit(), value));
}
}
import java.math.BigDecimal;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.PercentType;
*/
package org.openhab.io.imperihome.internal.model.device;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
boolean tripped = false;
if (item.getStateAs(OpenClosedType.class) != null) {
- OpenClosedType state = (OpenClosedType) item.getStateAs(OpenClosedType.class);
+ OpenClosedType state = item.getStateAs(OpenClosedType.class);
tripped = state == OpenClosedType.CLOSED;
} else if (item.getStateAs(OnOffType.class) != null) {
- OnOffType state = (OnOffType) item.getStateAs(OnOffType.class);
+ OnOffType state = item.getStateAs(OnOffType.class);
tripped = state == OnOffType.ON;
} else if (item.getStateAs(DecimalType.class) != null) {
- DecimalType state = (DecimalType) item.getStateAs(DecimalType.class);
- tripped = state.intValue() != 0;
+ DecimalType state = item.getStateAs(DecimalType.class);
+ tripped = state != null && state.intValue() != 0;
} else if (item.getStateAs(StringType.class) != null) {
- StringType state = (StringType) item.getStateAs(StringType.class);
- tripped = StringUtils.isNotBlank(state.toString()) && !state.toString().trim().equals("ok");
+ StringType state = item.getStateAs(StringType.class);
+ tripped = state != null && !state.toString().isBlank() && !state.toString().trim().equals("ok");
} else {
logger.debug("Can't interpret state {} as tripped status", item.getState());
}
*/
package org.openhab.io.imperihome.internal.model.device;
-import org.apache.commons.lang.StringUtils;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.types.State;
}
NumericValueParam dirParam = new NumericValueParam(ParamType.DIRECTION, valueParam.getUnit(), null);
- if (StringUtils.isEmpty(dirParam.getUnit())) {
+ String unit = dirParam.getUnit();
+ if (unit == null || unit.isEmpty()) {
dirParam.setUnit("Degrees");
}
public void stateUpdated(Item item, State newState) {
super.stateUpdated(item, newState);
- DecimalType value = (DecimalType) item.getStateAs(DecimalType.class);
+ DecimalType value = item.getStateAs(DecimalType.class);
addParam(new NumericValueParam(ParamType.SPEED, getUnit(), value));
}
}
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.BooleanUtils;
import org.openhab.core.items.Item;
import org.openhab.core.items.ItemRegistry;
import org.openhab.core.items.ItemRegistryChangeListener;
String icon = issTags.get(TagType.ICON).get(0);
if (!icon.toLowerCase().startsWith("http")) {
- if (StringUtils.isEmpty(config.getRootUrl())) {
+ String rootUrl = config.getRootUrl();
+ if (rootUrl == null || rootUrl.isEmpty()) {
logger.error("Can't set icon; 'openhab.rootUrl' not set in configuration");
return;
}
- icon = config.getRootUrl() + "icon/" + icon;
+ icon = rootUrl + "icon/" + icon;
}
device.addParam(new DeviceParam(ParamType.DEFAULT_ICON, icon));
return issTags.get(TagType.LABEL).get(0);
}
- if (StringUtils.isNotBlank(item.getLabel())) {
- String label = item.getLabel().trim();
+ String label = item.getLabel();
+ if (label != null && !label.isBlank()) {
+ label = label.trim();
if (label.matches("\\[.*\\]$")) {
label = label.substring(0, label.indexOf('['));
}
import javax.servlet.ServletException;
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.binding.BindingInfoRegistry;
* @param brainId the non-empty brain id
* @return the servlet for the brainId or null if none
*/
- @Nullable
- public NeeoBrainServlet getServlet(String brainId) {
+ public @Nullable NeeoBrainServlet getServlet(String brainId) {
NeeoUtil.requireNotEmpty(brainId, "brainId cannot be empty");
final String url = NeeoUtil.getServletUrl(brainId);
* @param servletUrl a non-null, non-empty servlet URL
* @return the servlet for the URL or null if not found
*/
- @Nullable
- private NeeoBrainServlet getServletByUrl(String servletUrl) {
+ private @Nullable NeeoBrainServlet getServletByUrl(String servletUrl) {
NeeoUtil.requireNotEmpty(servletUrl, "ServletURL cannot be empty");
for (NeeoBrainServlet servlet : servlets) {
- if (StringUtils.equalsIgnoreCase(servletUrl, servlet.getServletUrl())) {
+ if (servletUrl.equalsIgnoreCase(servlet.getServletUrl())) {
return servlet;
}
}
return Collections.singleton(ItemStateChangedEvent.TYPE);
}
- @Nullable
@Override
- public EventFilter getEventFilter() {
+ public @Nullable EventFilter getEventFilter() {
return eventFilter;
}
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
-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.openhab.core.events.Event;
private final String servletUrl;
/** Any event filters */
- @Nullable
- private final List<EventFilter> eventFilters;
+ private final @Nullable List<EventFilter> eventFilters;
/**
* Creates a servlet to serve the status/definitions web pages
final String pathInfo = NeeoUtil.decodeURIComponent(req.getPathInfo());
// invalid path - probably someone typed the path in manually
- if (StringUtils.isEmpty(pathInfo)) {
+ if (pathInfo.isEmpty()) {
return;
}
* @param paths the non-null, non-empty paths
* @return the service that can handle the path or null if none can
*/
- @Nullable
- protected ServletService getService(String[] paths) {
+ protected @Nullable ServletService getService(String[] paths) {
Objects.requireNonNull(paths, "paths cannot be null");
if (paths.length == 0) {
throw new IllegalArgumentException("paths cannot be of 0 length");
*
* @return the possibly null event filters;
*/
- @Nullable
- public List<EventFilter> getEventFilters() {
+ public @Nullable List<EventFilter> getEventFilters() {
return eventFilters;
}
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.http.HttpStatus;
}
for (NeeoRecipe recipe : GSON.fromJson(resp.getContent(), NeeoRecipe[].class)) {
- if (StringUtils.equalsIgnoreCase(recipe.getUid(), deviceKey)) {
+ if (deviceKey.equalsIgnoreCase(recipe.getUid())) {
final NeeoRecipeUrls urls = recipe.getUrls();
final String url = urls == null ? null : (on ? urls.getSetPowerOn() : urls.getSetPowerOff());
- if (url != null && StringUtils.isNotEmpty(url)) {
+ if (url != null && !url.isEmpty()) {
final HttpResponse cmdResp = rqst.sendGetCommand(url);
if (cmdResp.getHttpCode() != HttpStatus.OK_200) {
throw cmdResp.createException();
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.Thing;
// filter for only things that are still valid
final ThingRegistry thingRegistry = context.getThingRegistry();
for (NeeoDevice device : uidToDevice.values()) {
- if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, device.getUid().getBindingId())) {
+ if (NeeoConstants.NEEOIO_BINDING_ID.equalsIgnoreCase(device.getUid().getBindingId())) {
devices.add(device);
} else {
if (thingRegistry.get(device.getUid().asThingUID()) != null) {
final List<NeeoDevice> devices = new ArrayList<>();
for (NeeoDevice device : exposeAll || exposeNeeoBinding ? getAllDevices() : uidToDevice.values()) {
if (device.getExposedChannels().length > 0 && !NeeoDeviceType.EXCLUDE.equals(device.getType())
- && StringUtils.isNotEmpty(device.getType().toString())) {
+ && !device.getType().toString().isEmpty()) {
devices.add(device);
}
}
for (NeeoDevice device : uidToDevice.values()) {
if (keys.isBound(device.getUid())) {
for (NeeoDeviceChannel channel : device.getExposedChannels()) {
- if (itemName == null || StringUtils.equalsIgnoreCase(itemName, channel.getItemName())) {
+ if (itemName == null || itemName.equalsIgnoreCase(channel.getItemName())) {
channels.add(new AbstractMap.SimpleImmutableEntry<>(device, channel));
}
}
public List<NeeoDevice> getAllDevices() {
final List<NeeoDevice> devices = new ArrayList<>();
for (Entry<NeeoThingUID, NeeoDevice> entry : uidToDevice.entrySet()) {
- if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, entry.getKey().getBindingId())) {
+ if (NeeoConstants.NEEOIO_BINDING_ID.equalsIgnoreCase(entry.getKey().getBindingId())) {
devices.add(entry.getValue());
} else {
final Thing thing = context.getThingRegistry().get(entry.getKey().asThingUID());
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.http.HttpStatus;
import org.openhab.core.thing.ThingUID;
sb.append("[");
sb.append(entry.getKey());
sb.append("=");
- sb.append(StringUtils.join(entries.toArray()));
+ sb.append(entries.stream().map(Object::toString).collect(Collectors.joining()));
sb.append("]");
}
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
return new NeeoItemValue(convertedState == UpDownType.UP);
} else if (convertedState instanceof DecimalType) {
- if (StringUtils.isEmpty(format) || channel.getType() == NeeoCapabilityType.SLIDER) {
+ if (format == null || format.isEmpty() || channel.getType() == NeeoCapabilityType.SLIDER) {
return new NeeoItemValue(((DecimalType) convertedState).toBigDecimal());
}
} else if (convertedState instanceof UnDefType) {
// Formatting must use the actual state (not converted state) to avoid
// issues where a decimal converted to string or otherwise
String itemValue;
- if (format != null && StringUtils.isNotEmpty(format)) {
+ if (format != null && !format.isEmpty()) {
if (state instanceof UnDefType) {
itemValue = formatUndefined(format);
} else if (state instanceof Type) {
Objects.requireNonNull(item, "item cannot be null");
Objects.requireNonNull(eventType, "eventType cannot be null");
- if (actionValue == null || StringUtils.isEmpty(actionValue)) {
+ if (actionValue == null || actionValue.isEmpty()) {
return null;
}
}
break;
case "switch":
- if (StringUtils.equalsIgnoreCase("true", actionValue)) {
+ if ("true".equalsIgnoreCase(actionValue)) {
return OnOffType.ON;
- } else if (StringUtils.equalsIgnoreCase("false", actionValue)) {
+ } else if ("false".equalsIgnoreCase(actionValue)) {
return OnOffType.OFF;
}
break;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final PrintWriter pw = resp.getWriter();
- if (StringUtils.isEmpty(str)) {
+ if (str.isEmpty()) {
pw.print("{}");
} else {
pw.print(str);
*/
public static void requireNotEmpty(String value, String msg) {
Objects.requireNonNull(value, msg);
- if (StringUtils.isEmpty(value)) {
+ if (value.isEmpty()) {
throw new IllegalArgumentException(msg);
}
}
if (cmd.isEnum()) {
for (Command cmdEnum : cmd.getEnumConstants()) {
- if (StringUtils.equalsIgnoreCase(((Enum<?>) cmdEnum).name(), enumName)) {
+ if (((Enum<?>) cmdEnum).name().equalsIgnoreCase(enumName)) {
return cmdEnum;
}
}
public static String getLabel(@Nullable Item item, @Nullable ChannelType channelType) {
if (item != null) {
final String label = item.getLabel();
- if (label != null && StringUtils.isNotEmpty(label)) {
+ if (label != null && !label.isEmpty()) {
return label;
}
}
if (channelType != null) {
final String label = channelType.getLabel();
- if (StringUtils.isNotEmpty(label)) {
+ if (!label.isEmpty()) {
return label;
}
}
if (item != null) {
final StateDescription sd = item.getStateDescription();
final String format = sd == null ? null : sd.getPattern();
- if (StringUtils.isEmpty(format)) {
- if (StringUtils.equalsIgnoreCase("datetime", item.getType())) {
+ if (format == null || format.isEmpty()) {
+ if ("datetime".equalsIgnoreCase(item.getType())) {
return "%tF %<tT";
}
} else {
if (channelType != null) {
final String format = channelType.getState() == null ? null : channelType.getState().getPattern();
- if (StringUtils.isEmpty(format)) {
- if (StringUtils.equalsIgnoreCase("datetime", channelType.getItemType())) {
+ if (format == null || format.isEmpty()) {
+ if ("datetime".equalsIgnoreCase(channelType.getItemType())) {
return "%tF %<tT";
}
} else {
public static String getUniqueLabel(Set<String> labels, String itemLabel) {
Objects.requireNonNull(labels, "labels cannot be null");
- String label = StringUtils.isEmpty(itemLabel) ? "NA" : itemLabel;
+ String label = itemLabel.isEmpty() ? "NA" : itemLabel;
int idx = 0;
if (labels.contains(label)) {
do {
if (groupId != null) {
for (ChannelGroupDefinition cgd : thingType.getChannelGroupDefinitions()) {
- if (StringUtils.equals(groupId, cgd.getId())) {
+ if (Objects.equals(groupId, cgd.getId())) {
return cgd.getLabel();
}
}
import java.util.Objects;
import java.util.Set;
-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.openhab.core.items.Item;
.getChannelType(channel.getChannelTypeUID());
NeeoCapabilityType type = NeeoCapabilityType.EXCLUDE;
- if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOBINDING_BINDING_ID, thingUID.getBindingId())) {
- if (StringUtils.startsWithIgnoreCase(thingUID.getAsString(), NeeoConstants.NEEOBINDING_DEVICE_ID)) {
+ if (NeeoConstants.NEEOBINDING_BINDING_ID.equalsIgnoreCase(thingUID.getBindingId())) {
+ if (thingUID.getAsString().toLowerCase()
+ .startsWith(NeeoConstants.NEEOBINDING_DEVICE_ID.toLowerCase())) {
// all device channels are currently macros - so buttons are appropriate
type = NeeoCapabilityType.BUTTON;
} else {
return null;
}
- if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOBINDING_BINDING_ID, thing.getUID().getBindingId())) {
+ if (NeeoConstants.NEEOBINDING_BINDING_ID.equalsIgnoreCase(thing.getUID().getBindingId())) {
final Map<String, String> properties = thing.getProperties();
/** The following properties have matches in org.openhab.binding.neeo.NeeoDeviceHandler.java */
String neeoType = properties.get("Type");
final NeeoDeviceTiming timing = new NeeoDeviceTiming(standbyDelay, switchDelay, shutDownDelay);
final String dc = properties.get("Device Capabilities");
- final String[] deviceCapabilities = StringUtils.isEmpty(dc) ? new String[0] : StringUtils.split(dc, ',');
+ final String[] deviceCapabilities = dc == null || dc.isEmpty() ? new String[0] : StringUtils.split(dc, ',');
try {
return new NeeoDevice(new NeeoThingUID(thing.getUID()), 0,
* @param value a possibly null, possibly empty value to parse
* @return an Integer or null if not a number
*/
- @Nullable
- private static Integer parseInteger(String value) {
- if (StringUtils.isEmpty(value)) {
+
+ private static @Nullable Integer parseInteger(String value) {
+ if (value.isEmpty()) {
return null;
}
try {
*/
@Nullable
List<NeeoDeviceChannel> getNeeoDeviceChannel(String itemName) {
- if (StringUtils.isEmpty(itemName)) {
+ if (itemName.isEmpty()) {
return null;
}
import java.util.Objects;
import java.util.UUID;
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.binding.BindingInfoRegistry;
import org.openhab.core.events.EventPublisher;
import java.util.Objects;
import java.util.stream.Collectors;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.binding.BindingInfo;
final Thing thing = context.getThingRegistry().get(device.getUid().asThingUID());
if (thing != null) {
final String location = thing.getLocation();
- if (location != null && StringUtils.isNotEmpty(location)) {
+ if (location != null && !location.isEmpty()) {
score += search(location, needles);
}
int arrayLength = needles.length;
for (int i = 0; i < arrayLength; i++) {
String needle = needles[i];
- int stringPos = StringUtils.indexOfIgnoreCase(haystack, needle);
+ int stringPos = haystack.toLowerCase().indexOf(needle.toLowerCase());
int tokenScore = 0;
if (stringPos > -1) {
if (needle.length() < 2) {
tokenScore = 1;
} else {
- if (StringUtils.equalsIgnoreCase(haystack, needle)) {
+ if (haystack.equalsIgnoreCase(needle)) {
tokenScore = 6;
} else if (stringPos == 0) {
tokenScore = 2;
import javax.jmdns.ServiceListener;
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.common.ThreadPoolManager;
final String[] ipAddresses = gson.fromJson(json, String[].class);
if (ipAddresses != null) {
logger.debug("Restoring discovery from {}: {}", file.getAbsolutePath(),
- StringUtils.join(ipAddresses, ','));
+ String.join(",", ipAddresses));
for (String ipAddress : ipAddresses) {
- if (StringUtils.isNotBlank(ipAddress)) {
+ if (!ipAddress.isBlank()) {
addDiscovered(ipAddress, false);
}
}
@Nullable
private Entry<String, InetAddress> getNeeoBrainInfo(ServiceInfo info) {
Objects.requireNonNull(info, "info cannot be null");
- if (!StringUtils.equals("neeo", info.getApplication())) {
+ if (!"neeo".equals(info.getApplication())) {
logger.debug("A non-neeo application was found for the NEEO MDNS: {}", info);
return null;
}
systemsLock.lock();
try {
final Optional<NeeoSystemInfo> sysInfo = systems.keySet().stream()
- .filter(e -> StringUtils.equals(servletUrl, NeeoUtil.getServletUrl(e.getHostname()))).findFirst();
+ .filter(e -> servletUrl.equals(NeeoUtil.getServletUrl(e.getHostname()))).findFirst();
if (sysInfo.isPresent()) {
systems.remove(sysInfo.get());
fireRemoved(sysInfo.get());
try {
NeeoSystemInfo foundInfo = null;
for (NeeoSystemInfo existingSysInfo : systems.keySet()) {
- if (StringUtils.equals(existingSysInfo.getHostname(), brainInfo.getKey())) {
+ if (existingSysInfo.getHostname().equals(brainInfo.getKey())) {
foundInfo = existingSysInfo;
break;
}
final List<String> ipAddresses = systems.values().stream().map(e -> e.getHostAddress())
.collect(Collectors.toList());
- logger.debug("Saving brain's discovered to {}: {}", file.toPath(), StringUtils.join(ipAddresses, ','));
+ logger.debug("Saving brain's discovered to {}: {}", file.toPath(), String.join(",", ipAddresses));
final String json = gson.toJson(ipAddresses);
final byte[] contents = json.getBytes(StandardCharsets.UTF_8);
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* @return the ItemSubType type
*/
public static ItemSubType parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return NONE;
}
for (ItemSubType enm : ItemSubType.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return enm;
}
}
* @return true if valid, false otherwise
*/
public static boolean isValid(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return true;
}
for (ItemSubType enm : ItemSubType.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return true;
}
}
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* @return the ListUiAction type
*/
public static ListUiAction parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return CLOSE;
}
for (ListUiAction enm : ListUiAction.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return enm;
}
}
* @return true if valid, false otherwise
*/
public static boolean isValid(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return true;
}
for (ListUiAction enm : ListUiAction.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return true;
}
}
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
*/
@Nullable
public static NeeoButtonGroup parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return null;
}
// note: if we add more - might want to switch this into a loop
- if (StringUtils.equalsIgnoreCase(text, POWERONOFF.text)) {
+ if (text.equalsIgnoreCase(POWERONOFF.text)) {
return POWERONOFF;
}
- if (StringUtils.equalsIgnoreCase(text, VOLUMES.text)) {
+ if (text.equalsIgnoreCase(VOLUMES.text)) {
return VOLUMES;
}
- if (StringUtils.equalsIgnoreCase(text, CHANNELS.text)) {
+ if (text.equalsIgnoreCase(CHANNELS.text)) {
return CHANNELS;
}
- if (StringUtils.equalsIgnoreCase(text, CURSORUPDOWN.text)) {
+ if (text.equalsIgnoreCase(CURSORUPDOWN.text)) {
return CURSORUPDOWN;
}
- if (StringUtils.equalsIgnoreCase(text, CURSORLEFTRIGHT.text)) {
+ if (text.equalsIgnoreCase(CURSORLEFTRIGHT.text)) {
return CURSORLEFTRIGHT;
}
* @return true if matches, false otherwise
*/
public boolean equals(String text) {
- return StringUtils.equalsIgnoreCase(this.text, text);
+ return this.text.equalsIgnoreCase(text);
}
@Override
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.type.ChannelType;
* @return the NeeoCapabilityType type
*/
public static NeeoCapabilityType parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return EXCLUDE;
}
for (NeeoCapabilityType enm : NeeoCapabilityType.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return enm;
}
}
* @return the best guess {@link NeeoCapabilityType}
*/
public static NeeoCapabilityType guessType(@Nullable ChannelType channelType) {
- if (channelType == null || StringUtils.isEmpty(channelType.getItemType())) {
+ String itemType = channelType == null ? null : channelType.getItemType();
+ if (channelType == null || itemType == null || itemType.isEmpty()) {
return NeeoCapabilityType.EXCLUDE;
}
- switch (channelType.getItemType().toLowerCase()) {
+ switch (itemType.toLowerCase()) {
case "switch":
case "contact":
case "rollershutter":
import java.util.Objects;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
/**
* The specific name for the device, if null - NEEO will default it based on the type (ie "ACCESSORY", etc)
*/
- @Nullable
- private final String specificName;
+
+ private final @Nullable String specificName;
/**
* The icon name to assign. If null, NEEO will default it to a standard icon based on the type
*/
- @Nullable
- private final String iconName;
+ private final @Nullable String iconName;
/**
* The driver version for the device
this.driverVersion = driverVersion;
this.type = type;
this.manufacturer = manufacturer;
- this.name = name == null || StringUtils.isEmpty(name) ? "(N/A)" : name;
+ this.name = name == null || name.isEmpty() ? "(N/A)" : name;
this.specificName = specificName;
this.iconName = iconName;
this.channels.addAll(channels);
*
* @return a possibly null, possibly empty specific name
*/
- @Nullable
- public String getSpecificName() {
+ public @Nullable String getSpecificName() {
return specificName;
}
*
* @return a possibly null, possibly empty icon name
*/
- @Nullable
- public String getIconName() {
+ public @Nullable String getIconName() {
return iconName;
}
*
* @return a possibly null {@link NeeoDeviceTiming}
*/
- @Nullable
- public NeeoDeviceTiming getDeviceTiming() {
+ public @Nullable NeeoDeviceTiming getDeviceTiming() {
if (supportTiming(this)) {
return timing;
}
public NeeoDeviceChannel[] getExposedChannels() {
final List<NeeoDeviceChannel> exposedChannels = new ArrayList<>(channels.size());
for (NeeoDeviceChannel channel : channels) {
- if (channel.getType() != NeeoCapabilityType.EXCLUDE
- && StringUtils.isNotEmpty(channel.getType().toString())) {
+ if (channel.getType() != NeeoCapabilityType.EXCLUDE && !channel.getType().toString().isEmpty()) {
exposedChannels.add(channel);
}
}
for (NeeoDeviceChannel channel : channels) {
final boolean notExcluded = channel.getType() != NeeoCapabilityType.EXCLUDE;
- final boolean notEmpty = StringUtils.isNotEmpty(channel.getType().toString());
- final boolean isItemMatch = StringUtils.equalsIgnoreCase(itemName, channel.getItemName());
+ final boolean notEmpty = !channel.getType().toString().isEmpty();
+ final boolean isItemMatch = itemName.equalsIgnoreCase(channel.getItemName());
logger.trace("isExposed(channel): {} --- notExcluded({}) -- notEmpty({}) -- isItemMatch({}) -- {}",
itemName, notExcluded, notEmpty, isItemMatch, channel);
* @param channelNbr the channel nbr
* @return the channel or null if none found
*/
- @Nullable
- public NeeoDeviceChannel getChannel(String itemName, ItemSubType subType, int channelNbr) {
+ public @Nullable NeeoDeviceChannel getChannel(String itemName, ItemSubType subType, int channelNbr) {
NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
Objects.requireNonNull(subType, "subType cannot be null");
for (NeeoDeviceChannel channel : channels) {
- if (StringUtils.equalsIgnoreCase(itemName, channel.getItemName()) && channel.getSubType() == subType
+ if (itemName.equalsIgnoreCase(channel.getItemName()) && channel.getSubType() == subType
&& channel.getChannelNbr() == channelNbr) {
return channel;
}
* @param context the non-null service context
* @return the new {@link NeeoDevice} or null if the {@link Thing} doesn't exist anymore
*/
- @Nullable
- public NeeoDevice merge(ServiceContext context) {
+ public @Nullable NeeoDevice merge(ServiceContext context) {
Objects.requireNonNull(context, "context cannot be null");
- if (StringUtils.equalsIgnoreCase(NeeoConstants.NEEOIO_BINDING_ID, uid.getBindingId())) {
+ if (NeeoConstants.NEEOIO_BINDING_ID.equals(uid.getBindingId())) {
return this;
}
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.type.ChannelKind;
* @return the NeeoDeviceChannelKind type
*/
public static NeeoDeviceChannelKind parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return ITEM;
}
for (NeeoDeviceChannelKind enm : NeeoDeviceChannelKind.values()) {
- if (StringUtils.equalsIgnoreCase(text, enm.text)) {
+ if (text.equalsIgnoreCase(enm.text)) {
return enm;
}
}
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.items.Item;
import org.openhab.core.library.types.PercentType;
}
this.minValue = minValue;
this.maxValue = maxValue;
- this.unit = StringUtils.isEmpty(unit) ? UNIT_NUMBER : unit;
+ this.unit = unit.isEmpty() ? UNIT_NUMBER : unit;
}
/**
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
*/
private NeeoDeviceType(final String text) {
Objects.requireNonNull(text, "text is required");
- this.text = StringUtils.equalsIgnoreCase(text, ACCESSORY) ? ACCESSOIRE.text : text;
+ this.text = text.equalsIgnoreCase(ACCESSORY) ? ACCESSOIRE.text : text;
}
/**
* @return the possibly null NeeoDeviceType
*/
public static NeeoDeviceType parse(final String text) {
- if (StringUtils.isEmpty(text)) {
+ if (text.isEmpty()) {
return EXCLUDE;
}
- if (StringUtils.equalsIgnoreCase(text, ACCESSOIRE.text) || StringUtils.equalsIgnoreCase(text, ACCESSORY)) {
+ if (text.equalsIgnoreCase(ACCESSOIRE.text) || text.equalsIgnoreCase(ACCESSORY)) {
return ACCESSOIRE;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
- return StringUtils.equals(text, ((NeeoDeviceType) obj).text);
+ return text.equals(((NeeoDeviceType) obj).text);
}
@Override
*/
package org.openhab.io.neeo.internal.models;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.NeeoUtil;
private final String title;
/** The URI to the thumbnail representing the item */
- @Nullable
- private final String thumbnailUri;
+ private final @Nullable String thumbnailUri;
/** The browse identifier (reflected back in a request if this item is a container) */
- @Nullable
- private final String browseIdentifier;
+ private final @Nullable String browseIdentifier;
/** The action identifier (reflected back in a request if this is a leaf) */
- @Nullable
- private final String actionIdentifier;
+ private final @Nullable String actionIdentifier;
/** Whether the item is queueable (no explanation posted by NEEO) */
private final boolean isQueueable;
@Nullable String actionIdentifier, boolean isQueueable) {
NeeoUtil.requireNotEmpty(title, "title cannot be empty");
- if (StringUtils.isEmpty(browseIdentifier) && StringUtils.isEmpty(actionIdentifier)) {
+ if ((browseIdentifier == null || browseIdentifier.isEmpty())
+ && (actionIdentifier == null || actionIdentifier.isEmpty())) {
throw new IllegalArgumentException("Either browserIdentifier or actionIdentifier must be specified");
}
*/
package org.openhab.io.neeo.internal.models;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.NeeoUtil;
NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
this.type = deviceKey + ":" + itemName;
- this.data = data == null || (data instanceof String && StringUtils.isEmpty(data.toString())) ? "-" : data;
+ this.data = data == null || (data instanceof String && data.toString().isEmpty()) ? "-" : data;
}
/**
*/
package org.openhab.io.neeo.internal.models;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.NeeoConstants;
NeeoUtil.requireNotEmpty(deviceKey, "deviceKey cannot be empty");
NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty");
- this.type = overrideType == null || StringUtils.isEmpty(overrideType)
- ? NeeoConstants.NEEO_SENSOR_NOTIFICATION_TYPE
+ this.type = overrideType == null || overrideType.isEmpty() ? NeeoConstants.NEEO_SENSOR_NOTIFICATION_TYPE
: overrideType;
this.data = new SensorNotificationData(
deviceKey + ":" + itemName
- + (StringUtils.endsWithIgnoreCase(itemName, NeeoConstants.NEEO_SENSOR_SUFFIX) ? ""
+ + (itemName.toLowerCase().endsWith(NeeoConstants.NEEO_SENSOR_SUFFIX.toLowerCase()) ? ""
: NeeoConstants.NEEO_SENSOR_SUFFIX),
- data == null || (data instanceof String && StringUtils.isEmpty(data.toString())) ? "-" : data);
+ data == null || (data instanceof String && data.toString().isEmpty()) ? "-" : data);
}
/**
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.NeeoUtil;
* @return true if greater than or equal, false otherwise
*/
public boolean isFirmwareGreaterOrEqual(String checkFirmwareVersion) {
- if (StringUtils.isEmpty(checkFirmwareVersion)) {
+ if (checkFirmwareVersion.isEmpty()) {
return true;
}
return false;
}
- return StringUtils.equals(hostname, ((NeeoSystemInfo) obj).hostname);
+ return hostname.equals(((NeeoSystemInfo) obj).hostname);
}
}
*/
package org.openhab.io.neeo.internal.models;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingUID;
import org.openhab.io.neeo.internal.NeeoConstants;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.NeeoConstants;
jsonObject.add("device", deviceObj);
final String specificName = device.getSpecificName();
- if (specificName != null && StringUtils.isNotEmpty(specificName)) {
+ if (specificName != null && !specificName.isEmpty()) {
deviceObj.addProperty("specificname", specificName);
jsonObject.addProperty("specificname", specificName);
- } else if (StringUtils.isNotEmpty(deviceName)) {
+ } else if (!deviceName.isEmpty()) {
deviceObj.addProperty("specificname", deviceName);
jsonObject.addProperty("specificname", deviceName);
}
final String iconName = device.getIconName();
- if (iconName != null && StringUtils.isNotEmpty(iconName)) {
+ if (iconName != null && !iconName.isEmpty()) {
deviceObj.addProperty("icon", iconName);
jsonObject.addProperty("icon", iconName);
}
final String uniqueItemName = channel.getUniqueItemName();
final String sensorItemName = uniqueItemName
- + (StringUtils.endsWithIgnoreCase(uniqueItemName, NeeoConstants.NEEO_SENSOR_SUFFIX) ? ""
+ + (uniqueItemName.toLowerCase().endsWith(NeeoConstants.NEEO_SENSOR_SUFFIX.toLowerCase()) ? ""
: NeeoConstants.NEEO_SENSOR_SUFFIX);
if (capabilityType == NeeoCapabilityType.BUTTON) {
- final String name = StringUtils.isEmpty(channel.getLabel()) ? uniqueItemName : channel.getLabel();
+ final String name = channel.getLabel().isEmpty() ? uniqueItemName : channel.getLabel();
if (channel.getKind() == NeeoDeviceChannelKind.TRIGGER) {
final String path = compPath + "/button/trigger";
capabilities.add(createBase(name, channel.getLabel(), capabilityType.toString(), path));
} else {
final String value = channel.getValue();
- final String path = compPath + "/button/" + (value == null || StringUtils.isEmpty(value) ? "on"
- : NeeoUtil.encodeURIComponent(value.trim()));
+ final String path = compPath + "/button/"
+ + (value == null || value.isEmpty() ? "on" : NeeoUtil.encodeURIComponent(value.trim()));
capabilities.add(createBase(name, channel.getLabel(), capabilityType.toString(), path));
}
} else if (capabilityType == NeeoCapabilityType.SENSOR_POWER) {
}
} else if (capabilityType == NeeoCapabilityType.IMAGEURL) {
final String value = channel.getValue();
- final String size = (value == null || StringUtils.isEmpty(value) ? "large" : value.trim())
- .toLowerCase();
+ final String size = (value == null || value.isEmpty() ? "large" : value.trim()).toLowerCase();
final JsonObject jo = createBase(uniqueItemName, channel.getLabel(), capabilityType.toString(),
compPath + "/image/actor", "sensor", new JsonPrimitive(sensorItemName));
compObj.addProperty("type", type);
compObj.addProperty("path", NeeoUtil.encodeURIComponent(path));
- if (sensor != null && StringUtils.isNotEmpty(sensorName)) {
+ if (sensor != null && sensorName != null && !sensorName.isEmpty()) {
if (sensor instanceof JsonPrimitive) {
compObj.addProperty(sensorName, sensor.getAsString());
} else {
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
final Item item = localContext.getItemRegistry().getItem(chnl.getItemName());
itemType = item.getType();
- if (StringUtils.isNotEmpty(item.getLabel())) {
- itemLabel = item.getLabel();
+ String label = item.getLabel();
+ if (label != null && !label.isEmpty()) {
+ itemLabel = label;
}
for (Class<? extends Command> cmd : item.getAcceptedCommandTypes()) {
- if (!StringUtils.equalsIgnoreCase(cmd.getSimpleName(), "refreshtype")) {
+ if (!cmd.getSimpleName().equalsIgnoreCase("refreshtype")) {
commandTypes.add(cmd.getSimpleName().toLowerCase());
}
}
itemType = "N/A";
}
- if (StringUtils.isNotEmpty(itemLabel)) {
+ if (!itemLabel.isEmpty()) {
switch (chnl.getSubType()) {
case HUE:
itemType += " (Hue)";
final JsonObject jo = (JsonObject) elm;
final String itemName = NeeoUtil.getString(jo, "itemName");
- if (itemName == null || StringUtils.isEmpty(itemName)) {
+ if (itemName == null || itemName.isEmpty()) {
throw new JsonParseException("Element requires an itemName attribute: " + elm);
}
final boolean labelVisible = jo.has("labelVisible") ? jo.get("labelVisible").getAsBoolean() : true;
return new NeeoDeviceChannelText(kind, itemName, channelNbr, capType, itemSubType,
- label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range,
- labelVisible);
+ label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range, labelVisible);
} else if (capType == NeeoCapabilityType.DIRECTORY) {
final NeeoDeviceChannelDirectoryListItem[] listItems = jo.has("listItems")
? context.deserialize(jo.get("listItems"), NeeoDeviceChannelDirectoryListItem[].class)
: new NeeoDeviceChannelDirectoryListItem[0];
return new NeeoDeviceChannelDirectory(kind, itemName, channelNbr, capType, itemSubType,
- label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range,
- listItems);
+ label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range, listItems);
} else {
return new NeeoDeviceChannel(kind, itemName, channelNbr, capType, itemSubType,
- label == null || StringUtils.isEmpty(label) ? NeeoUtil.NOTAVAILABLE : label, value, range);
+ label == null || label.isEmpty() ? NeeoUtil.NOTAVAILABLE : label, value, range);
}
} catch (NullPointerException | IllegalArgumentException e) {
throw new JsonParseException(e);
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.io.neeo.NeeoService;
import org.openhab.io.neeo.internal.NeeoBrainServlet;
*/
@Override
public boolean canHandleRoute(String[] paths) {
- return paths.length >= 1 && (StringUtils.equalsIgnoreCase(paths[0], "brainstatus")
- || StringUtils.equalsIgnoreCase(paths[0], "addbrain")
- || StringUtils.equalsIgnoreCase(paths[0], "removebrain")
- || StringUtils.equalsIgnoreCase(paths[0], "getlog")
- || StringUtils.equalsIgnoreCase(paths[0], "blinkled"));
+ return paths.length >= 1 && (paths[0].equalsIgnoreCase("brainstatus") || paths[0].equalsIgnoreCase("addbrain")
+ || paths[0].equalsIgnoreCase("removebrain") || paths[0].equalsIgnoreCase("getlog")
+ || paths[0].equalsIgnoreCase("blinkled"));
}
/**
Objects.requireNonNull(resp, "resp cannot be null");
try {
- if (StringUtils.equalsIgnoreCase(paths[0], "brainstatus")) {
+ if (paths[0].equalsIgnoreCase("brainstatus")) {
final List<BrainStatus> status = new ArrayList<>();
for (NeeoBrainServlet servlet : service.getServlets()) {
status.add(servlet.getBrainStatus());
}
NeeoUtil.write(resp, gson.toJson(status));
- } else if (StringUtils.equalsIgnoreCase(paths[0], "blinkled")) {
+ } else if (paths[0].equalsIgnoreCase("blinkled")) {
final String brainId = req.getParameter("brainid");
if (brainId == null) {
NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
}
}
}
- } else if (StringUtils.equalsIgnoreCase(paths[0], "getlog")) {
+ } else if (paths[0].equalsIgnoreCase("getlog")) {
final String brainId = req.getParameter("brainid");
if (brainId == null) {
NeeoUtil.write(resp, gson.toJson(new ReturnStatus("BrainID is null")));
}
}
} else {
- logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+ logger.debug("Unknown get path: {}", String.join(",", paths));
}
} catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
logger.debug("Exception handling get: {}", e.getMessage(), e);
}
try {
- if (StringUtils.equalsIgnoreCase(paths[0], "removebrain")) {
+ if (paths[0].equalsIgnoreCase("removebrain")) {
final BrainInfo info = gson.fromJson(req.getReader(), BrainInfo.class);
final String brainId = info.getBrainId();
if (brainId == null) {
NeeoUtil.write(resp,
gson.toJson(new ReturnStatus("BrainID (" + brainId + ") could not be removed")));
}
- } else if (StringUtils.equalsIgnoreCase(paths[0], "addbrain")) {
+ } else if (paths[0].equalsIgnoreCase("addbrain")) {
final BrainInfo info = gson.fromJson(req.getReader(), BrainInfo.class);
final String brainIp = info.getBrainIp();
if (brainIp == null) {
"Brain (" + brainIp + ") could not be added - no brain at that IP Address")));
}
} else {
- logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+ logger.debug("Unknown get path: {}", String.join(",", paths));
}
} catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
logger.debug("Exception handling get: {}", e.getMessage(), e);
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.io.neeo.internal.NeeoConstants;
import org.openhab.io.neeo.internal.NeeoUtil;
private final ServiceContext context;
/** The last search results */
- private final ConcurrentHashMap<Integer, NeeoThingUID> lastSearchResults = new ConcurrentHashMap<>();
+ private final Map<Integer, NeeoThingUID> lastSearchResults = new ConcurrentHashMap<>();
/**
* Constructs the service from the given {@link ServiceContext}.
*/
@Override
public boolean canHandleRoute(String[] paths) {
- return paths.length >= 1 && StringUtils.equalsIgnoreCase(paths[0], "db");
+ return paths.length >= 1 && paths[0].equalsIgnoreCase("db");
}
/**
Objects.requireNonNull(paths, "paths cannot be null");
Objects.requireNonNull(resp, "resp cannot be null");
if (paths.length < 2) {
- throw new IllegalArgumentException("paths must have atleast 2 elements: " + StringUtils.join(paths));
+ throw new IllegalArgumentException("paths must have atleast 2 elements: " + String.join("", paths));
}
- final String path = StringUtils.lowerCase(paths[1]);
+ final String path = paths[1].toLowerCase();
- if (StringUtils.equalsIgnoreCase(path, "search")) {
+ if (path.equalsIgnoreCase("search")) {
String queryString = req.getQueryString();
if (queryString != null) {
doSearch(queryString, resp);
}
- } else if (StringUtils.equalsIgnoreCase(path, "adapterdefinition") && paths.length >= 3) {
+ } else if (path.equalsIgnoreCase("adapterdefinition") && paths.length >= 3) {
doAdapterDefinition(paths[2], resp);
} else {
doQuery(path, resp);
Objects.requireNonNull(queryString, "queryString cannot be null");
Objects.requireNonNull(resp, "resp cannot be null");
- final int idx = StringUtils.indexOf(queryString, '=');
+ final int idx = queryString.indexOf("=");
if (idx >= 0 && idx + 1 < queryString.length()) {
final String search = NeeoUtil.decodeURIComponent(queryString.substring(idx + 1));
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.client.ClientBuilder;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
return false;
}
- if (StringUtils.equalsIgnoreCase(paths[0], "device")) {
+ if (paths[0].equalsIgnoreCase("device")) {
return true;
}
final String lastPath = paths.length >= 2 ? paths[1] : null;
- return StringUtils.equalsIgnoreCase(lastPath, "subscribe")
- || StringUtils.equalsIgnoreCase(lastPath, "unsubscribe");
+ return "subscribe".equalsIgnoreCase(lastPath) || "unsubscribe".equalsIgnoreCase(lastPath);
}
@Override
throw new IllegalArgumentException("paths cannot be empty");
}
- final boolean hasDeviceStart = StringUtils.equalsIgnoreCase(paths[0], "device");
+ final boolean hasDeviceStart = paths[0].equalsIgnoreCase("device");
if (hasDeviceStart) {
final PathInfo pathInfo = new PathInfo(paths);
- if (StringUtils.equalsIgnoreCase("directory", pathInfo.getComponentType())) {
+ if ("directory".equalsIgnoreCase(pathInfo.getComponentType())) {
handleDirectory(req, resp, pathInfo);
} else {
- logger.debug("Unknown/unhandled brain service device route (POST): {}", StringUtils.join(paths, '/'));
+ logger.debug("Unknown/unhandled brain service device route (POST): {}", String.join("/", paths));
}
} else {
- logger.debug("Unknown/unhandled brain service route (POST): {}", StringUtils.join(paths, '/'));
+ logger.debug("Unknown/unhandled brain service route (POST): {}", String.join("/", paths));
}
}
// 4. Old subscribe path: /{thingUID}/subscribe or unsubscribe/{deviceid}/{devicekey}
// 4. Old unsubscribe path: /{thingUID}/subscribe or unsubscribe/{deviceid}
- final boolean hasDeviceStart = StringUtils.equalsIgnoreCase(paths[0], "device");
- if (hasDeviceStart && (paths.length >= 3 && !StringUtils.equalsIgnoreCase(paths[2], "subscribe")
- && !StringUtils.equalsIgnoreCase(paths[2], "unsubscribe"))) {
+ final boolean hasDeviceStart = paths[0].equalsIgnoreCase("device");
+ if (hasDeviceStart && (paths.length >= 3 && !paths[2].equalsIgnoreCase("subscribe")
+ && !paths[2].equalsIgnoreCase("unsubscribe"))) {
try {
final PathInfo pathInfo = new PathInfo(paths);
- if (StringUtils.isEmpty(pathInfo.getActionValue())) {
+ String actionValue = pathInfo.getActionValue();
+ if (actionValue == null || actionValue.isEmpty()) {
handleGetValue(resp, pathInfo);
} else {
handleSetValue(resp, pathInfo);
}
} catch (IllegalArgumentException e) {
- logger.debug("Bad path: {} - {}", StringUtils.join(paths), e.getMessage(), e);
+ logger.debug("Bad path: {} - {}", String.join("", paths), e.getMessage(), e);
}
} else {
int idx = hasDeviceStart ? 1 : 0;
if (idx + 2 < paths.length) {
final String adapterName = paths[idx++];
- final String action = StringUtils.lowerCase(paths[idx++]);
+ final String action = paths[idx++].toLowerCase();
idx++; // deviceId/default - not used
switch (action) {
final String deviceKey = paths[idx++];
handleSubscribe(resp, adapterName, deviceKey);
} else {
- logger.debug("No device key set for a subscribe action: {}", StringUtils.join(paths, '/'));
+ logger.debug("No device key set for a subscribe action: {}", String.join("/", paths));
}
break;
case "unsubscribe":
}
} else {
- logger.debug("Unknown/unhandled brain service route (GET): {}", StringUtils.join(paths, '/'));
+ logger.debug("Unknown/unhandled brain service route (GET): {}", String.join("/", paths));
}
}
}
if (device != null) {
final NeeoDeviceChannel channel = device.getChannel(pathInfo.getItemName(), pathInfo.getSubType(),
pathInfo.getChannelNbr());
- if (StringUtils.equalsIgnoreCase("action", pathInfo.getActionValue())) {
+ if ("action".equalsIgnoreCase(pathInfo.getActionValue())) {
final NeeoDirectoryRequestAction discoveryAction = gson.fromJson(req.getReader(),
NeeoDirectoryRequestAction.class);
if (state instanceof OnOffType) {
Boolean recipeState = null;
final String label = channel.getLabel();
- if (StringUtils.equalsIgnoreCase(NeeoButtonGroup.POWERONOFF.getText(), label)) {
+ if (NeeoButtonGroup.POWERONOFF.getText().equalsIgnoreCase(label)) {
recipeState = state == OnOffType.ON;
- } else if (state == OnOffType.ON
- && StringUtils.equalsIgnoreCase(ButtonInfo.POWERON.getLabel(), label)) {
+ } else if (state == OnOffType.ON && ButtonInfo.POWERON.getLabel().equalsIgnoreCase(label)) {
recipeState = true;
- } else if (state == OnOffType.OFF
- && StringUtils.equalsIgnoreCase(ButtonInfo.POWEROFF.getLabel(), label)) {
+ } else if (state == OnOffType.OFF && ButtonInfo.POWEROFF.getLabel().equalsIgnoreCase(label)) {
recipeState = false;
}
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ChannelUID;
import org.openhab.io.neeo.NeeoService;
*/
@Override
public boolean canHandleRoute(String[] paths) {
- return paths.length >= 1 && (StringUtils.equalsIgnoreCase(paths[0], "thingstatus")
- || StringUtils.equalsIgnoreCase(paths[0], "getchannel")
- || StringUtils.equalsIgnoreCase(paths[0], "getvirtualdevice")
- || StringUtils.equalsIgnoreCase(paths[0], "restoredevice")
- || StringUtils.equalsIgnoreCase(paths[0], "refreshdevice")
- || StringUtils.equalsIgnoreCase(paths[0], "deletedevice")
- || StringUtils.equalsIgnoreCase(paths[0], "exportrules")
- || StringUtils.equalsIgnoreCase(paths[0], "updatedevice"));
+ return paths.length >= 1 && (paths[0].equalsIgnoreCase("thingstatus") //
+ || paths[0].equalsIgnoreCase("getchannel") //
+ || paths[0].equalsIgnoreCase("getvirtualdevice") //
+ || paths[0].equalsIgnoreCase("restoredevice") //
+ || paths[0].equalsIgnoreCase("refreshdevice") //
+ || paths[0].equalsIgnoreCase("deletedevice") //
+ || paths[0].equalsIgnoreCase("exportrules") //
+ || paths[0].equalsIgnoreCase("updatedevice"));
}
/**
Objects.requireNonNull(resp, "resp cannot be null");
try {
- if (StringUtils.equalsIgnoreCase(paths[0], "thingstatus")) {
+ if (paths[0].equalsIgnoreCase("thingstatus")) {
final List<NeeoDevice> devices = context.getDefinitions().getAllDevices();
NeeoUtil.write(resp, gson.toJson(devices));
- } else if (StringUtils.equalsIgnoreCase(paths[0], "getchannel")) {
+ } else if (paths[0].equalsIgnoreCase("getchannel")) {
final String itemName = NeeoUtil.decodeURIComponent(req.getParameter("itemname"));
final List<NeeoDeviceChannel> channels = context.getDefinitions().getNeeoDeviceChannel(itemName);
if (channels == null) {
} else {
NeeoUtil.write(resp, gson.toJson(new ReturnStatus(channels)));
}
- } else if (StringUtils.equalsIgnoreCase(paths[0], "getvirtualdevice")) {
+ } else if (paths[0].equalsIgnoreCase("getvirtualdevice")) {
final NeeoThingUID uid = context.generate(NeeoConstants.VIRTUAL_THING_TYPE);
final NeeoDevice device = new NeeoDevice(uid, 0, NeeoDeviceType.EXCLUDE, "NEEO Integration",
"New Virtual Thing", new ArrayList<>(), null, null, null, null);
NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
} else {
- logger.debug("Unknown get path: {}", StringUtils.join(paths, ','));
+ logger.debug("Unknown get path: {}", String.join(",", paths));
}
} catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
logger.debug("Exception handling get: {}", e.getMessage(), e);
}
try {
- if (StringUtils.equalsIgnoreCase(paths[0], "updatedevice")) {
+ if (paths[0].equalsIgnoreCase("updatedevice")) {
final NeeoDevice device = gson.fromJson(req.getReader(), NeeoDevice.class);
context.getDefinitions().put(device);
}
NeeoUtil.write(resp, gson.toJson(ReturnStatus.SUCCESS));
- } else if (StringUtils.equalsIgnoreCase(paths[0], "restoredevice")) {
+ } else if (paths[0].equalsIgnoreCase("restoredevice")) {
final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
context.getDefinitions().remove(uid);
final NeeoDevice device = context.getDefinitions().getDevice(uid);
} else {
NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
}
- } else if (StringUtils.equalsIgnoreCase(paths[0], "refreshdevice")) {
+ } else if (paths[0].equalsIgnoreCase("refreshdevice")) {
final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
final NeeoDevice device = context.getDefinitions().getDevice(uid);
if (device == null) {
} else {
NeeoUtil.write(resp, gson.toJson(new ReturnStatus(device)));
}
- } else if (StringUtils.equalsIgnoreCase(paths[0], "deletedevice")) {
+ } else if (paths[0].equalsIgnoreCase("deletedevice")) {
final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
final boolean deleted = context.getDefinitions().remove(uid);
NeeoUtil.write(resp, gson.toJson(new ReturnStatus(
deleted ? null : "Device " + uid + " was not found (possibly already deleted?)")));
- } else if (StringUtils.equalsIgnoreCase(paths[0], "exportrules")) {
+ } else if (paths[0].equalsIgnoreCase("exportrules")) {
final NeeoThingUID uid = new NeeoThingUID(IOUtils.toString(req.getReader()));
final NeeoDevice device = context.getDefinitions().getDevice(uid);
if (device == null) {
writeExampleRules(resp, device);
}
} else {
- logger.debug("Unknown post path: {}", StringUtils.join(paths, ','));
+ logger.debug("Unknown post path: {}", String.join(",", paths));
}
} catch (JsonParseException | IllegalArgumentException | NullPointerException e) {
logger.debug("Exception handling post: {}", e.getMessage(), e);
import java.util.Objects;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.models.ItemSubType;
private final String componentSubType;
/** The action value */
- @Nullable
- private final String actionValue;
+ private final @Nullable String actionValue;
/**
* Creates the path info object from the route path
componentType = paths[idx++];
// actor/sensor/buttoncmd
- if (StringUtils.equalsIgnoreCase("button", componentType)) {
+ if ("button".equalsIgnoreCase(componentType)) {
componentSubType = "actor";
actionValue = paths[idx++];
} else {
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.io.neeo.internal.models.NeeoDevice;
private final boolean success;
/** The optional message if not successful */
- @Nullable
- private final String message;
+ private final @Nullable String message;
/** The optional device if successful */
- @Nullable
- private final NeeoDevice device;
+ private final @Nullable NeeoDevice device;
/** The optional channel if successful */
- @Nullable
- private final List<NeeoDeviceChannel> channels;
+ private final @Nullable List<NeeoDeviceChannel> channels;
/**
* Creates a return status of true or not (with no message or device)
* @param message the possibly null, possibly empty message
*/
public ReturnStatus(@Nullable String message) {
- this(StringUtils.isEmpty(message), message, null, null);
+ this(message == null || message.isEmpty(), message, null, null);
}
/**
*
* @return the possibly empty, possibly null message
*/
- @Nullable
- public String getMessage() {
+ public @Nullable String getMessage() {
return message;
}
*
* @return the possibly null device
*/
- @Nullable
- public NeeoDevice getDevice() {
+ public @Nullable NeeoDevice getDevice() {
return device;
}
*
* @return the possibly null channel
*/
- @Nullable
- public List<NeeoDeviceChannel> getChannels() {
+ public @Nullable List<NeeoDeviceChannel> getChannels() {
return channels;
}
#
-runbundles: \
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
- org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
org.objenesis;version='[3.1.0,3.1.1)',\
org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
- biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+ biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+ org.apache.commons.lang3;version='[3.9.0,3.9.1)'
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
- org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
junit-platform-engine;version='[1.7.0,1.7.1)',\
junit-platform-launcher;version='[1.7.0,1.7.1)',\
org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
- biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+ biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+ org.apache.commons.lang3;version='[3.9.0,3.9.1)'
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
- org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.commons.commons-net;version='[3.7.2,3.7.3)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
import java.util.Locale;
import java.util.TimeZone;
-import org.apache.commons.lang.StringUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
}
private String getStringChannelTimeZoneFromItemRegistry() {
- String itemState = getItemState(ACCEPTED_ITEM_TYPE_STRING).toString();
- String timeZoneFromItemRegistry = StringUtils.substringAfterLast(itemState, " ");
- return timeZoneFromItemRegistry;
+ return getItemState(ACCEPTED_ITEM_TYPE_STRING).toString().split(" ")[2];
}
private void assertFormat(String initialDate, String formatPattern) {
-runbundles: \
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
- org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
org.objenesis;version='[3.1.0,3.1.1)',\
org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
- biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+ biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+ org.apache.commons.lang3;version='[3.9.0,3.9.1)'
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
- org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
org.objenesis;version='[3.1.0,3.1.1)',\
org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
- biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)'
+ biz.aQute.tester.junit-platform;version='[5.3.0,5.3.1)',\
+ org.apache.commons.lang3;version='[3.9.0,3.9.1)'