mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Rework more commons-lang usages (#10314)
* Reworks many commons-lang usages to use standard Java * Updates all remaining commons.lang imports to commons.lang3 Related to openhab/openhab-addons#7722 Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
16fba31556
commit
f3503430b4
@ -18,7 +18,6 @@ import java.io.IOException;
|
||||
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;
|
||||
@ -128,7 +127,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
@ -141,7 +140,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import java.util.Arrays;
|
||||
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;
|
||||
@ -318,8 +317,9 @@ public class AmbientWeatherEventListener {
|
||||
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());
|
||||
|
@ -34,7 +34,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
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;
|
||||
|
@ -16,7 +16,7 @@ import static java.util.Arrays.asList;
|
||||
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.*;
|
||||
|
||||
|
@ -16,7 +16,7 @@ import java.util.Calendar;
|
||||
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;
|
||||
|
@ -25,7 +25,6 @@ import javax.xml.xpath.XPath;
|
||||
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;
|
||||
@ -288,17 +287,17 @@ public class AutelisHandler extends BaseThingHandler {
|
||||
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;
|
||||
}
|
||||
@ -443,7 +442,7 @@ public class AutelisHandler extends BaseThingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty((value))) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.bigassfan.internal;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* The {@link BigAssFanConfig} is responsible for storing the BigAssFan thing configuration.
|
||||
*
|
||||
@ -60,13 +58,13 @@ public class BigAssFanConfig {
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
@ -668,7 +667,7 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void processMessage(String incomingMessage) {
|
||||
if (StringUtils.isEmpty(incomingMessage)) {
|
||||
if (incomingMessage == null || incomingMessage.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -742,11 +741,11 @@ public class BigAssFanHandler extends BaseThingHandler {
|
||||
|
||||
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;
|
||||
|
@ -18,7 +18,7 @@ import java.util.concurrent.locks.Condition;
|
||||
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;
|
||||
|
||||
|
@ -19,7 +19,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
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;
|
||||
@ -193,7 +192,7 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot
|
||||
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);
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
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;
|
||||
|
@ -15,7 +15,7 @@ package org.openhab.binding.bosesoundtouch.internal;
|
||||
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;
|
||||
|
@ -12,16 +12,15 @@
|
||||
*/
|
||||
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;
|
||||
@ -50,17 +49,14 @@ public class BsbLanApiCaller {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -96,21 +92,21 @@ public class BsbLanApiCaller {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -134,7 +130,7 @@ public class BsbLanApiCaller {
|
||||
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";
|
||||
}
|
||||
|
@ -18,9 +18,8 @@ import java.util.HashSet;
|
||||
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;
|
||||
@ -78,7 +77,8 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
|
||||
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;
|
||||
@ -128,8 +128,10 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
|
||||
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);
|
||||
|
@ -14,10 +14,11 @@ package org.openhab.binding.bsblan.internal.helper;
|
||||
|
||||
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;
|
||||
@ -74,7 +75,7 @@ public class BsbLanParameterConverter {
|
||||
}
|
||||
|
||||
private static State getStateForUnitChannel(BsbLanApiParameterDTO parameter) {
|
||||
String value = StringEscapeUtils.unescapeHtml(parameter.unit);
|
||||
String value = StringEscapeUtils.unescapeHtml4(parameter.unit);
|
||||
return new StringType(value);
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ public class BsbLanParameterConverter {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
@ -81,7 +80,7 @@ public class BuienradarHandler extends BaseThingHandler {
|
||||
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;
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.PercentType;
|
||||
@ -184,7 +183,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingArtist(String artist) {
|
||||
StringType newVal = StringUtils.isBlank(artist) ? StringType.EMPTY : StringType.valueOf(artist);
|
||||
StringType newVal = artist == null || artist.isBlank() ? StringType.EMPTY : StringType.valueOf(artist);
|
||||
if (!newVal.equals(this.artist)) {
|
||||
this.artist = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ARTIST, this.artist);
|
||||
@ -192,7 +191,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingAlbum(String album) {
|
||||
StringType newVal = StringUtils.isBlank(album) ? StringType.EMPTY : StringType.valueOf(album);
|
||||
StringType newVal = album == null || album.isBlank() ? StringType.EMPTY : StringType.valueOf(album);
|
||||
if (!newVal.equals(this.album)) {
|
||||
this.album = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ALBUM, this.album);
|
||||
@ -200,7 +199,7 @@ public class DenonMarantzState {
|
||||
}
|
||||
|
||||
public void setNowPlayingTrack(String track) {
|
||||
StringType newVal = StringUtils.isBlank(track) ? StringType.EMPTY : StringType.valueOf(track);
|
||||
StringType newVal = track == null || track.isBlank() ? StringType.EMPTY : StringType.valueOf(track);
|
||||
if (!newVal.equals(this.track)) {
|
||||
this.track = newVal;
|
||||
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_TRACK, this.track);
|
||||
|
@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.util.StreamReaderDelegate;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
@ -169,7 +168,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
@Override
|
||||
protected void internalSendCommand(String command) {
|
||||
logger.debug("Sending command '{}'", command);
|
||||
if (StringUtils.isBlank(command)) {
|
||||
if (command == null || command.isBlank()) {
|
||||
logger.warn("Trying to send empty command");
|
||||
return;
|
||||
}
|
||||
@ -306,7 +305,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
String result = HttpUtil.executeUrl("GET", uri, REQUEST_TIMEOUT_MS);
|
||||
logger.trace("result of getDocument for uri '{}':\r\n{}", uri, result);
|
||||
|
||||
if (StringUtils.isNotBlank(result)) {
|
||||
if (result != null && !result.isBlank()) {
|
||||
JAXBContext jc = JAXBContext.newInstance(response);
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
|
||||
@ -341,7 +340,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(sw.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String result = HttpUtil.executeUrl("POST", uri, inputStream, CONTENT_TYPE_XML, REQUEST_TIMEOUT_MS);
|
||||
|
||||
if (StringUtils.isNotBlank(result)) {
|
||||
if (result != null && !result.isBlank()) {
|
||||
JAXBContext jcResponse = JAXBContext.newInstance(response);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -20,7 +20,6 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -74,7 +73,7 @@ public class DenonMarantzTelnetClientThread extends Thread {
|
||||
break;
|
||||
}
|
||||
logger.trace("Received from {}: {}", config.getHost(), line);
|
||||
if (!StringUtils.isBlank(line)) {
|
||||
if (!line.isBlank()) {
|
||||
listener.receivedLine(line);
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
|
@ -20,7 +20,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openhab.binding.denonmarantz.internal.DenonMarantzState;
|
||||
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
|
||||
import org.openhab.binding.denonmarantz.internal.connector.DenonMarantzConnector;
|
||||
@ -263,7 +263,7 @@ public class DenonMarantzTelnetConnector extends DenonMarantzConnector implement
|
||||
@Override
|
||||
protected void internalSendCommand(String command) {
|
||||
logger.debug("Sending command '{}'", command);
|
||||
if (StringUtils.isBlank(command)) {
|
||||
if (command == null || command.isBlank()) {
|
||||
logger.warn("Trying to send empty command");
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.denonmarantz.internal.xml.adapters;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Adapter to clean up string values
|
||||
|
@ -18,7 +18,6 @@ import java.util.HashMap;
|
||||
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;
|
||||
@ -139,8 +138,9 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
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;
|
||||
}
|
||||
@ -208,7 +208,8 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
|
||||
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);
|
||||
@ -225,13 +226,15 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -249,8 +252,9 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -21,16 +21,17 @@ import java.util.HashSet;
|
||||
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;
|
||||
@ -126,10 +127,8 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
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();
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ import java.util.HashMap;
|
||||
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;
|
||||
@ -103,7 +103,7 @@ public class ZoneTemperatureControlDiscoveryService extends AbstractDiscoverySer
|
||||
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)
|
||||
|
@ -25,7 +25,6 @@ import java.util.Set;
|
||||
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;
|
||||
@ -198,9 +197,10 @@ public class BridgeHandler extends BaseBridgeHandler
|
||||
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);
|
||||
@ -235,8 +235,12 @@ public class BridgeHandler extends BaseBridgeHandler
|
||||
}
|
||||
|
||||
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);
|
||||
@ -296,8 +300,9 @@ public class BridgeHandler extends BaseBridgeHandler
|
||||
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;
|
||||
}
|
||||
@ -307,8 +312,9 @@ public class BridgeHandler extends BaseBridgeHandler
|
||||
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.");
|
||||
|
@ -16,7 +16,6 @@ import java.util.HashSet;
|
||||
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;
|
||||
@ -77,8 +76,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
|
||||
@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());
|
||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||
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;
|
||||
@ -108,8 +107,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
|
||||
@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());
|
||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.digitalstrom.internal.lib.manager.impl;
|
||||
|
||||
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;
|
||||
@ -286,8 +285,9 @@ public class ConnectionManagerImpl implements 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();
|
||||
}
|
||||
@ -379,8 +379,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
|
||||
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 {
|
||||
@ -425,7 +426,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
|
||||
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()))) {
|
||||
@ -464,10 +465,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,8 +509,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import java.util.Map;
|
||||
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;
|
||||
@ -134,12 +133,13 @@ public class DsAPIImpl implements DsAPI {
|
||||
}
|
||||
|
||||
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
|
||||
@ -411,7 +411,7 @@ public class DsAPIImpl implements DsAPI {
|
||||
@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)
|
||||
@ -428,7 +428,7 @@ public class DsAPIImpl implements DsAPI {
|
||||
@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)
|
||||
@ -586,7 +586,7 @@ public class DsAPIImpl implements DsAPI {
|
||||
|
||||
@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());
|
||||
|
@ -43,7 +43,7 @@ import javax.net.ssl.TrustManager;
|
||||
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;
|
||||
@ -194,13 +194,14 @@ public class HttpTransportImpl implements 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 {
|
||||
@ -355,7 +356,7 @@ public class HttpTransportImpl implements HttpTransport {
|
||||
|
||||
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();
|
||||
@ -415,7 +416,7 @@ public class HttpTransportImpl implements HttpTransport {
|
||||
}
|
||||
|
||||
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);
|
||||
@ -446,9 +447,9 @@ public class HttpTransportImpl implements HttpTransport {
|
||||
|
||||
@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) {
|
||||
@ -485,7 +486,7 @@ public class HttpTransportImpl implements HttpTransport {
|
||||
}
|
||||
|
||||
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")
|
||||
|
@ -15,7 +15,6 @@ package org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsr
|
||||
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;
|
||||
@ -61,7 +60,7 @@ public class SimpleRequestBuilder {
|
||||
* @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();
|
||||
}
|
||||
@ -78,14 +77,13 @@ public class 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;
|
||||
@ -102,8 +100,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -115,7 +112,7 @@ public class SimpleRequestBuilder {
|
||||
if (!classIsChosen) {
|
||||
throw new IllegalArgumentException(ExeptionConstants.CLASS_ALREADY_ADDED);
|
||||
} else {
|
||||
throw new NullArgumentException("requestClassKey");
|
||||
throw new IllegalArgumentException("requestClassKey is null");
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@ -129,7 +126,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -142,7 +139,7 @@ public class SimpleRequestBuilder {
|
||||
functionIsChosen = true;
|
||||
request = request + functionKey;
|
||||
} else {
|
||||
throw new NullArgumentException("functionKey");
|
||||
throw new IllegalArgumentException("functionKey is null");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED);
|
||||
@ -160,7 +157,7 @@ public class SimpleRequestBuilder {
|
||||
* @throws NullArgumentException if the parameterKey is null
|
||||
*/
|
||||
public SimpleRequestBuilder addParameter(String parameterKey, String parameterValue)
|
||||
throws IllegalArgumentException, NullArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
return builder.addParameterInt(parameterKey, parameterValue);
|
||||
}
|
||||
|
||||
@ -175,7 +172,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
}
|
||||
@ -191,7 +188,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
@ -210,7 +207,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
@ -228,7 +225,7 @@ public class SimpleRequestBuilder {
|
||||
* @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);
|
||||
}
|
||||
@ -236,7 +233,7 @@ public class SimpleRequestBuilder {
|
||||
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) {
|
||||
|
@ -22,7 +22,6 @@ import java.util.Map;
|
||||
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;
|
||||
@ -1695,7 +1694,7 @@ public class DeviceImpl extends AbstractGeneralDeviceInformations implements Dev
|
||||
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(",");
|
||||
|
@ -16,7 +16,6 @@ import java.util.Collections;
|
||||
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;
|
||||
@ -71,7 +70,7 @@ public class InternalScene {
|
||||
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;
|
||||
|
@ -13,8 +13,9 @@
|
||||
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;
|
||||
@ -132,6 +133,9 @@ public abstract class BaseDsI18n {
|
||||
* @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));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import java.util.Properties;
|
||||
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;
|
||||
|
@ -18,8 +18,7 @@ import java.util.concurrent.ExecutionException;
|
||||
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;
|
||||
@ -133,8 +132,9 @@ public class EcobeeAuth {
|
||||
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);
|
||||
@ -172,8 +172,9 @@ public class EcobeeAuth {
|
||||
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);
|
||||
|
@ -17,7 +17,7 @@ import static org.openhab.binding.ecobee.internal.EcobeeBindingConstants.*;
|
||||
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;
|
||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
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;
|
||||
|
@ -17,7 +17,7 @@ import java.util.ArrayList;
|
||||
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;
|
||||
|
@ -24,7 +24,6 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
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;
|
||||
@ -94,7 +93,7 @@ public class Enigma2Client {
|
||||
} 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;
|
||||
|
@ -23,7 +23,6 @@ import java.util.concurrent.ScheduledFuture;
|
||||
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;
|
||||
@ -135,7 +134,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
|
||||
}
|
||||
|
||||
protected void sendRequestResponse() {
|
||||
throw new NotImplementedException("Sensor cannot send responses");
|
||||
throw new UnsupportedOperationException("Sensor cannot send responses");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
@ -95,14 +94,15 @@ public class EnturNoHandler extends BaseThingHandler {
|
||||
|
||||
logger.debug("Stop place id: {}", stopId);
|
||||
boolean configValid = true;
|
||||
if (StringUtils.trimToNull(stopId) == null) {
|
||||
if (stopId == null || stopId.isBlank()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"@text/offline.conf-error-missing-stopId");
|
||||
configValid = false;
|
||||
}
|
||||
|
||||
logger.debug("Line code: {}", config.getLineCode());
|
||||
if (StringUtils.trimToNull(config.getLineCode()) == null) {
|
||||
String lineCode = config.getLineCode();
|
||||
logger.debug("Line code: {}", lineCode);
|
||||
if (lineCode == null || lineCode.isBlank()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"@text/offline.conf-error-missing-lineCode");
|
||||
configValid = false;
|
||||
|
@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
@ -96,9 +96,9 @@ public class EnturNoConnection {
|
||||
*/
|
||||
public synchronized List<DisplayData> getEnturTimeTable(@Nullable String stopPlaceId, @Nullable String lineCode)
|
||||
throws JsonSyntaxException, EnturConfigurationException, EnturCommunicationException {
|
||||
if (StringUtils.isBlank(stopPlaceId)) {
|
||||
if (stopPlaceId == null || stopPlaceId.isBlank()) {
|
||||
throw new EnturConfigurationException("Stop place id cannot be empty or null");
|
||||
} else if (lineCode == null || StringUtils.isBlank(lineCode)) {
|
||||
} else if (lineCode == null || lineCode.isBlank()) {
|
||||
throw new EnturConfigurationException("Line code cannot be empty or null");
|
||||
}
|
||||
|
||||
@ -115,8 +115,9 @@ public class EnturNoConnection {
|
||||
|
||||
private Map<String, String> getRequestParams(EnturNoConfiguration config) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(PARAM_STOPID, StringUtils.trimToEmpty(config.getStopPlaceId()));
|
||||
params.put(PARAM_START_DATE_TIME, StringUtils.trimToEmpty(LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString()));
|
||||
String stopPlaceId = config.getStopPlaceId();
|
||||
params.put(PARAM_STOPID, stopPlaceId == null ? "" : stopPlaceId.trim());
|
||||
params.put(PARAM_START_DATE_TIME, LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString());
|
||||
|
||||
return params;
|
||||
}
|
||||
@ -141,7 +142,7 @@ public class EnturNoConnection {
|
||||
|
||||
int httpStatus = contentResponse.getStatus();
|
||||
String content = contentResponse.getContentAsString();
|
||||
String errorMessage = StringUtils.EMPTY;
|
||||
String errorMessage = "";
|
||||
logger.trace("Entur response: status = {}, content = '{}'", httpStatus, content);
|
||||
switch (httpStatus) {
|
||||
case OK_200:
|
||||
|
@ -12,7 +12,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -132,7 +131,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import java.util.concurrent.ScheduledFuture;
|
||||
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;
|
||||
@ -190,9 +189,9 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
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;
|
||||
|
@ -29,7 +29,7 @@ import java.util.regex.Matcher;
|
||||
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;
|
||||
|
@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
|
||||
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;
|
||||
@ -156,7 +155,7 @@ public class FoobotApiConnector {
|
||||
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;
|
||||
|
@ -15,12 +15,14 @@ package org.openhab.binding.foobot.internal.handler;
|
||||
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;
|
||||
@ -93,10 +95,12 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
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'");
|
||||
}
|
||||
|
||||
@ -104,13 +108,13 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
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(
|
||||
@ -118,8 +122,7 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
|
||||
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");
|
||||
|
||||
|
@ -21,7 +21,6 @@ import java.util.Map;
|
||||
|
||||
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;
|
||||
@ -93,7 +92,7 @@ public class FoobotDeviceHandler extends BaseThingHandler {
|
||||
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;
|
||||
|
@ -18,7 +18,6 @@ import java.util.Set;
|
||||
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;
|
||||
@ -62,10 +61,13 @@ public class FroniusBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
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;
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.fronius.internal.handler;
|
||||
|
||||
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;
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
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;
|
||||
|
@ -18,7 +18,6 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
|
||||
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;
|
||||
@ -128,7 +127,7 @@ public class FSInternetRadioHandler extends BaseThingHandler {
|
||||
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 {
|
||||
|
@ -21,9 +21,12 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
|
||||
|
||||
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;
|
||||
@ -818,7 +821,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
|
||||
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;
|
||||
|
@ -18,7 +18,6 @@ import java.util.Collections;
|
||||
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;
|
||||
@ -98,7 +97,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
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) {
|
||||
@ -109,7 +108,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
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) {
|
||||
|
@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
@ -252,7 +251,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -266,14 +265,13 @@ public class GlobalCacheHandler extends BaseThingHandler {
|
||||
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;
|
||||
}
|
||||
@ -638,7 +636,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
|
||||
|
||||
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");
|
||||
}
|
||||
@ -912,7 +910,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
|
||||
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 {
|
||||
|
@ -45,7 +45,7 @@ import java.util.stream.Collectors;
|
||||
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;
|
||||
|
@ -25,7 +25,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
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;
|
||||
@ -263,9 +262,9 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyClien
|
||||
// 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);
|
||||
|
@ -12,8 +12,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -93,27 +91,25 @@ public class Mhub4K431Handler extends BaseThingHandler {
|
||||
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());
|
||||
|
@ -12,8 +12,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -69,24 +67,22 @@ public class MultiroomPlusHandler extends BaseThingHandler {
|
||||
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());
|
||||
|
@ -14,9 +14,9 @@ package org.openhab.binding.heos.internal.handler;
|
||||
|
||||
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;
|
||||
@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
@ -38,15 +37,31 @@ import org.openhab.binding.heos.internal.api.HeosFacade;
|
||||
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;
|
||||
@ -474,16 +489,17 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -16,11 +16,14 @@ import static org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants.*
|
||||
|
||||
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;
|
||||
@ -210,8 +213,9 @@ public abstract class HydrawiseHandler extends BaseThingHandler {
|
||||
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);
|
||||
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
@ -268,7 +267,7 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
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;
|
||||
@ -291,7 +290,7 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
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,
|
||||
@ -438,8 +437,7 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||
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;
|
||||
@ -214,16 +213,16 @@ public class ChannelUtils {
|
||||
|
||||
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;
|
||||
|
@ -20,7 +20,6 @@ import java.util.Set;
|
||||
|
||||
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;
|
||||
@ -92,12 +91,12 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
// 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),
|
||||
@ -106,13 +105,13 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
|
||||
// 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));
|
||||
@ -120,13 +119,13 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
|
||||
// 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));
|
||||
@ -134,7 +133,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
|
||||
// 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));
|
||||
@ -142,7 +141,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
|
||||
// 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);
|
||||
@ -150,7 +149,7 @@ public class IhcResourceInteractionService extends IhcBaseService {
|
||||
|
||||
// Parse week day value
|
||||
value = getValue(n, "weekdayNumber");
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
if (value != null && !value.isBlank()) {
|
||||
return new WSWeekdayValue(id, Integer.valueOf(value));
|
||||
}
|
||||
|
||||
|
@ -16,13 +16,14 @@ import static org.openhab.binding.innogysmarthome.internal.client.Constants.*;
|
||||
|
||||
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;
|
||||
@ -180,7 +181,8 @@ public class InnogyClient {
|
||||
} 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;
|
||||
|
@ -20,11 +20,19 @@ import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
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.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;
|
||||
@ -183,7 +191,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
|
||||
* @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,
|
||||
@ -868,7 +876,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
|
||||
|
||||
/**
|
||||
* Sends the command to start or stop moving the rollershutter (ISR2) in a specified direction
|
||||
*
|
||||
*
|
||||
* @param deviceId
|
||||
* @param action
|
||||
*/
|
||||
@ -970,7 +978,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
|
||||
|
||||
/**
|
||||
* Checks if the job is already (re-)scheduled.
|
||||
*
|
||||
*
|
||||
* @param job job to check
|
||||
* @return true, when the job is already (re-)scheduled, otherwise false
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.irtrans.internal.handler;
|
||||
|
||||
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;
|
||||
|
@ -35,7 +35,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
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;
|
||||
|
@ -21,7 +21,7 @@ import java.util.HashMap;
|
||||
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;
|
||||
|
@ -18,7 +18,7 @@ import static org.openhab.core.library.unit.MetricPrefix.*;
|
||||
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;
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -48,8 +48,8 @@ public class KaleidescapeFormatter {
|
||||
// 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;
|
||||
|
@ -15,7 +15,7 @@ package org.openhab.binding.keba.internal;
|
||||
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;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import javax.measure.quantity.Energy;
|
||||
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;
|
||||
|
@ -23,7 +23,6 @@ import java.util.Base64;
|
||||
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;
|
||||
@ -131,8 +130,8 @@ public class KM200Cryption {
|
||||
* @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;
|
||||
|
@ -19,8 +19,7 @@ import java.util.HashMap;
|
||||
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;
|
||||
@ -84,7 +83,7 @@ public class KM200Device {
|
||||
}
|
||||
|
||||
public Boolean isConfigured() {
|
||||
return StringUtils.isNotBlank(ip4Address) && cryptKeyPriv.length > 0;
|
||||
return !ip4Address.isBlank() && cryptKeyPriv.length > 0;
|
||||
}
|
||||
|
||||
public String getIP4Address() {
|
||||
|
@ -30,7 +30,6 @@ import java.util.concurrent.Executors;
|
||||
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;
|
||||
@ -177,7 +176,7 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
|
||||
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) {
|
||||
@ -190,25 +189,25 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
|
||||
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;
|
||||
|
@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
@ -360,12 +359,12 @@ public class LaMetricTimeHandler extends ConfigStatusBridgeHandler {
|
||||
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());
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
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}.
|
||||
@ -30,8 +30,8 @@ public class IPBridgeConfig {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import java.util.regex.MatchResult;
|
||||
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;
|
||||
@ -156,7 +155,8 @@ public class IPBridgeHandler extends LutronBridgeHandler {
|
||||
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;
|
||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||
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;
|
||||
|
@ -16,7 +16,7 @@ import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import java.util.Date;
|
||||
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;
|
||||
@ -278,7 +278,7 @@ public final class CMessage extends Message {
|
||||
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));
|
||||
|
@ -12,8 +12,6 @@
|
||||
*/
|
||||
package org.openhab.binding.meteoblue.internal;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* Model for the meteoblue binding configuration.
|
||||
*
|
||||
@ -64,15 +62,15 @@ public class MeteoBlueConfiguration {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import static org.openhab.binding.meteoblue.internal.MeteoBlueBindingConstants.T
|
||||
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;
|
||||
@ -55,7 +54,7 @@ public class MeteoBlueBridgeHandler extends BaseBridgeHandler {
|
||||
|
||||
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;
|
||||
|
@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
@ -97,13 +96,13 @@ public class MeteoBlueHandler extends BaseThingHandler {
|
||||
|
||||
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;
|
||||
}
|
||||
@ -315,7 +314,7 @@ public class MeteoBlueHandler extends BaseThingHandler {
|
||||
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());
|
||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||
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;
|
||||
@ -46,6 +45,9 @@ import com.google.gson.JsonElement;
|
||||
*/
|
||||
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;
|
||||
@ -103,10 +105,9 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -145,17 +146,16 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
|
||||
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());
|
||||
|
@ -20,7 +20,7 @@ import java.util.Set;
|
||||
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;
|
||||
|
@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
|
@ -18,7 +18,7 @@ import java.util.Date;
|
||||
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;
|
||||
|
@ -21,7 +21,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
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;
|
||||
@ -78,7 +77,7 @@ public class ChannelState implements MqttMessageSubscriber {
|
||||
this.channelStateUpdateListener = channelStateUpdateListener;
|
||||
this.channelUID = channelUID;
|
||||
this.cachedValue = cachedValue;
|
||||
this.readOnly = StringUtils.isBlank(config.commandTopic);
|
||||
this.readOnly = config.commandTopic.isBlank();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
@ -242,7 +241,7 @@ public class ChannelState implements MqttMessageSubscriber {
|
||||
*/
|
||||
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();
|
||||
@ -297,7 +296,7 @@ public class ChannelState implements MqttMessageSubscriber {
|
||||
|
||||
this.connection = connection;
|
||||
|
||||
if (StringUtils.isBlank(config.stateTopic)) {
|
||||
if (config.stateTopic.isBlank()) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
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;
|
||||
@ -164,9 +164,8 @@ public class GenericMQTTThingHandler extends AbstractMQTTThingHandler implements
|
||||
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);
|
||||
}
|
||||
|
@ -12,12 +12,13 @@
|
||||
*/
|
||||
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;
|
||||
@ -45,7 +46,7 @@ public class TextValue extends Value {
|
||||
*/
|
||||
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 {
|
||||
|
@ -12,7 +12,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -35,7 +34,7 @@ public class ValueFactory {
|
||||
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:
|
||||
|
@ -16,7 +16,6 @@ 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.binding.mqtt.generic.MqttChannelTypeProvider;
|
||||
@ -54,8 +53,8 @@ public class MqttThingHandlerFactory extends BaseThingHandlerFactory implements
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -16,7 +16,6 @@ import java.util.List;
|
||||
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;
|
||||
@ -103,9 +102,9 @@ public abstract class BaseChannelConfiguration {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import java.net.URI;
|
||||
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;
|
||||
@ -149,9 +148,9 @@ public class CChannel {
|
||||
|
||||
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;
|
||||
}
|
||||
@ -204,7 +203,8 @@ public class CChannel {
|
||||
.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 {
|
||||
|
@ -15,7 +15,6 @@ package org.openhab.binding.mqtt.homeassistant.internal;
|
||||
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;
|
||||
|
||||
@ -119,7 +118,7 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
|
||||
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) == '~') {
|
||||
|
@ -12,7 +12,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -46,7 +45,7 @@ public class ComponentLock extends AbstractComponent<ComponentLock.ChannelConfig
|
||||
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");
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user