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:
Wouter Born 2021-03-16 12:38:16 +01:00 committed by GitHub
parent 16fba31556
commit f3503430b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
257 changed files with 906 additions and 1125 deletions

View File

@ -18,7 +18,6 @@ import java.io.IOException;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ambientweather.internal.config.BridgeConfig; import org.openhab.binding.ambientweather.internal.config.BridgeConfig;
@ -128,7 +127,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
*/ */
private boolean hasApplicationKey() { private boolean hasApplicationKey() {
String configApplicationKey = getConfigAs(BridgeConfig.class).applicationKey; String configApplicationKey = getConfigAs(BridgeConfig.class).applicationKey;
if (StringUtils.isEmpty(configApplicationKey)) { if (configApplicationKey == null || configApplicationKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing application key"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing application key");
return false; return false;
} }
@ -141,7 +140,7 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
*/ */
private boolean hasApiKey() { private boolean hasApiKey() {
String configApiKey = getConfigAs(BridgeConfig.class).apiKey; String configApiKey = getConfigAs(BridgeConfig.class).apiKey;
if (StringUtils.isEmpty(configApiKey)) { if (configApiKey == null || configApiKey.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing API key"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Missing API key");
return false; return false;
} }

View File

@ -18,7 +18,6 @@ import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject; import org.json.JSONObject;
import org.openhab.binding.ambientweather.internal.model.DeviceJson; import org.openhab.binding.ambientweather.internal.model.DeviceJson;
import org.openhab.binding.ambientweather.internal.model.EventDataGenericJson; import org.openhab.binding.ambientweather.internal.model.EventDataGenericJson;
@ -318,8 +317,9 @@ public class AmbientWeatherEventListener {
logger.debug("Listener: Data: {}", jsonData); logger.debug("Listener: Data: {}", jsonData);
try { try {
EventDataGenericJson data = gson.fromJson(jsonData, EventDataGenericJson.class); EventDataGenericJson data = gson.fromJson(jsonData, EventDataGenericJson.class);
if (StringUtils.isNotEmpty(data.macAddress)) { String macAddress = data == null ? null : data.macAddress;
sendWeatherDataToHandler(data.macAddress, jsonData); if (macAddress != null && !macAddress.isEmpty()) {
sendWeatherDataToHandler(macAddress, jsonData);
} }
} catch (JsonSyntaxException e) { } catch (JsonSyntaxException e) {
logger.info("Listener: Exception parsing subscribed event: {}", e.getMessage()); logger.info("Listener: Exception parsing subscribed event: {}", e.getMessage());

View File

@ -34,7 +34,7 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.measure.quantity.Angle; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.astro.internal.action.AstroActions; import org.openhab.binding.astro.internal.action.AstroActions;

View File

@ -16,7 +16,7 @@ import static java.util.Arrays.asList;
import static java.util.Calendar.SECOND; import static java.util.Calendar.SECOND;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList; 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.AstroBindingConstants.*;
import static org.openhab.binding.astro.internal.util.DateTimeUtils.*; import static org.openhab.binding.astro.internal.util.DateTimeUtils.*;

View File

@ -16,7 +16,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.regex.Pattern; 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.config.AstroChannelConfig;
import org.openhab.binding.astro.internal.model.Range; import org.openhab.binding.astro.internal.model.Range;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -25,7 +25,6 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
@ -288,17 +287,17 @@ public class AutelisHandler extends BaseThingHandler {
String username = configuration.user; String username = configuration.user;
String password = configuration.password; String password = configuration.password;
if (StringUtils.isBlank(username)) { if (username == null || username.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "username must not be empty"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "username must not be empty");
return; return;
} }
if (StringUtils.isBlank(password)) { if (password == null || password.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "password must not be empty"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "password must not be empty");
return; return;
} }
if (StringUtils.isBlank(host)) { if (host == null || host.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "hostname must not be empty"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "hostname must not be empty");
return; return;
} }
@ -443,7 +442,7 @@ public class AutelisHandler extends BaseThingHandler {
} }
} }
if (StringUtils.isEmpty((value))) { if (value == null || value.isEmpty()) {
continue; continue;
} }

View File

@ -12,8 +12,6 @@
*/ */
package org.openhab.binding.bigassfan.internal; package org.openhab.binding.bigassfan.internal;
import org.apache.commons.lang.StringUtils;
/** /**
* The {@link BigAssFanConfig} is responsible for storing the BigAssFan thing configuration. * The {@link BigAssFanConfig} is responsible for storing the BigAssFan thing configuration.
* *
@ -60,13 +58,13 @@ public class BigAssFanConfig {
} }
public boolean isValid() { public boolean isValid() {
if (StringUtils.isBlank(label)) { if (label == null || label.isBlank()) {
return false; return false;
} }
if (StringUtils.isBlank(ipAddress)) { if (ipAddress == null || ipAddress.isBlank()) {
return false; return false;
} }
if (StringUtils.isBlank(macAddress)) { if (macAddress == null || macAddress.isBlank()) {
return false; return false;
} }
return true; return true;

View File

@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.bigassfan.internal.BigAssFanConfig; import org.openhab.binding.bigassfan.internal.BigAssFanConfig;
import org.openhab.binding.bigassfan.internal.utils.BigAssFanConverter; import org.openhab.binding.bigassfan.internal.utils.BigAssFanConverter;
import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.common.ThreadPoolManager;
@ -668,7 +667,7 @@ public class BigAssFanHandler extends BaseThingHandler {
} }
private void processMessage(String incomingMessage) { private void processMessage(String incomingMessage) {
if (StringUtils.isEmpty(incomingMessage)) { if (incomingMessage == null || incomingMessage.isEmpty()) {
return; return;
} }
@ -742,11 +741,11 @@ public class BigAssFanHandler extends BaseThingHandler {
private boolean isMe(String idFromDevice) { private boolean isMe(String idFromDevice) {
// Check match on MAC address // Check match on MAC address
if (StringUtils.equalsIgnoreCase(idFromDevice, macAddress)) { if (macAddress.equalsIgnoreCase(idFromDevice)) {
return true; return true;
} }
// Didn't match MAC address, check match for label // Didn't match MAC address, check match for label
if (StringUtils.equalsIgnoreCase(idFromDevice, label)) { if (label.equalsIgnoreCase(idFromDevice)) {
return true; return true;
} }
return false; return false;

View File

@ -18,7 +18,7 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;

View File

@ -19,7 +19,6 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.measure.quantity.Power; import javax.measure.quantity.Power;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bluetooth.BluetoothDevice.ConnectionState; import org.openhab.binding.bluetooth.BluetoothDevice.ConnectionState;
@ -193,7 +192,7 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot
if (device != null) { if (device != null) {
BluetoothAdapter adapter = device.getAdapter(); BluetoothAdapter adapter = device.getAdapter();
String location = adapter.getLocation(); String location = adapter.getLocation();
if (location != null || StringUtils.isBlank(location)) { if (location != null && !location.isBlank()) {
updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, new StringType(location)); updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, new StringType(location));
} else { } else {
updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, UnDefType.NULL); updateState(BluetoothBindingConstants.CHANNEL_TYPE_ADAPTER_LOCATION, UnDefType.NULL);

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.bluetooth; 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.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.ThingUID;

View File

@ -23,7 +23,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer; 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.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;

View File

@ -15,7 +15,7 @@ package org.openhab.binding.bosesoundtouch.internal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.openhab.core.types.StateOption; import org.openhab.core.types.StateOption;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;

View File

@ -12,16 +12,15 @@
*/ */
package org.openhab.binding.bsblan.internal.api; 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.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.Set; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiContentDTO; import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiContentDTO;
@ -50,17 +49,14 @@ public class BsbLanApiCaller {
} }
public @Nullable BsbLanApiParameterQueryResponseDTO queryParameter(Integer parameterId) { public @Nullable BsbLanApiParameterQueryResponseDTO queryParameter(Integer parameterId) {
Set<Integer> parameters = new HashSet<>(); return queryParameters(Set.of(parameterId));
parameters.add(parameterId);
return queryParameters(parameters);
} }
public @Nullable BsbLanApiParameterQueryResponseDTO queryParameters(Set<Integer> parameterIds) { public @Nullable BsbLanApiParameterQueryResponseDTO queryParameters(Set<Integer> parameterIds) {
// note: make the request even if parameterIds is empty as // note: make the request even if parameterIds is empty as
// thing OFFLINE/ONLINE detection relies on a response // thing OFFLINE/ONLINE detection relies on a response
String apiPath = String.format("/JQ=%s",
String apiPath = String.format("/JQ=%s", StringUtils.join(parameterIds, ",")); parameterIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
return makeRestCall(BsbLanApiParameterQueryResponseDTO.class, "GET", apiPath, null); return makeRestCall(BsbLanApiParameterQueryResponseDTO.class, "GET", apiPath, null);
} }
@ -96,21 +92,21 @@ public class BsbLanApiCaller {
} }
private String createApiBaseUrl() { private String createApiBaseUrl() {
final String host = StringUtils.trimToEmpty(bridgeConfig.host); final String host = bridgeConfig.host == null ? "" : bridgeConfig.host.trim();
final String username = StringUtils.trimToEmpty(bridgeConfig.username); final String username = bridgeConfig.username == null ? "" : bridgeConfig.username.trim();
final String password = StringUtils.trimToEmpty(bridgeConfig.password); final String password = bridgeConfig.password == null ? "" : bridgeConfig.password.trim();
final String passkey = StringUtils.trimToEmpty(bridgeConfig.passkey); final String passkey = bridgeConfig.passkey == null ? "" : bridgeConfig.passkey.trim();
StringBuilder url = new StringBuilder(); StringBuilder url = new StringBuilder();
url.append("http://"); url.append("http://");
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { if (!username.isBlank() && !password.isBlank()) {
url.append(username).append(":").append(password).append("@"); url.append(username).append(":").append(password).append("@");
} }
url.append(host); url.append(host);
if (bridgeConfig.port != 80) { if (bridgeConfig.port != 80) {
url.append(":").append(bridgeConfig.port); url.append(":").append(bridgeConfig.port);
} }
if (StringUtils.isNotBlank(passkey)) { if (!passkey.isBlank()) {
url.append("/").append(passkey); url.append("/").append(passkey);
} }
return url.toString(); return url.toString();
@ -134,7 +130,7 @@ public class BsbLanApiCaller {
if (request != null) { if (request != null) {
String content = BsbLanApiContentConverter.toJson(request); String content = BsbLanApiContentConverter.toJson(request);
logger.trace("api request content: '{}'", content); logger.trace("api request content: '{}'", content);
if (StringUtils.isNotBlank(content)) { if (!content.isBlank()) {
contentStream = new ByteArrayInputStream(content.getBytes(Charset.forName("UTF-8"))); contentStream = new ByteArrayInputStream(content.getBytes(Charset.forName("UTF-8")));
contentType = "application/json"; contentType = "application/json";
} }

View File

@ -18,9 +18,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bsblan.internal.api.BsbLanApiCaller; import org.openhab.binding.bsblan.internal.api.BsbLanApiCaller;
@ -78,7 +77,8 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
bridgeConfig = getConfigAs(BsbLanBridgeConfiguration.class); bridgeConfig = getConfigAs(BsbLanBridgeConfiguration.class);
// validate 'host' configuration // validate 'host' configuration
if (StringUtils.isBlank(bridgeConfig.host)) { String host = bridgeConfig.host;
if (host == null || host.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Parameter 'host' is mandatory and must be configured"); "Parameter 'host' is mandatory and must be configured");
return; return;
@ -128,8 +128,10 @@ public class BsbLanBridgeHandler extends BaseBridgeHandler {
BsbLanApiCaller apiCaller = new BsbLanApiCaller(bridgeConfig); BsbLanApiCaller apiCaller = new BsbLanApiCaller(bridgeConfig);
// refresh all parameters // refresh all parameters
Set<Integer> parameterIds = things.stream().filter(thing -> thing instanceof BsbLanParameterHandler) Set<Integer> parameterIds = things.stream() //
.map(thing -> (BsbLanParameterHandler) thing).map(thing -> thing.getParameterId()) .filter(thing -> thing instanceof BsbLanParameterHandler) //
.map(thing -> (BsbLanParameterHandler) thing) //
.map(thing -> thing.getParameterId()) //
.collect(Collectors.toSet()); .collect(Collectors.toSet());
cachedParameterQueryResponse = apiCaller.queryParameters(parameterIds); cachedParameterQueryResponse = apiCaller.queryParameters(parameterIds);

View File

@ -14,10 +14,11 @@ package org.openhab.binding.bsblan.internal.helper;
import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO; 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.DecimalType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType; import org.openhab.core.library.types.StringType;
@ -74,7 +75,7 @@ public class BsbLanParameterConverter {
} }
private static State getStateForUnitChannel(BsbLanApiParameterDTO parameter) { private static State getStateForUnitChannel(BsbLanApiParameterDTO parameter) {
String value = StringEscapeUtils.unescapeHtml(parameter.unit); String value = StringEscapeUtils.unescapeHtml4(parameter.unit);
return new StringType(value); return new StringType(value);
} }

View File

@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI; import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI;
import org.openhab.binding.buienradar.internal.buienradarapi.Prediction; import org.openhab.binding.buienradar.internal.buienradarapi.Prediction;
@ -81,7 +80,7 @@ public class BuienradarHandler extends BaseThingHandler {
this.config = getConfigAs(BuienradarConfiguration.class); this.config = getConfigAs(BuienradarConfiguration.class);
boolean configValid = true; boolean configValid = true;
if (StringUtils.trimToNull(config.location) == null) { if (config.location == null || config.location.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error-missing-location"); "@text/offline.conf-error-missing-location");
configValid = false; configValid = false;

View File

@ -14,7 +14,6 @@ package org.openhab.binding.denonmarantz.internal;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.apache.commons.lang.StringUtils;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType; import org.openhab.core.library.types.PercentType;
@ -184,7 +183,7 @@ public class DenonMarantzState {
} }
public void setNowPlayingArtist(String artist) { 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)) { if (!newVal.equals(this.artist)) {
this.artist = newVal; this.artist = newVal;
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ARTIST, this.artist); handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ARTIST, this.artist);
@ -192,7 +191,7 @@ public class DenonMarantzState {
} }
public void setNowPlayingAlbum(String album) { 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)) { if (!newVal.equals(this.album)) {
this.album = newVal; this.album = newVal;
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ALBUM, this.album); handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_ALBUM, this.album);
@ -200,7 +199,7 @@ public class DenonMarantzState {
} }
public void setNowPlayingTrack(String track) { 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)) { if (!newVal.equals(this.track)) {
this.track = newVal; this.track = newVal;
handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_TRACK, this.track); handler.stateChanged(DenonMarantzBindingConstants.CHANNEL_NOW_PLAYING_TRACK, this.track);

View File

@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.util.StreamReaderDelegate; import javax.xml.stream.util.StreamReaderDelegate;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.client.api.Response;
@ -169,7 +168,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
@Override @Override
protected void internalSendCommand(String command) { protected void internalSendCommand(String command) {
logger.debug("Sending command '{}'", command); logger.debug("Sending command '{}'", command);
if (StringUtils.isBlank(command)) { if (command == null || command.isBlank()) {
logger.warn("Trying to send empty command"); logger.warn("Trying to send empty command");
return; return;
} }
@ -306,7 +305,7 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
String result = HttpUtil.executeUrl("GET", uri, REQUEST_TIMEOUT_MS); String result = HttpUtil.executeUrl("GET", uri, REQUEST_TIMEOUT_MS);
logger.trace("result of getDocument for uri '{}':\r\n{}", uri, result); 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); JAXBContext jc = JAXBContext.newInstance(response);
XMLInputFactory xif = XMLInputFactory.newInstance(); XMLInputFactory xif = XMLInputFactory.newInstance();
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); 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)); ByteArrayInputStream inputStream = new ByteArrayInputStream(sw.toString().getBytes(StandardCharsets.UTF_8));
String result = HttpUtil.executeUrl("POST", uri, inputStream, CONTENT_TYPE_XML, REQUEST_TIMEOUT_MS); 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); JAXBContext jcResponse = JAXBContext.newInstance(response);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -20,7 +20,6 @@ import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration; import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -74,7 +73,7 @@ public class DenonMarantzTelnetClientThread extends Thread {
break; break;
} }
logger.trace("Received from {}: {}", config.getHost(), line); logger.trace("Received from {}: {}", config.getHost(), line);
if (!StringUtils.isBlank(line)) { if (!line.isBlank()) {
listener.receivedLine(line); listener.receivedLine(line);
} }
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {

View File

@ -20,7 +20,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Pattern; 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.DenonMarantzState;
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration; import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
import org.openhab.binding.denonmarantz.internal.connector.DenonMarantzConnector; import org.openhab.binding.denonmarantz.internal.connector.DenonMarantzConnector;
@ -263,7 +263,7 @@ public class DenonMarantzTelnetConnector extends DenonMarantzConnector implement
@Override @Override
protected void internalSendCommand(String command) { protected void internalSendCommand(String command) {
logger.debug("Sending command '{}'", command); logger.debug("Sending command '{}'", command);
if (StringUtils.isBlank(command)) { if (command == null || command.isBlank()) {
logger.warn("Trying to send empty command"); logger.warn("Trying to send empty command");
return; return;
} }

View File

@ -14,7 +14,7 @@ package org.openhab.binding.denonmarantz.internal.xml.adapters;
import javax.xml.bind.annotation.adapters.XmlAdapter; 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 * Adapter to clean up string values

View File

@ -18,7 +18,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; 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.discovery.DiscoveryServiceManager;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler; import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler;
import org.openhab.binding.digitalstrom.internal.handler.CircuitHandler; 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, private ThingUID getDeviceUID(ThingTypeUID thingTypeUID, ThingUID thingUID, Configuration configuration,
ThingUID bridgeUID) { ThingUID bridgeUID) {
if (thingUID == null && StringUtils.isNotBlank((String) configuration.get(DEVICE_DSID))) { String id = (String) configuration.get(DEVICE_DSID);
return new ThingUID(thingTypeUID, bridgeUID, configuration.get(DEVICE_DSID).toString()); if (thingUID == null && id != null && !id.isBlank()) {
return new ThingUID(thingTypeUID, bridgeUID, id);
} }
return thingUID; return thingUID;
} }
@ -208,7 +208,8 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
return thingUID; return thingUID;
} }
String dSID; 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); dSID = getDSSid(configuration);
if (dSID != null) { if (dSID != null) {
configuration.put(DS_ID, dSID); configuration.put(DS_ID, dSID);
@ -225,13 +226,15 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
private String getDSSid(Configuration configuration) { private String getDSSid(Configuration configuration) {
String dSID = null; String dSID = null;
if (StringUtils.isNotBlank((String) configuration.get(HOST))) { String hostConfigValue = (String) configuration.get(HOST);
String host = configuration.get(HOST).toString(); if (hostConfigValue != null && !hostConfigValue.isBlank()) {
String host = hostConfigValue;
String applicationToken = null; String applicationToken = null;
String user = null; String user = null;
String pw = 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(); applicationToken = configuration.get(APPLICATION_TOKEN).toString();
} }
@ -249,8 +252,9 @@ public class DigitalSTROMHandlerFactory extends BaseThingHandlerFactory {
} }
private boolean checkUserPassword(Configuration configuration) { private boolean checkUserPassword(Configuration configuration) {
return StringUtils.isNotBlank((String) configuration.get(USER_NAME)) String userName = (String) configuration.get(USER_NAME);
&& StringUtils.isNotBlank((String) configuration.get(PASSWORD)); String password = (String) configuration.get(PASSWORD);
return userName != null && !userName.isBlank() && password != null && !password.isBlank();
} }
@Override @Override

View File

@ -21,16 +21,17 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler; 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.Circuit;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device; 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.GeneralDeviceInformation;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.OutputModeEnum;
import org.openhab.binding.digitalstrom.internal.providers.DsDeviceThingTypeProvider; import org.openhab.binding.digitalstrom.internal.providers.DsDeviceThingTypeProvider;
import org.openhab.core.config.discovery.AbstractDiscoveryService; import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder; import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.ThingUID;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -126,10 +127,8 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
if (thingUID != null) { if (thingUID != null) {
Map<String, Object> properties = new HashMap<>(1); Map<String, Object> properties = new HashMap<>(1);
properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue()); properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue());
String deviceName = null; String deviceName = device.getName();
if (StringUtils.isNotBlank(device.getName())) { if (deviceName == null || deviceName.isBlank()) {
deviceName = device.getName();
} else {
// if no name is set, the dSID will be used as name // if no name is set, the dSID will be used as name
deviceName = device.getDSID().getValue(); deviceName = device.getDSID().getValue();
} }

View File

@ -20,9 +20,9 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.handler.BridgeHandler; 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.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
import org.openhab.core.config.discovery.AbstractDiscoveryService; import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResult;
@ -103,7 +103,7 @@ public class ZoneTemperatureControlDiscoveryService extends AbstractDiscoverySer
Map<String, Object> properties = new HashMap<>(); Map<String, Object> properties = new HashMap<>();
properties.put(DigitalSTROMBindingConstants.ZONE_ID, tempControlStatus.getZoneID()); properties.put(DigitalSTROMBindingConstants.ZONE_ID, tempControlStatus.getZoneID());
String zoneName = tempControlStatus.getZoneName(); String zoneName = tempControlStatus.getZoneName();
if (StringUtils.isBlank(zoneName)) { if (zoneName == null || zoneName.isBlank()) {
zoneName = tempControlStatus.getZoneID().toString(); zoneName = tempControlStatus.getZoneID().toString();
} }
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties) DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)

View File

@ -25,7 +25,6 @@ import java.util.Set;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; 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.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
import org.openhab.binding.digitalstrom.internal.lib.config.Config; import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@ -198,9 +197,10 @@ public class BridgeHandler extends BaseBridgeHandler
if (versions != null) { if (versions != null) {
properties.putAll(versions); properties.putAll(versions);
} }
if (StringUtils.isBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT)) String certProperty = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
&& StringUtils.isNotBlank(config.getCert())) { String certConfig = config.getCert();
properties.put(DigitalSTROMBindingConstants.SERVER_CERT, config.getCert()); if ((certProperty == null || certProperty.isBlank()) && (certConfig != null && !certConfig.isBlank())) {
properties.put(DigitalSTROMBindingConstants.SERVER_CERT, certConfig);
} }
logger.debug("update properties"); logger.debug("update properties");
updateProperties(properties); updateProperties(properties);
@ -235,8 +235,12 @@ public class BridgeHandler extends BaseBridgeHandler
} }
private boolean checkLoginConfig(Config config) { private boolean checkLoginConfig(Config config) {
if ((StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword())) String userName = config.getUserName();
|| StringUtils.isNotBlank(config.getAppToken())) { String password = config.getPassword();
String appToken = config.getAppToken();
if (((userName != null && !userName.isBlank()) && (password != null && !password.isBlank()))
|| (appToken != null && !appToken.isBlank())) {
return true; return true;
} }
onConnectionStateChange(CONNECTION_LOST, NO_USER_PASSWORD); 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."); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, excText + " have to be a number.");
return null; return null;
} }
if (StringUtils.isNotBlank(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT))) { String servertCert = getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT);
config.setCert(getThing().getProperties().get(DigitalSTROMBindingConstants.SERVER_CERT)); if (servertCert != null && !servertCert.isBlank()) {
config.setCert(servertCert);
} }
return config; return config;
} }
@ -307,8 +312,9 @@ public class BridgeHandler extends BaseBridgeHandler
this.config = new Config(); this.config = new Config();
} }
// load and check connection and authorization data // load and check connection and authorization data
if (StringUtils.isNotBlank((String) thingConfig.get(HOST))) { String host = (String) thingConfig.get(HOST);
config.setHost(thingConfig.get(HOST).toString()); if (host != null && !host.isBlank()) {
config.setHost(host);
} else { } else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, 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."); "The connection to the digitalSTROM-Server can't established, because the host address is missing. Please set the host address.");

View File

@ -16,7 +16,6 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.listener.DeviceStatusListener; import org.openhab.binding.digitalstrom.internal.lib.listener.DeviceStatusListener;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit; import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
@ -77,8 +76,8 @@ public class CircuitHandler extends BaseThingHandler implements DeviceStatusList
@Override @Override
public void initialize() { public void initialize() {
logger.debug("Initializing CircuitHandler."); logger.debug("Initializing CircuitHandler.");
if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) { dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString(); if (dSID != null && !dSID.isBlank()) {
final Bridge bridge = getBridge(); final Bridge bridge = getBridge();
if (bridge != null) { if (bridge != null) {
bridgeStatusChanged(bridge.getStatusInfo()); bridgeStatusChanged(bridge.getStatusInfo());

View File

@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance; import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.config.Config; import org.openhab.binding.digitalstrom.internal.lib.config.Config;
@ -108,8 +107,8 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
@Override @Override
public void initialize() { public void initialize() {
logger.debug("Initializing DeviceHandler."); logger.debug("Initializing DeviceHandler.");
if (StringUtils.isNotBlank((String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID))) { dSID = (String) getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID);
dSID = getConfig().get(DigitalSTROMBindingConstants.DEVICE_DSID).toString(); if (dSID != null && !dSID.isBlank()) {
final Bridge bridge = getBridge(); final Bridge bridge = getBridge();
if (bridge != null) { if (bridge != null) {
bridgeStatusChanged(bridge.getStatusInfo()); bridgeStatusChanged(bridge.getStatusInfo());

View File

@ -14,7 +14,6 @@ package org.openhab.binding.digitalstrom.internal.lib.manager.impl;
import java.net.HttpURLConnection; 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.config.Config;
import org.openhab.binding.digitalstrom.internal.lib.listener.ConnectionListener; import org.openhab.binding.digitalstrom.internal.lib.listener.ConnectionListener;
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager; import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
@ -286,8 +285,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
@Override @Override
public String getNewSessionToken() { public String getNewSessionToken() {
if (this.genAppToken) { if (this.genAppToken) {
if (StringUtils.isNotBlank(config.getAppToken())) { String token = config.getAppToken();
sessionToken = this.digitalSTROMClient.loginApplication(config.getAppToken()); if (token != null && !token.isBlank()) {
sessionToken = this.digitalSTROMClient.loginApplication(token);
} else if (codeIsAuthentificationFaild()) { } else if (codeIsAuthentificationFaild()) {
onNotAuthenticated(); onNotAuthenticated();
} }
@ -379,8 +379,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
private void onNotAuthenticated() { private void onNotAuthenticated() {
String applicationToken = null; String applicationToken = null;
boolean isAuthenticated = false; boolean isAuthenticated = false;
if (StringUtils.isNotBlank(config.getAppToken())) { String token = config.getAppToken();
sessionToken = digitalSTROMClient.loginApplication(config.getAppToken()); if (token != null && !token.isBlank()) {
sessionToken = digitalSTROMClient.loginApplication(token);
if (sessionToken != null) { if (sessionToken != null) {
isAuthenticated = true; isAuthenticated = true;
} else { } else {
@ -425,7 +426,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
logger.debug( logger.debug(
"no application-token for application {} found, generate a application-token {}", "no application-token for application {} found, generate a application-token {}",
config.getApplicationName(), applicationToken); config.getApplicationName(), applicationToken);
if (StringUtils.isNotBlank(applicationToken)) { if (applicationToken != null && !applicationToken.isBlank()) {
// enable applicationToken // enable applicationToken
if (!digitalSTROMClient.enableApplicationToken(applicationToken, if (!digitalSTROMClient.enableApplicationToken(applicationToken,
digitalSTROMClient.login(config.getUserName(), config.getPassword()))) { digitalSTROMClient.login(config.getUserName(), config.getPassword()))) {
@ -464,10 +465,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
} }
private boolean checkUserPassword() { private boolean checkUserPassword() {
if (StringUtils.isNotBlank(config.getUserName()) && StringUtils.isNotBlank(config.getPassword())) { String userName = config.getUserName();
return true; String password = config.getPassword();
} return userName != null && !userName.isBlank() && password != null && !password.isBlank();
return false;
} }
/** /**
@ -509,8 +509,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
@Override @Override
public boolean removeApplicationToken() { public boolean removeApplicationToken() {
if (StringUtils.isNotBlank(config.getAppToken())) { String token = config.getAppToken();
return digitalSTROMClient.revokeToken(config.getAppToken(), null); if (token != null && !token.isBlank()) {
return digitalSTROMClient.revokeToken(token, null);
} }
return true; return true;
} }

View File

@ -22,7 +22,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; 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.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseSensorValues; import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseSensorValues;
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.AssignedSensors; 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) { 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) { private boolean checkRequiredDevice(DSID dsid, String dSUID, String name) {
return StringUtils.isNotBlank(SimpleRequestBuilder.objectToString(dsid)) || StringUtils.isNotBlank(name) String objectString = SimpleRequestBuilder.objectToString(dsid);
|| StringUtils.isNotBlank(dSUID); return (objectString != null && !objectString.isBlank()) || (name != null && !name.isBlank())
|| (dSUID != null && !dSUID.isBlank());
} }
@Override @Override
@ -411,7 +411,7 @@ public class DsAPIImpl implements DsAPI {
@Override @Override
public boolean subscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout, public boolean subscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
int readTimeout) { int readTimeout) {
if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) { if ((name != null && !name.isBlank()) && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
String response; String response;
response = transport.execute( response = transport.execute(
SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.SUBSCRIBE) SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.SUBSCRIBE)
@ -428,7 +428,7 @@ public class DsAPIImpl implements DsAPI {
@Override @Override
public boolean unsubscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout, public boolean unsubscribeEvent(String token, String name, Integer subscriptionID, int connectionTimeout,
int readTimeout) { int readTimeout) {
if (StringUtils.isNotBlank(name) && SimpleRequestBuilder.objectToString(subscriptionID) != null) { if (name != null && !name.isBlank() && SimpleRequestBuilder.objectToString(subscriptionID) != null) {
String response; String response;
response = transport.execute( response = transport.execute(
SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.UNSUBSCRIBE) SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.EVENT).addFunction(FunctionKeys.UNSUBSCRIBE)
@ -586,7 +586,7 @@ public class DsAPIImpl implements DsAPI {
@Override @Override
public String loginApplication(String loginToken) { public String loginApplication(String loginToken) {
if (StringUtils.isNotBlank(loginToken)) { if (loginToken != null && !loginToken.isBlank()) {
String response = transport.execute(SimpleRequestBuilder.buildNewRequest(InterfaceKeys.JSON) String response = transport.execute(SimpleRequestBuilder.buildNewRequest(InterfaceKeys.JSON)
.addRequestClass(ClassKeys.SYSTEM).addFunction(FunctionKeys.LOGIN_APPLICATION) .addRequestClass(ClassKeys.SYSTEM).addFunction(FunctionKeys.LOGIN_APPLICATION)
.addParameter(ParameterKeys.LOGIN_TOKEN, loginToken).buildRequestString()); .addParameter(ParameterKeys.LOGIN_TOKEN, loginToken).buildRequestString());

View File

@ -43,7 +43,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.commons.io.IOUtils; 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.config.Config;
import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager; import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport; import org.openhab.binding.digitalstrom.internal.lib.serverconnection.HttpTransport;
@ -194,13 +194,14 @@ public class HttpTransportImpl implements HttpTransport {
if (config != null) { if (config != null) {
cert = config.getCert(); cert = config.getCert();
logger.debug("generate SSLcontext from config cert"); logger.debug("generate SSLcontext from config cert");
if (StringUtils.isNotBlank(cert)) { if (cert != null && !cert.isBlank()) {
sslSocketFactory = generateSSLContextFromPEMCertString(cert); sslSocketFactory = generateSSLContextFromPEMCertString(cert);
} else { } else {
if (StringUtils.isNotBlank(config.getTrustCertPath())) { String trustCertPath = config.getTrustCertPath();
if (trustCertPath != null && !trustCertPath.isBlank()) {
logger.debug("generate SSLcontext from config cert path"); logger.debug("generate SSLcontext from config cert path");
cert = readPEMCertificateStringFromFile(config.getTrustCertPath()); cert = readPEMCertificateStringFromFile(trustCertPath);
if (StringUtils.isNotBlank(cert)) { if (cert != null && !cert.isBlank()) {
sslSocketFactory = generateSSLContextFromPEMCertString(cert); sslSocketFactory = generateSSLContextFromPEMCertString(cert);
} }
} else { } else {
@ -355,7 +356,7 @@ public class HttpTransportImpl implements HttpTransport {
private HttpsURLConnection getConnection(String request, int connectTimeout, int readTimeout) throws IOException { private HttpsURLConnection getConnection(String request, int connectTimeout, int readTimeout) throws IOException {
String correctedRequest = request; String correctedRequest = request;
if (StringUtils.isNotBlank(correctedRequest)) { if (correctedRequest != null && !correctedRequest.isBlank()) {
correctedRequest = fixRequest(correctedRequest); correctedRequest = fixRequest(correctedRequest);
URL url = new URL(this.uri + correctedRequest); URL url = new URL(this.uri + correctedRequest);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
@ -415,7 +416,7 @@ public class HttpTransportImpl implements HttpTransport {
} }
private String readPEMCertificateStringFromFile(String path) { private String readPEMCertificateStringFromFile(String path) {
if (StringUtils.isBlank(path)) { if (path == null || path.isBlank()) {
logger.error("Path is empty."); logger.error("Path is empty.");
} else { } else {
File dssCert = new File(path); File dssCert = new File(path);
@ -446,9 +447,9 @@ public class HttpTransportImpl implements HttpTransport {
@Override @Override
public String writePEMCertFile(String path) { public String writePEMCertFile(String path) {
String correctedPath = StringUtils.trimToEmpty(path); String correctedPath = path == null ? "" : path.trim();
File certFilePath; File certFilePath;
if (StringUtils.isNotBlank(correctedPath)) { if (!correctedPath.isBlank()) {
certFilePath = new File(correctedPath); certFilePath = new File(correctedPath);
boolean pathExists = certFilePath.exists(); boolean pathExists = certFilePath.exists();
if (!pathExists) { if (!pathExists) {
@ -485,7 +486,7 @@ public class HttpTransportImpl implements HttpTransport {
} }
private SSLSocketFactory generateSSLContextFromPEMCertString(String pemCert) { private SSLSocketFactory generateSSLContextFromPEMCertString(String pemCert) {
if (StringUtils.isNotBlank(pemCert) && pemCert.startsWith(BEGIN_CERT)) { if (pemCert != null && !pemCert.isBlank() && pemCert.startsWith(BEGIN_CERT)) {
try { try {
InputStream certInputStream = IOUtils.toInputStream(pemCert); InputStream certInputStream = IOUtils.toInputStream(pemCert);
final X509Certificate trustedCert = (X509Certificate) CertificateFactory.getInstance("X.509") final X509Certificate trustedCert = (X509Certificate) CertificateFactory.getInstance("X.509")

View File

@ -15,7 +15,6 @@ package org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsr
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; 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.ExeptionConstants;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.InterfaceKeys; import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.InterfaceKeys;
import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ParameterKeys; import org.openhab.binding.digitalstrom.internal.lib.serverconnection.simpledsrequestbuilder.constants.ParameterKeys;
@ -61,7 +60,7 @@ public class SimpleRequestBuilder {
* @return simpleRequestBuilder with chosen interface * @return simpleRequestBuilder with chosen interface
* @throws NullArgumentException if the interfaceKey is null * @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) { if (builder == null) {
builder = new SimpleRequestBuilder(); builder = new SimpleRequestBuilder();
} }
@ -78,14 +77,13 @@ public class SimpleRequestBuilder {
* @throws IllegalArgumentException if a requestClass is already chosen * @throws IllegalArgumentException if a requestClass is already chosen
* @throws NullArgumentException if the requestClassKey is null * @throws NullArgumentException if the requestClassKey is null
*/ */
public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey) public static SimpleRequestBuilder buildNewJsonRequest(String requestClassKey) throws IllegalArgumentException {
throws NullArgumentException, IllegalArgumentException {
return buildNewRequest(InterfaceKeys.JSON).addRequestClass(requestClassKey); return buildNewRequest(InterfaceKeys.JSON).addRequestClass(requestClassKey);
} }
private SimpleRequestBuilder buildNewRequestInt(String interfaceKey) { private SimpleRequestBuilder buildNewRequestInt(String interfaceKey) {
if (interfaceKey == null) { if (interfaceKey == null) {
throw new NullArgumentException("interfaceKey"); throw new IllegalArgumentException("interfaceKey is null");
} }
request = "/" + interfaceKey + "/"; request = "/" + interfaceKey + "/";
classIsChosen = false; classIsChosen = false;
@ -102,8 +100,7 @@ public class SimpleRequestBuilder {
* @throws IllegalArgumentException if a requestClass is already chosen * @throws IllegalArgumentException if a requestClass is already chosen
* @throws NullArgumentException if the requestClassKey is null * @throws NullArgumentException if the requestClassKey is null
*/ */
public SimpleRequestBuilder addRequestClass(String requestClassKey) public SimpleRequestBuilder addRequestClass(String requestClassKey) throws IllegalArgumentException {
throws IllegalArgumentException, NullArgumentException {
return builder.addRequestClassInt(requestClassKey); return builder.addRequestClassInt(requestClassKey);
} }
@ -115,7 +112,7 @@ public class SimpleRequestBuilder {
if (!classIsChosen) { if (!classIsChosen) {
throw new IllegalArgumentException(ExeptionConstants.CLASS_ALREADY_ADDED); throw new IllegalArgumentException(ExeptionConstants.CLASS_ALREADY_ADDED);
} else { } else {
throw new NullArgumentException("requestClassKey"); throw new IllegalArgumentException("requestClassKey is null");
} }
} }
return this; return this;
@ -129,7 +126,7 @@ public class SimpleRequestBuilder {
* @throws IllegalArgumentException if a function is already chosen * @throws IllegalArgumentException if a function is already chosen
* @throws NullArgumentException if the functionKey is null * @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); return builder.addFunctionInt(functionKey);
} }
@ -142,7 +139,7 @@ public class SimpleRequestBuilder {
functionIsChosen = true; functionIsChosen = true;
request = request + functionKey; request = request + functionKey;
} else { } else {
throw new NullArgumentException("functionKey"); throw new IllegalArgumentException("functionKey is null");
} }
} else { } else {
throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED); throw new IllegalArgumentException(ExeptionConstants.FUNCTION_ALLREADY_ADDED);
@ -160,7 +157,7 @@ public class SimpleRequestBuilder {
* @throws NullArgumentException if the parameterKey is null * @throws NullArgumentException if the parameterKey is null
*/ */
public SimpleRequestBuilder addParameter(String parameterKey, String parameterValue) public SimpleRequestBuilder addParameter(String parameterKey, String parameterValue)
throws IllegalArgumentException, NullArgumentException { throws IllegalArgumentException {
return builder.addParameterInt(parameterKey, parameterValue); return builder.addParameterInt(parameterKey, parameterValue);
} }
@ -175,7 +172,7 @@ public class SimpleRequestBuilder {
* @throws NullArgumentException if the parameterKey is null * @throws NullArgumentException if the parameterKey is null
*/ */
public SimpleRequestBuilder addDefaultZoneParameter(String sessionToken, Integer zoneID, String zoneName) public SimpleRequestBuilder addDefaultZoneParameter(String sessionToken, Integer zoneID, String zoneName)
throws IllegalArgumentException, NullArgumentException { throws IllegalArgumentException {
return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.ID, objectToString(zoneID)) return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.ID, objectToString(zoneID))
.addParameter(ParameterKeys.NAME, zoneName); .addParameter(ParameterKeys.NAME, zoneName);
} }
@ -191,7 +188,7 @@ public class SimpleRequestBuilder {
* @throws NullArgumentException if the parameterKey is null * @throws NullArgumentException if the parameterKey is null
*/ */
public SimpleRequestBuilder addDefaultGroupParameter(String sessionToken, Short groupID, String groupName) public SimpleRequestBuilder addDefaultGroupParameter(String sessionToken, Short groupID, String groupName)
throws IllegalArgumentException, NullArgumentException { throws IllegalArgumentException {
return addParameter(ParameterKeys.TOKEN, sessionToken) return addParameter(ParameterKeys.TOKEN, sessionToken)
.addParameter(ParameterKeys.GROUP_ID, objectToString(groupID)) .addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
.addParameter(ParameterKeys.GROUP_NAME, groupName); .addParameter(ParameterKeys.GROUP_NAME, groupName);
@ -210,7 +207,7 @@ public class SimpleRequestBuilder {
* @throws NullArgumentException if the parameterKey is null * @throws NullArgumentException if the parameterKey is null
*/ */
public SimpleRequestBuilder addDefaultZoneGroupParameter(String sessionToken, Integer zoneID, String zoneName, 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) return addDefaultZoneParameter(sessionToken, zoneID, zoneName)
.addParameter(ParameterKeys.GROUP_ID, objectToString(groupID)) .addParameter(ParameterKeys.GROUP_ID, objectToString(groupID))
.addParameter(ParameterKeys.GROUP_NAME, groupName); .addParameter(ParameterKeys.GROUP_NAME, groupName);
@ -228,7 +225,7 @@ public class SimpleRequestBuilder {
* @throws NullArgumentException if the parameterKey is null * @throws NullArgumentException if the parameterKey is null
*/ */
public SimpleRequestBuilder addDefaultDeviceParameter(String sessionToken, DSID dsid, String dSUID, String name) 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)) return addParameter(ParameterKeys.TOKEN, sessionToken).addParameter(ParameterKeys.DSID, objectToString(dsid))
.addParameter(ParameterKeys.DSUID, dSUID).addParameter(ParameterKeys.NAME, name); .addParameter(ParameterKeys.DSUID, dSUID).addParameter(ParameterKeys.NAME, name);
} }
@ -236,7 +233,7 @@ public class SimpleRequestBuilder {
private SimpleRequestBuilder addParameterInt(String parameterKey, String parameterValue) { private SimpleRequestBuilder addParameterInt(String parameterKey, String parameterValue) {
if (allRight()) { if (allRight()) {
if (parameterKey == null) { if (parameterKey == null) {
throw new NullArgumentException("parameterKey"); throw new IllegalArgumentException("parameterKey is null");
} }
if (parameterValue != null) { if (parameterValue != null) {
if (!parameterIsAdded) { if (!parameterIsAdded) {

View File

@ -22,7 +22,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants; import org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants;
import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance; import org.openhab.binding.digitalstrom.internal.lib.GeneralLibConstance;
import org.openhab.binding.digitalstrom.internal.lib.config.Config; 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 short sceneID = Short.parseShort((String) key
.subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length())); .subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length()));
sceneSave = propertries.get(key); 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, logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid,
key); key);
String[] sceneParm = sceneSave.replace(" ", "").split(","); String[] sceneParm = sceneSave.replace(" ", "").split(",");

View File

@ -16,7 +16,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; 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.listener.SceneStatusListener;
import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device; import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
import org.openhab.binding.digitalstrom.internal.lib.structure.scene.constants.SceneTypes; import org.openhab.binding.digitalstrom.internal.lib.structure.scene.constants.SceneTypes;
@ -71,7 +70,7 @@ public class InternalScene {
this.zoneID = zoneID; this.zoneID = zoneID;
} }
this.internalSceneID = this.zoneID + "-" + this.groupID + "-" + this.sceneID; this.internalSceneID = this.zoneID + "-" + this.groupID + "-" + this.sceneID;
if (StringUtils.isBlank(sceneName)) { if (sceneName == null || sceneName.isBlank()) {
this.sceneName = this.internalSceneID; this.sceneName = this.internalSceneID;
} else { } else {
this.sceneName = sceneName; this.sceneName = sceneName;

View File

@ -13,8 +13,9 @@
package org.openhab.binding.digitalstrom.internal.providers; package org.openhab.binding.digitalstrom.internal.providers;
import java.util.Locale; 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.openhab.core.i18n.TranslationProvider;
import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
@ -132,6 +133,9 @@ public abstract class BaseDsI18n {
* @return key * @return key
*/ */
public static String buildIdentifier(Object... parts) { 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));
} }
} }

View File

@ -26,7 +26,7 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeoutException; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;

View File

@ -18,8 +18,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -133,8 +132,9 @@ public class EcobeeAuth {
logger.debug("EcobeeAuth: Got null authorize response from Ecobee API"); logger.debug("EcobeeAuth: Got null authorize response from Ecobee API");
setState(EcobeeAuthState.NEED_PIN); setState(EcobeeAuthState.NEED_PIN);
} else { } else {
if (StringUtils.isNotEmpty(authResponse.error)) { String error = authResponse.error;
throw new EcobeeAuthException(authResponse.error + ": " + authResponse.errorDescription); if (error != null && !error.isEmpty()) {
throw new EcobeeAuthException(error + ": " + authResponse.errorDescription);
} }
code = authResponse.code; code = authResponse.code;
writeLogMessage(authResponse.pin, authResponse.expiresIn); writeLogMessage(authResponse.pin, authResponse.expiresIn);
@ -172,8 +172,9 @@ public class EcobeeAuth {
setState(isPinExpired() ? EcobeeAuthState.NEED_PIN : EcobeeAuthState.NEED_TOKEN); setState(isPinExpired() ? EcobeeAuthState.NEED_PIN : EcobeeAuthState.NEED_TOKEN);
return; return;
} }
if (StringUtils.isNotEmpty(tokenResponse.error)) { String error = tokenResponse.error;
throw new EcobeeAuthException(tokenResponse.error + ": " + tokenResponse.errorDescription); if (error != null && !error.isEmpty()) {
throw new EcobeeAuthException(error + ": " + tokenResponse.errorDescription);
} }
AccessTokenResponse accessTokenResponse = new AccessTokenResponse(); AccessTokenResponse accessTokenResponse = new AccessTokenResponse();
accessTokenResponse.setRefreshToken(tokenResponse.refreshToken); accessTokenResponse.setRefreshToken(tokenResponse.refreshToken);

View File

@ -17,7 +17,7 @@ import static org.openhab.binding.ecobee.internal.EcobeeBindingConstants.*;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; 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.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration; import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration;
import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO; import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO;

View File

@ -25,7 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import javax.measure.Unit; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ecobee.internal.action.EcobeeActions; import org.openhab.binding.ecobee.internal.action.EcobeeActions;

View File

@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TooManyListenersException; 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.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPort; import org.openhab.core.io.transport.serial.SerialPort;
import org.openhab.core.io.transport.serial.SerialPortEvent; import org.openhab.core.io.transport.serial.SerialPortEvent;

View File

@ -24,7 +24,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.util.UrlEncoded; import org.eclipse.jetty.util.UrlEncoded;
@ -94,7 +93,7 @@ public class Enigma2Client {
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
logger.warn("Failed setting parser features against XXE attacks!", 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; this.host = "http://" + user + ":" + password + "@" + host;
} else { } else {
this.host = "http://" + host; this.host = "http://" + host;

View File

@ -23,7 +23,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Predicate; 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.config.EnOceanBaseConfig;
import org.openhab.binding.enocean.internal.eep.EEP; import org.openhab.binding.enocean.internal.eep.EEP;
import org.openhab.binding.enocean.internal.eep.EEPFactory; import org.openhab.binding.enocean.internal.eep.EEPFactory;
@ -135,7 +134,7 @@ public class EnOceanBaseSensorHandler extends EnOceanBaseThingHandler implements
} }
protected void sendRequestResponse() { protected void sendRequestResponse() {
throw new NotImplementedException("Sensor cannot send responses"); throw new UnsupportedOperationException("Sensor cannot send responses");
} }
@Override @Override

View File

@ -20,7 +20,6 @@ import java.util.List;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -95,14 +94,15 @@ public class EnturNoHandler extends BaseThingHandler {
logger.debug("Stop place id: {}", stopId); logger.debug("Stop place id: {}", stopId);
boolean configValid = true; boolean configValid = true;
if (StringUtils.trimToNull(stopId) == null) { if (stopId == null || stopId.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error-missing-stopId"); "@text/offline.conf-error-missing-stopId");
configValid = false; configValid = false;
} }
logger.debug("Line code: {}", config.getLineCode()); String lineCode = config.getLineCode();
if (StringUtils.trimToNull(config.getLineCode()) == null) { logger.debug("Line code: {}", lineCode);
if (lineCode == null || lineCode.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error-missing-lineCode"); "@text/offline.conf-error-missing-lineCode");
configValid = false; configValid = false;

View File

@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -96,9 +96,9 @@ public class EnturNoConnection {
*/ */
public synchronized List<DisplayData> getEnturTimeTable(@Nullable String stopPlaceId, @Nullable String lineCode) public synchronized List<DisplayData> getEnturTimeTable(@Nullable String stopPlaceId, @Nullable String lineCode)
throws JsonSyntaxException, EnturConfigurationException, EnturCommunicationException { throws JsonSyntaxException, EnturConfigurationException, EnturCommunicationException {
if (StringUtils.isBlank(stopPlaceId)) { if (stopPlaceId == null || stopPlaceId.isBlank()) {
throw new EnturConfigurationException("Stop place id cannot be empty or null"); 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"); throw new EnturConfigurationException("Line code cannot be empty or null");
} }
@ -115,8 +115,9 @@ public class EnturNoConnection {
private Map<String, String> getRequestParams(EnturNoConfiguration config) { private Map<String, String> getRequestParams(EnturNoConfiguration config) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put(PARAM_STOPID, StringUtils.trimToEmpty(config.getStopPlaceId())); String stopPlaceId = config.getStopPlaceId();
params.put(PARAM_START_DATE_TIME, StringUtils.trimToEmpty(LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString())); params.put(PARAM_STOPID, stopPlaceId == null ? "" : stopPlaceId.trim());
params.put(PARAM_START_DATE_TIME, LocalDateTime.now(ZoneId.of(TIME_ZONE)).toString());
return params; return params;
} }
@ -141,7 +142,7 @@ public class EnturNoConnection {
int httpStatus = contentResponse.getStatus(); int httpStatus = contentResponse.getStatus();
String content = contentResponse.getContentAsString(); String content = contentResponse.getContentAsString();
String errorMessage = StringUtils.EMPTY; String errorMessage = "";
logger.trace("Entur response: status = {}, content = '{}'", httpStatus, content); logger.trace("Entur response: status = {}, content = '{}'", httpStatus, content);
switch (httpStatus) { switch (httpStatus) {
case OK_200: case OK_200:

View File

@ -12,7 +12,6 @@
*/ */
package org.openhab.binding.evohome.internal.handler; 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.api.models.v2.response.Locations;
import org.openhab.binding.evohome.internal.configuration.EvohomeThingConfiguration; import org.openhab.binding.evohome.internal.configuration.EvohomeThingConfiguration;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -132,7 +131,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler {
if (configuration == null) { if (configuration == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Configuration is missing or corrupted"); "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"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Id not configured");
} }
} }

View File

@ -22,7 +22,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.evohome.internal.RunnableWithTimeout; import org.openhab.binding.evohome.internal.RunnableWithTimeout;
import org.openhab.binding.evohome.internal.api.EvohomeApiClient; import org.openhab.binding.evohome.internal.api.EvohomeApiClient;
@ -190,9 +189,9 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler {
if (configuration == null) { if (configuration == null) {
errorMessage = "Configuration is missing or corrupted"; errorMessage = "Configuration is missing or corrupted";
} else if (StringUtils.isEmpty(configuration.username)) { } else if (configuration.username == null || configuration.username.isEmpty()) {
errorMessage = "Username not configured"; errorMessage = "Username not configured";
} else if (StringUtils.isEmpty(configuration.password)) { } else if (configuration.password == null || configuration.password.isEmpty()) {
errorMessage = "Password not configured"; errorMessage = "Password not configured";
} else { } else {
return true; return true;

View File

@ -29,7 +29,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.exec.internal.ExecWhitelistWatchService; import org.openhab.binding.exec.internal.ExecWhitelistWatchService;

View File

@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -156,7 +155,7 @@ public class FoobotApiConnector {
apiKeyLimitRemaining = API_RATE_LIMIT_EXCEEDED; apiKeyLimitRemaining = API_RATE_LIMIT_EXCEEDED;
throw new FoobotApiException(response.getStatus(), API_RATE_LIMIT_EXCEEDED_MESSAGE); throw new FoobotApiException(response.getStatus(), API_RATE_LIMIT_EXCEEDED_MESSAGE);
case HttpStatus.OK_200: case HttpStatus.OK_200:
if (StringUtils.trimToNull(content) == null) { if (content == null || content.isBlank()) {
throw new FoobotApiException(0, "No data returned"); throw new FoobotApiException(0, "No data returned");
} }
return content; return content;

View File

@ -15,12 +15,14 @@ package org.openhab.binding.foobot.internal.handler;
import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*; import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
import java.time.Duration; 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.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.foobot.internal.FoobotApiConnector; import org.openhab.binding.foobot.internal.FoobotApiConnector;
@ -93,10 +95,12 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
final FoobotAccountConfiguration accountConfig = getConfigAs(FoobotAccountConfiguration.class); final FoobotAccountConfiguration accountConfig = getConfigAs(FoobotAccountConfiguration.class);
final List<String> missingParams = new ArrayList<>(); final List<String> missingParams = new ArrayList<>();
if (StringUtils.trimToNull(accountConfig.apiKey) == null) { String apiKey = accountConfig.apiKey;
if (apiKey.isBlank()) {
missingParams.add("'apikey'"); missingParams.add("'apikey'");
} }
if (StringUtils.trimToNull(accountConfig.username) == null) { String username = accountConfig.username;
if (username.isBlank()) {
missingParams.add("'username'"); missingParams.add("'username'");
} }
@ -104,13 +108,13 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
final boolean oneParam = missingParams.size() == 1; final boolean oneParam = missingParams.size() == 1;
final String errorMsg = String.format( final String errorMsg = String.format(
"Parameter%s [%s] %s mandatory and must be configured and not be empty", oneParam ? "" : "s", "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); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, errorMsg);
return; return;
} }
username = accountConfig.username; this.username = username;
connector.setApiKey(accountConfig.apiKey); connector.setApiKey(apiKey);
refreshInterval = accountConfig.refreshInterval; refreshInterval = accountConfig.refreshInterval;
if (this.refreshInterval < MINIMUM_REFRESH_PERIOD_MINUTES) { if (this.refreshInterval < MINIMUM_REFRESH_PERIOD_MINUTES) {
logger.warn( logger.warn(
@ -118,8 +122,7 @@ public class FoobotAccountHandler extends BaseBridgeHandler {
accountConfig.refreshInterval, MINIMUM_REFRESH_PERIOD_MINUTES, DEFAULT_REFRESH_PERIOD_MINUTES); accountConfig.refreshInterval, MINIMUM_REFRESH_PERIOD_MINUTES, DEFAULT_REFRESH_PERIOD_MINUTES);
refreshInterval = DEFAULT_REFRESH_PERIOD_MINUTES; refreshInterval = DEFAULT_REFRESH_PERIOD_MINUTES;
} }
logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", accountConfig.username, logger.debug("Foobot Account bridge starting... user: {}, refreshInterval: {}", username, refreshInterval);
refreshInterval);
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "Wait to get associated devices"); updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "Wait to get associated devices");

View File

@ -21,7 +21,6 @@ import java.util.Map;
import javax.measure.Unit; import javax.measure.Unit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.foobot.internal.FoobotApiConnector; import org.openhab.binding.foobot.internal.FoobotApiConnector;
@ -93,7 +92,7 @@ public class FoobotDeviceHandler extends BaseThingHandler {
logger.debug("Initializing Foobot handler."); logger.debug("Initializing Foobot handler.");
uuid = (String) getConfig().get(FoobotBindingConstants.CONFIG_UUID); uuid = (String) getConfig().get(FoobotBindingConstants.CONFIG_UUID);
if (StringUtils.trimToNull(uuid) == null) { if (uuid.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Parameter 'uuid' is mandatory and must be configured"); "Parameter 'uuid' is mandatory and must be configured");
return; return;

View File

@ -18,7 +18,6 @@ import java.util.Set;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration; import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
import org.openhab.core.io.net.http.HttpUtil; import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -62,10 +61,13 @@ public class FroniusBridgeHandler extends BaseBridgeHandler {
boolean validConfig = true; boolean validConfig = true;
String errorMsg = null; 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"; errorMsg = "Parameter 'hostname' is mandatory and must be configured";
validConfig = false; validConfig = false;
} }
if (config.refreshInterval != null && config.refreshInterval <= 0) { if (config.refreshInterval != null && config.refreshInterval <= 0) {
errorMsg = "Parameter 'refresh' must be at least 1 second"; errorMsg = "Parameter 'refresh' must be at least 1 second";
validConfig = false; validConfig = false;

View File

@ -14,7 +14,7 @@ package org.openhab.binding.fronius.internal.handler;
import java.util.Map; 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.FroniusBaseDeviceConfiguration;
import org.openhab.binding.fronius.internal.FroniusBindingConstants; import org.openhab.binding.fronius.internal.FroniusBindingConstants;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration; import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.fronius.internal.handler; 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.FroniusBaseDeviceConfiguration;
import org.openhab.binding.fronius.internal.FroniusBindingConstants; import org.openhab.binding.fronius.internal.FroniusBindingConstants;
import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration; import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;

View File

@ -18,7 +18,6 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.fsinternetradio.internal.radio.FrontierSiliconRadio; import org.openhab.binding.fsinternetradio.internal.radio.FrontierSiliconRadio;
import org.openhab.core.library.types.DecimalType; 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 BigDecimal port = (BigDecimal) getThing().getConfiguration().get(CONFIG_PROPERTY_PORT);
final String pin = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_PIN); 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 // configuration incomplete
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Configuration incomplete"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Configuration incomplete");
} else { } else {

View File

@ -21,9 +21,12 @@ import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindin
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; 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.jdt.annotation.NonNull;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.servlet.ServletHolder; 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()); BigDecimal port = (BigDecimal) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PORT.toString());
String pin = (String) config.get(FSInternetRadioBindingConstants.CONFIG_PROPERTY_PIN.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 false;
} }
return true; return true;

View File

@ -18,7 +18,6 @@ import java.util.Collections;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.ftpserver.DataConnectionConfigurationFactory; import org.apache.ftpserver.DataConnectionConfigurationFactory;
import org.apache.ftpserver.FtpServerConfigurationException; import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException; import org.apache.ftpserver.ftplet.FtpException;
@ -98,7 +97,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
if (properties.get("port") != null) { if (properties.get("port") != null) {
String strPort = properties.get("port").toString(); String strPort = properties.get("port").toString();
if (StringUtils.isNotEmpty(strPort)) { if (!strPort.isEmpty()) {
try { try {
port = Integer.valueOf(strPort); port = Integer.valueOf(strPort);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -109,7 +108,7 @@ public class FtpUploadHandlerFactory extends BaseThingHandlerFactory {
if (properties.get("idleTimeout") != null) { if (properties.get("idleTimeout") != null) {
String strIdleTimeout = properties.get("idleTimeout").toString(); String strIdleTimeout = properties.get("idleTimeout").toString();
if (StringUtils.isNotEmpty(strIdleTimeout)) { if (!strIdleTimeout.isEmpty()) {
try { try {
idleTimeout = Integer.valueOf(strIdleTimeout); idleTimeout = Integer.valueOf(strIdleTimeout);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType; import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
import org.openhab.binding.globalcache.internal.command.CommandGetstate; 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); 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()); logger.warn("MAP file is not defined in configuration of thing {}", thingID());
return null; return null;
} }
@ -266,14 +265,13 @@ public class GlobalCacheHandler extends BaseThingHandler {
String code; String code;
try { try {
code = transformService.transform(mapFile, command.toString()); code = transformService.transform(mapFile, command.toString());
} catch (TransformationException e) { } catch (TransformationException e) {
logger.error("Failed to transform {} for thing {} using map file '{}', exception={}", command, thingID(), logger.error("Failed to transform {} for thing {} using map file '{}', exception={}", command, thingID(),
mapFile, e.getMessage()); mapFile, e.getMessage());
return null; return null;
} }
if (StringUtils.isEmpty(code)) { if (code == null || code.isEmpty()) {
logger.warn("No entry for {} in map file '{}' for thing {}", command, mapFile, thingID()); logger.warn("No entry for {} in map file '{}' for thing {}", command, mapFile, thingID());
return null; return null;
} }
@ -638,7 +636,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
private String getIPAddress() { private String getIPAddress() {
String ipAddress = ((GlobalCacheHandler) thing.getHandler()).getIP(); 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()); logger.debug("Handler for thing {} could not get IP address from config", thingID());
markThingOfflineWithError(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "IP address not set"); markThingOfflineWithError(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "IP address not set");
} }
@ -912,7 +910,7 @@ public class GlobalCacheHandler extends BaseThingHandler {
if (Boolean.TRUE.equals(enableTwoWay)) { if (Boolean.TRUE.equals(enableTwoWay)) {
// Get the end of message delimiter from the config, URL decode it, and convert it to a byte array // 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); 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); logger.debug("End of message is {} for thing {} {}", endOfMessageString, thingID(), serialDevice);
byte[] endOfMessage; byte[] endOfMessage;
try { try {

View File

@ -45,7 +45,7 @@ import java.util.stream.Collectors;
import javax.measure.quantity.ElectricCurrent; import javax.measure.quantity.ElectricCurrent;
import javax.measure.quantity.Energy; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;

View File

@ -25,7 +25,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.harmonyhub.internal.HarmonyHubHandlerFactory; 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, // 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 // this section is to not break that and also update older configurations to use the host configuration
// option instead of name // option instead of name
if (StringUtils.isBlank(host)) { if (host == null || host.isBlank()) {
host = getThing().getProperties().get(HUB_PROPERTY_HOST); host = getThing().getProperties().get(HUB_PROPERTY_HOST);
if (StringUtils.isNotBlank(host)) { if (host != null && !host.isBlank()) {
Configuration genericConfig = getConfig(); Configuration genericConfig = getConfig();
genericConfig.put(HUB_PROPERTY_HOST, host); genericConfig.put(HUB_PROPERTY_HOST, host);
updateConfiguration(genericConfig); updateConfiguration(genericConfig);

View File

@ -12,8 +12,6 @@
*/ */
package org.openhab.binding.hdanywhere.internal.handler; package org.openhab.binding.hdanywhere.internal.handler;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -93,7 +91,6 @@ public class Mhub4K431Handler extends BaseThingHandler {
String content = "{tag:ptn}"; String content = "{tag:ptn}";
InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
if (isNotBlank(httpMethod) && isNotBlank(url)) {
String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout); String response = HttpUtil.executeUrl(httpMethod, url, null, stream, null, timeout);
response = response.trim(); response = response.trim();
response = response.substring(1, response.length() - 1); response = response.substring(1, response.length() - 1);
@ -114,7 +111,6 @@ public class Mhub4K431Handler extends BaseThingHandler {
} else { } else {
updateStatus(ThingStatus.OFFLINE); updateStatus(ThingStatus.OFFLINE);
} }
}
} catch (Exception e) { } catch (Exception e) {
logger.debug("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage()); logger.debug("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
updateStatus(ThingStatus.OFFLINE); updateStatus(ThingStatus.OFFLINE);

View File

@ -12,8 +12,6 @@
*/ */
package org.openhab.binding.hdanywhere.internal.handler; package org.openhab.binding.hdanywhere.internal.handler;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -69,7 +67,6 @@ public class MultiroomPlusHandler extends BaseThingHandler {
String httpMethod = "GET"; String httpMethod = "GET";
String url = "http://" + host + "/status_show.shtml"; 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) { if (response != null) {
@ -87,7 +84,6 @@ public class MultiroomPlusHandler extends BaseThingHandler {
} else { } else {
updateStatus(ThingStatus.OFFLINE); updateStatus(ThingStatus.OFFLINE);
} }
}
} catch (Exception e) { } catch (Exception e) {
logger.warn("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage()); logger.warn("An exception occurred while polling the HDanwywhere matrix: '{}'", e.getMessage());
} }

View File

@ -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.HeosBindingConstants.*;
import static org.openhab.binding.heos.internal.handler.FutureUtil.cancel; 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.*;
import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.PLAYER;
import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*; 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 static org.openhab.core.thing.ThingStatus.*;
import java.io.IOException; import java.io.IOException;
@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit;
import javax.measure.quantity.Time; import javax.measure.quantity.Time;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.heos.internal.HeosChannelHandlerFactory; 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.HeosFunctionalException;
import org.openhab.binding.heos.internal.exception.HeosNotConnectedException; import org.openhab.binding.heos.internal.exception.HeosNotConnectedException;
import org.openhab.binding.heos.internal.exception.HeosNotFoundException; 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.Media;
import org.openhab.binding.heos.internal.json.payload.Player; import org.openhab.binding.heos.internal.json.payload.Player;
import org.openhab.binding.heos.internal.resources.HeosEventListener; import org.openhab.binding.heos.internal.resources.HeosEventListener;
import org.openhab.binding.heos.internal.resources.Telnet.ReadException; import org.openhab.binding.heos.internal.resources.Telnet.ReadException;
import org.openhab.core.io.net.http.HttpUtil; 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.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.thing.binding.BaseThingHandler;
import org.openhab.core.types.UnDefType; import org.openhab.core.types.UnDefType;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -474,16 +489,17 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
} }
private void handleImageUrl(Media info) { private void handleImageUrl(Media info) {
if (StringUtils.isNotBlank(info.imageUrl)) { String imageUrl = info.imageUrl;
if (imageUrl != null && !imageUrl.isBlank()) {
try { 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()); RawType cover = HttpUtil.downloadImage(url.toString());
if (cover != null) { if (cover != null) {
updateState(CH_ID_COVER, cover); updateState(CH_ID_COVER, cover);
return; return;
} }
} catch (MalformedURLException e) { } 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); updateState(CH_ID_COVER, UnDefType.NULL);

View File

@ -16,11 +16,14 @@ import static org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants.*
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; 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.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hydrawise.internal.api.HydrawiseAuthenticationException; 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_TYPE, new DecimalType(r.type));
updateGroupState(group, CHANNEL_ZONE_TIME, updateGroupState(group, CHANNEL_ZONE_TIME,
r.runTimeSeconds != null ? new DecimalType(r.runTimeSeconds) : UnDefType.UNDEF); r.runTimeSeconds != null ? new DecimalType(r.runTimeSeconds) : UnDefType.UNDEF);
if (StringUtils.isNotBlank(r.icon)) { String icon = r.icon;
updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + r.icon)); if (icon != null && !icon.isBlank()) {
updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + icon));
} }
if (r.time >= MAX_RUN_TIME) { if (r.time >= MAX_RUN_TIME) {
updateGroupState(group, CHANNEL_ZONE_NEXT_RUN_TIME_TIME, UnDefType.UNDEF); updateGroupState(group, CHANNEL_ZONE_NEXT_RUN_TIME_TIME, UnDefType.UNDEF);

View File

@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
import javax.measure.Unit; import javax.measure.Unit;
import javax.measure.quantity.Temperature; import javax.measure.quantity.Temperature;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -268,7 +267,7 @@ public class IAqualinkHandler extends BaseThingHandler {
String confSerialId = configuration.serialId; String confSerialId = configuration.serialId;
String confApiKey = configuration.apiKey; String confApiKey = configuration.apiKey;
if (StringUtils.isNotBlank(confApiKey)) { if (confApiKey != null && !confApiKey.isBlank()) {
this.apiKey = confApiKey; this.apiKey = confApiKey;
} else { } else {
this.apiKey = DEFAULT_API_KEY; this.apiKey = DEFAULT_API_KEY;
@ -291,7 +290,7 @@ public class IAqualinkHandler extends BaseThingHandler {
return; return;
} }
if (StringUtils.isNotBlank(confSerialId)) { if (confSerialId != null && !confSerialId.isBlank()) {
serialNumber = confSerialId.replaceAll("[^a-zA-Z0-9]", "").toLowerCase(); serialNumber = confSerialId.replaceAll("[^a-zA-Z0-9]", "").toLowerCase();
if (!Arrays.stream(devices).anyMatch(device -> device.getSerialNumber().equals(serialNumber))) { if (!Arrays.stream(devices).anyMatch(device -> device.getSerialNumber().equals(serialNumber))) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, 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) { private State toState(String name, @Nullable String type, @Nullable String value) {
try { try {
// @nullable checker does not recognize isBlank as checking null here, so must use == null to make happy if (value == null || value.isBlank()) {
if (value == null || StringUtils.isBlank(value)) {
return UnDefType.UNDEF; return UnDefType.UNDEF;
} }

View File

@ -19,7 +19,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; 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.config.ChannelParams;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.core.config.core.Configuration; 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) { private static String createDescription(String name1, String name2, String name3, String name4) {
String description = ""; String description = "";
if (StringUtils.isNotEmpty(name1)) { if (name1 != null && !name1.isEmpty()) {
description = name1; description = name1;
} }
if (StringUtils.isNotEmpty(name2)) { if (name2 != null && !name2.isEmpty()) {
description += String.format(" - %s", name2); description += String.format(" - %s", name2);
} }
if (StringUtils.isNotEmpty(name3)) { if (name3 != null && !name3.isEmpty()) {
description += String.format(" - %s", name3); description += String.format(" - %s", name3);
} }
if (StringUtils.isNotEmpty(name4)) { if (name4 != null && !name4.isEmpty()) {
description += String.format(" - %s", name4); description += String.format(" - %s", name4);
} }
return description; return description;

View File

@ -20,7 +20,6 @@ import java.util.Set;
import javax.xml.xpath.XPathExpressionException; 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.datatypes.XPathUtils;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption; import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool; import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
@ -92,12 +91,12 @@ public class IhcResourceInteractionService extends IhcBaseService {
// parse resource id // parse resource id
String resourceId = XPathUtils.getSpeficValueFromNode(n, "ns1:resourceID"); String resourceId = XPathUtils.getSpeficValueFromNode(n, "ns1:resourceID");
if (StringUtils.isNotBlank(resourceId)) { if (resourceId != null && !resourceId.isBlank()) {
int id = Integer.parseInt(resourceId); int id = Integer.parseInt(resourceId);
// Parse floating point value // Parse floating point value
String floatingPointValue = getValue(n, "floatingPointValue"); String floatingPointValue = getValue(n, "floatingPointValue");
if (StringUtils.isNotBlank(floatingPointValue)) { if (floatingPointValue != null && !floatingPointValue.isBlank()) {
String min = getValue(n, "minimumValue"); String min = getValue(n, "minimumValue");
String max = getValue(n, "maximumValue"); String max = getValue(n, "maximumValue");
return new WSFloatingPointValue(id, Double.valueOf(floatingPointValue), Double.valueOf(min), return new WSFloatingPointValue(id, Double.valueOf(floatingPointValue), Double.valueOf(min),
@ -106,13 +105,13 @@ public class IhcResourceInteractionService extends IhcBaseService {
// Parse boolean value // Parse boolean value
String value = getValue(n, "value"); String value = getValue(n, "value");
if (StringUtils.isNotBlank(value)) { if (value != null && !value.isBlank()) {
return new WSBooleanValue(id, Boolean.valueOf(value)); return new WSBooleanValue(id, Boolean.valueOf(value));
} }
// Parse integer value // Parse integer value
String integer = getValue(n, "integer"); String integer = getValue(n, "integer");
if (StringUtils.isNotBlank(integer)) { if (integer != null && !integer.isBlank()) {
String min = getValue(n, "minimumValue"); String min = getValue(n, "minimumValue");
String max = getValue(n, "maximumValue"); String max = getValue(n, "maximumValue");
return new WSIntegerValue(id, Integer.valueOf(integer), Integer.valueOf(min), Integer.valueOf(max)); 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 // Parse timer value
String milliseconds = getValue(n, "milliseconds"); String milliseconds = getValue(n, "milliseconds");
if (StringUtils.isNotBlank(milliseconds)) { if (milliseconds != null && !milliseconds.isBlank()) {
return new WSTimerValue(id, Integer.valueOf(milliseconds)); return new WSTimerValue(id, Integer.valueOf(milliseconds));
} }
// Parse time value // Parse time value
String hours = getValue(n, "hours"); String hours = getValue(n, "hours");
if (StringUtils.isNotBlank(hours)) { if (hours != null && !hours.isBlank()) {
String minutes = getValue(n, "minutes"); String minutes = getValue(n, "minutes");
String seconds = getValue(n, "seconds"); String seconds = getValue(n, "seconds");
return new WSTimeValue(id, Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(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 // Parse date value
String year = getValue(n, "year"); String year = getValue(n, "year");
if (StringUtils.isNotBlank(year)) { if (year != null && !year.isBlank()) {
String month = getValue(n, "month"); String month = getValue(n, "month");
String day = getValue(n, "day"); String day = getValue(n, "day");
return new WSDateValue(id, Short.valueOf(year), Byte.valueOf(month), Byte.valueOf(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 // Parse enum value
String definitionTypeID = getValue(n, "definitionTypeID"); String definitionTypeID = getValue(n, "definitionTypeID");
if (StringUtils.isNotBlank(definitionTypeID)) { if (definitionTypeID != null && !definitionTypeID.isBlank()) {
String enumValueID = getValue(n, "enumValueID"); String enumValueID = getValue(n, "enumValueID");
String enumName = getValue(n, "enumName"); String enumName = getValue(n, "enumName");
return new WSEnumValue(id, Integer.valueOf(definitionTypeID), Integer.valueOf(enumValueID), 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 // Parse week day value
value = getValue(n, "weekdayNumber"); value = getValue(n, "weekdayNumber");
if (StringUtils.isNotBlank(value)) { if (value != null && !value.isBlank()) {
return new WSWeekdayValue(id, Integer.valueOf(value)); return new WSWeekdayValue(id, Integer.valueOf(value));
} }

View File

@ -16,13 +16,14 @@ import static org.openhab.binding.innogysmarthome.internal.client.Constants.*;
import java.io.IOException; import java.io.IOException;
import java.net.URI; 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.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -180,7 +181,8 @@ public class InnogyClient {
} catch (OAuthException | OAuthResponseException e) { } catch (OAuthException | OAuthResponseException e) {
throw new AuthenticationException("Error fetching access token: " + e.getMessage()); 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?"); throw new AuthenticationException("No innogy accesstoken. Is this thing authorized?");
} }
return accessTokenResponse; return accessTokenResponse;

View File

@ -20,11 +20,19 @@ import java.net.SocketTimeoutException;
import java.net.URI; import java.net.URI;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle; import java.time.format.FormatStyle;
import java.util.*; import java.util.Collection;
import java.util.concurrent.*; 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.lang3.exception.ExceptionUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -183,7 +191,7 @@ public class InnogyBridgeHandler extends BaseBridgeHandler
* @return true if success * @return true if success
*/ */
private boolean checkOnAuthCode() { private boolean checkOnAuthCode() {
if (StringUtils.isNotBlank(bridgeConfiguration.authcode)) { if (!bridgeConfiguration.authcode.isBlank()) {
logger.debug("Trying to get access and refresh tokens"); logger.debug("Trying to get access and refresh tokens");
try { try {
oAuthService.getAccessTokenResponseByAuthorizationCode(bridgeConfiguration.authcode, oAuthService.getAccessTokenResponseByAuthorizationCode(bridgeConfiguration.authcode,

View File

@ -14,7 +14,7 @@ package org.openhab.binding.irtrans.internal.handler;
import static org.openhab.binding.irtrans.internal.IRtransBindingConstants.CHANNEL_IO; 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.IRtransBindingConstants.Led;
import org.openhab.binding.irtrans.internal.IrCommand; import org.openhab.binding.irtrans.internal.IrCommand;
import org.openhab.core.library.types.StringType; import org.openhab.core.library.types.StringType;

View File

@ -35,7 +35,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.irtrans.internal.IRtransBindingConstants; import org.openhab.binding.irtrans.internal.IRtransBindingConstants;
import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led; import org.openhab.binding.irtrans.internal.IRtransBindingConstants.Led;

View File

@ -21,7 +21,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher; import org.openhab.binding.jeelink.internal.ReadingPublisher;
import org.openhab.binding.jeelink.internal.RollingAveragePublisher; import org.openhab.binding.jeelink.internal.RollingAveragePublisher;

View File

@ -18,7 +18,7 @@ import static org.openhab.core.library.unit.MetricPrefix.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler; import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher; import org.openhab.binding.jeelink.internal.ReadingPublisher;

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.kaleidescape.internal.communication; 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; 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 // 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 // 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 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 :( // then convert with unescapeHtml4, not sure how to do this without the Apache libraries :(
return StringEscapeUtils.unescapeHtml(input); return StringEscapeUtils.unescapeHtml4(input);
} }
} }
return input; return input;

View File

@ -15,7 +15,7 @@ package org.openhab.binding.keba.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingTypeUID;

View File

@ -32,7 +32,7 @@ import javax.measure.quantity.Energy;
import javax.measure.quantity.Power; import javax.measure.quantity.Power;
import javax.measure.quantity.Time; 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.KebaSeries;
import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType; import org.openhab.binding.keba.internal.KebaBindingConstants.KebaType;
import org.openhab.core.cache.ExpiringCacheMap; import org.openhab.core.cache.ExpiringCacheMap;

View File

@ -23,7 +23,6 @@ import java.util.Base64;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -131,8 +130,8 @@ public class KM200Cryption {
* @author Markus Eckhardt * @author Markus Eckhardt
*/ */
public void recreateKeys() { public void recreateKeys() {
if (StringUtils.isNotBlank(remoteDevice.getGatewayPassword()) if (!remoteDevice.getGatewayPassword().isBlank() && !remoteDevice.getPrivatePassword().isBlank()
&& StringUtils.isNotBlank(remoteDevice.getPrivatePassword()) && remoteDevice.getMD5Salt().length > 0) { && remoteDevice.getMD5Salt().length > 0) {
byte[] md5K1 = null; byte[] md5K1 = null;
byte[] md5K2Init = null; byte[] md5K2Init = null;
byte[] md5K2Private = null; byte[] md5K2Private = null;

View File

@ -19,8 +19,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -84,7 +83,7 @@ public class KM200Device {
} }
public Boolean isConfigured() { public Boolean isConfigured() {
return StringUtils.isNotBlank(ip4Address) && cryptKeyPriv.length > 0; return !ip4Address.isBlank() && cryptKeyPriv.length > 0;
} }
public String getIP4Address() { public String getIP4Address() {

View File

@ -30,7 +30,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -177,7 +176,7 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
switch (key) { switch (key) {
case "ip4Address": case "ip4Address":
String ip = (String) configuration.get("ip4Address"); String ip = (String) configuration.get("ip4Address");
if (StringUtils.isNotBlank(ip)) { if (ip != null && !ip.isBlank()) {
try { try {
InetAddress.getByName(ip); InetAddress.getByName(ip);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
@ -190,25 +189,25 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
break; break;
case "privateKey": case "privateKey":
String privateKey = (String) configuration.get("privateKey"); String privateKey = (String) configuration.get("privateKey");
if (StringUtils.isNotBlank(privateKey)) { if (privateKey != null && !privateKey.isBlank()) {
getDevice().setCryptKeyPriv(privateKey); getDevice().setCryptKeyPriv(privateKey);
} }
break; break;
case "md5Salt": case "md5Salt":
String md5Salt = (String) configuration.get("md5Salt"); String md5Salt = (String) configuration.get("md5Salt");
if (StringUtils.isNotBlank(md5Salt)) { if (md5Salt != null && !md5Salt.isBlank()) {
getDevice().setMD5Salt(md5Salt); getDevice().setMD5Salt(md5Salt);
} }
break; break;
case "gatewayPassword": case "gatewayPassword":
String gatewayPassword = (String) configuration.get("gatewayPassword"); String gatewayPassword = (String) configuration.get("gatewayPassword");
if (StringUtils.isNotBlank(gatewayPassword)) { if (gatewayPassword != null && !gatewayPassword.isBlank()) {
getDevice().setGatewayPassword(gatewayPassword); getDevice().setGatewayPassword(gatewayPassword);
} }
break; break;
case "privatePassword": case "privatePassword":
String privatePassword = (String) configuration.get("privatePassword"); String privatePassword = (String) configuration.get("privatePassword");
if (StringUtils.isNotBlank(privatePassword)) { if (privatePassword != null && !privatePassword.isBlank()) {
getDevice().setPrivatePassword(privatePassword); getDevice().setPrivatePassword(privatePassword);
} }
break; break;

View File

@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
import javax.ws.rs.client.ClientBuilder; 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.Configuration;
import org.openhab.binding.lametrictime.api.LaMetricTime; import org.openhab.binding.lametrictime.api.LaMetricTime;
import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
@ -360,12 +359,12 @@ public class LaMetricTimeHandler extends ConfigStatusBridgeHandler {
String host = config.host; String host = config.host;
String apiKey = config.apiKey; String apiKey = config.apiKey;
if (StringUtils.isEmpty(host)) { if (host == null || host.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(HOST) configStatusMessages.add(ConfigStatusMessage.Builder.error(HOST)
.withMessageKeySuffix(LaMetricTimeConfigStatusMessage.HOST_MISSING).withArguments(HOST).build()); .withMessageKeySuffix(LaMetricTimeConfigStatusMessage.HOST_MISSING).withArguments(HOST).build());
} }
if (StringUtils.isEmpty(apiKey)) { if (apiKey == null || apiKey.isEmpty()) {
configStatusMessages.add(ConfigStatusMessage.Builder.error(API_KEY) configStatusMessages.add(ConfigStatusMessage.Builder.error(API_KEY)
.withMessageKeySuffix(LaMetricTimeConfigStatusMessage.API_KEY_MISSING).withArguments(API_KEY) .withMessageKeySuffix(LaMetricTimeConfigStatusMessage.API_KEY_MISSING).withArguments(API_KEY)
.build()); .build());

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.lutron.internal.config; 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}. * Configuration settings for an {@link org.openhab.binding.lutron.internal.handler.IPBridgeHandler}.
@ -30,8 +30,8 @@ public class IPBridgeConfig {
public int delay = 0; public int delay = 0;
public boolean sameConnectionParameters(IPBridgeConfig config) { public boolean sameConnectionParameters(IPBridgeConfig config) {
return StringUtils.equals(ipAddress, config.ipAddress) && StringUtils.equals(user, config.user) return Objects.equals(ipAddress, config.ipAddress) && Objects.equals(user, config.user)
&& StringUtils.equals(password, config.password) && (reconnect == config.reconnect) && Objects.equals(password, config.password) && (reconnect == config.reconnect)
&& (heartbeat == config.heartbeat) && (delay == config.delay); && (heartbeat == config.heartbeat) && (delay == config.delay);
} }
} }

View File

@ -25,7 +25,6 @@ import java.util.regex.MatchResult;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.config.IPBridgeConfig;
import org.openhab.binding.lutron.internal.discovery.LutronDeviceDiscoveryService; import org.openhab.binding.lutron.internal.discovery.LutronDeviceDiscoveryService;
import org.openhab.binding.lutron.internal.net.TelnetSession; import org.openhab.binding.lutron.internal.net.TelnetSession;
@ -156,7 +155,8 @@ public class IPBridgeHandler extends LutronBridgeHandler {
return false; 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"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "bridge address not specified");
return false; return false;

View File

@ -21,7 +21,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils; import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.Device; import org.openhab.binding.max.internal.device.Device;

View File

@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils; import org.openhab.binding.max.internal.Utils;

View File

@ -25,7 +25,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.max.internal.Utils; import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.DeviceType; import org.openhab.binding.max.internal.device.DeviceType;
@ -278,7 +278,7 @@ public final class CMessage extends Message {
logger.debug("RoomID: {}", roomId); logger.debug("RoomID: {}", roomId);
for (String key : properties.keySet()) { for (String key : properties.keySet()) {
if (!key.startsWith("Unknown")) { if (!key.startsWith("Unknown")) {
String propertyName = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(key), ' '); String propertyName = String.join(" ", StringUtils.splitByCharacterTypeCamelCase(key));
logger.debug("{}: {}", propertyName, properties.get(key)); logger.debug("{}: {}", propertyName, properties.get(key));
} else { } else {
logger.debug("{}: {}", key, properties.get(key)); logger.debug("{}: {}", key, properties.get(key));

View File

@ -12,8 +12,6 @@
*/ */
package org.openhab.binding.meteoblue.internal; package org.openhab.binding.meteoblue.internal;
import org.apache.commons.lang.StringUtils;
/** /**
* Model for the meteoblue binding configuration. * Model for the meteoblue binding configuration.
* *
@ -64,15 +62,15 @@ public class MeteoBlueConfiguration {
String a2 = split.length > 1 ? split[1] : null; String a2 = split.length > 1 ? split[1] : null;
String a3 = split.length > 2 ? split[2] : null; String a3 = split.length > 2 ? split[2] : null;
if (!StringUtils.isBlank(a1)) { if (a1 != null && !a1.isBlank()) {
latitude = tryGetDouble(a1); latitude = tryGetDouble(a1);
} }
if (!StringUtils.isBlank(a2)) { if (a2 != null && !a2.isBlank()) {
longitude = tryGetDouble(a2); longitude = tryGetDouble(a2);
} }
if (!StringUtils.isBlank(a3)) { if (a3 != null && !a3.isBlank()) {
altitude = tryGetDouble(a3); altitude = tryGetDouble(a3);
} }
} }

View File

@ -17,7 +17,6 @@ import static org.openhab.binding.meteoblue.internal.MeteoBlueBindingConstants.T
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.meteoblue.internal.MeteoBlueBridgeConfig; import org.openhab.binding.meteoblue.internal.MeteoBlueBridgeConfig;
import org.openhab.core.io.net.http.HttpUtil; import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -55,7 +54,7 @@ public class MeteoBlueBridgeHandler extends BaseBridgeHandler {
MeteoBlueBridgeConfig config = getConfigAs(MeteoBlueBridgeConfig.class); MeteoBlueBridgeConfig config = getConfigAs(MeteoBlueBridgeConfig.class);
String apiKeyTemp = config.getApiKey(); String apiKeyTemp = config.getApiKey();
if (StringUtils.isBlank(apiKeyTemp)) { if (apiKeyTemp == null || apiKeyTemp.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Cannot initialize meteoblue bridge. No apiKey provided."); "Cannot initialize meteoblue bridge. No apiKey provided.");
return; return;

View File

@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.apache.commons.lang.StringUtils;
import org.openhab.binding.meteoblue.internal.Forecast; import org.openhab.binding.meteoblue.internal.Forecast;
import org.openhab.binding.meteoblue.internal.MeteoBlueConfiguration; import org.openhab.binding.meteoblue.internal.MeteoBlueConfiguration;
import org.openhab.binding.meteoblue.internal.json.JsonData; import org.openhab.binding.meteoblue.internal.json.JsonData;
@ -97,13 +96,13 @@ public class MeteoBlueHandler extends BaseThingHandler {
MeteoBlueConfiguration config = getConfigAs(MeteoBlueConfiguration.class); MeteoBlueConfiguration config = getConfigAs(MeteoBlueConfiguration.class);
if (StringUtils.isBlank(config.serviceType)) { if (config.serviceType == null || config.serviceType.isBlank()) {
config.serviceType = MeteoBlueConfiguration.SERVICETYPE_NONCOMM; config.serviceType = MeteoBlueConfiguration.SERVICETYPE_NONCOMM;
logger.debug("Using default service type ({}).", config.serviceType); logger.debug("Using default service type ({}).", config.serviceType);
return; return;
} }
if (StringUtils.isBlank(config.location)) { if (config.location == null || config.location.isBlank()) {
flagBadConfig("The location was not configured."); flagBadConfig("The location was not configured.");
return; return;
} }
@ -315,7 +314,7 @@ public class MeteoBlueHandler extends BaseThingHandler {
if (config.altitude != null) { if (config.altitude != null) {
builder.append("&asl=" + config.altitude); builder.append("&asl=" + config.altitude);
} }
if (StringUtils.isNotBlank(config.timeZone)) { if (config.timeZone != null && !config.timeZone.isBlank()) {
builder.append("&tz=" + config.timeZone); builder.append("&tz=" + config.timeZone);
} }
url = url.replace("#FORMAT_PARAMS#", builder.toString()); url = url.replace("#FORMAT_PARAMS#", builder.toString());

View File

@ -20,7 +20,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.ApplianceStatusListener;
import org.openhab.binding.miele.internal.handler.MieleApplianceHandler; import org.openhab.binding.miele.internal.handler.MieleApplianceHandler;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler; import org.openhab.binding.miele.internal.handler.MieleBridgeHandler;
@ -46,6 +45,9 @@ import com.google.gson.JsonElement;
*/ */
public class MieleApplianceDiscoveryService extends AbstractDiscoveryService implements ApplianceStatusListener { 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 final Logger logger = LoggerFactory.getLogger(MieleApplianceDiscoveryService.class);
private static final int SEARCH_TIME = 60; private static final int SEARCH_TIME = 60;
@ -103,10 +105,9 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
properties.put(APPLIANCE_ID, appliance.getApplianceId()); properties.put(APPLIANCE_ID, appliance.getApplianceId());
for (JsonElement dc : appliance.DeviceClasses) { for (JsonElement dc : appliance.DeviceClasses) {
if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele") String dcStr = dc.getAsString();
&& !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) { if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
properties.put(DEVICE_CLASS, StringUtils.right(dc.getAsString(), dc.getAsString().length() properties.put(DEVICE_CLASS, dcStr.substring(MIELE_CLASS.length()));
- new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()));
break; break;
} }
} }
@ -145,17 +146,16 @@ public class MieleApplianceDiscoveryService extends AbstractDiscoveryService imp
String modelID = null; String modelID = null;
for (JsonElement dc : appliance.DeviceClasses) { for (JsonElement dc : appliance.DeviceClasses) {
if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele") String dcStr = dc.getAsString();
&& !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) { if (dcStr.contains(MIELE_CLASS) && !dcStr.equals(MIELE_APPLIANCE_CLASS)) {
modelID = StringUtils.right(dc.getAsString(), dc.getAsString().length() modelID = dcStr.substring(MIELE_CLASS.length());
- new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
break; break;
} }
} }
if (modelID != null) { if (modelID != null) {
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, 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)) { if (getSupportedThingTypes().contains(thingTypeUID)) {
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getId()); ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, appliance.getId());

View File

@ -20,7 +20,7 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; 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.DeviceClassObject;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData; import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation; import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation;

View File

@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream; 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.common.NamedThreadFactory;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.ChannelUID;

View File

@ -18,7 +18,7 @@ import java.util.Date;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TimeZone; 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.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;

View File

@ -21,7 +21,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.values.TextValue; import org.openhab.binding.mqtt.generic.values.TextValue;
@ -78,7 +77,7 @@ public class ChannelState implements MqttMessageSubscriber {
this.channelStateUpdateListener = channelStateUpdateListener; this.channelStateUpdateListener = channelStateUpdateListener;
this.channelUID = channelUID; this.channelUID = channelUID;
this.cachedValue = cachedValue; this.cachedValue = cachedValue;
this.readOnly = StringUtils.isBlank(config.commandTopic); this.readOnly = config.commandTopic.isBlank();
} }
public boolean isReadOnly() { public boolean isReadOnly() {
@ -242,7 +241,7 @@ public class ChannelState implements MqttMessageSubscriber {
*/ */
public CompletableFuture<@Nullable Void> stop() { public CompletableFuture<@Nullable Void> stop() {
final MqttBrokerConnection connection = this.connection; 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); return connection.unsubscribe(config.stateTopic, this).thenRun(this::internalStop);
} else { } else {
internalStop(); internalStop();
@ -297,7 +296,7 @@ public class ChannelState implements MqttMessageSubscriber {
this.connection = connection; this.connection = connection;
if (StringUtils.isBlank(config.stateTopic)) { if (config.stateTopic.isBlank()) {
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }

View File

@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; 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.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.AbstractMQTTThingHandler; import org.openhab.binding.mqtt.generic.AbstractMQTTThingHandler;
@ -164,9 +164,8 @@ public class GenericMQTTThingHandler extends AbstractMQTTThingHandler implements
Value value = ValueFactory.createValueState(channelConfig, channelTypeUID.getId()); Value value = ValueFactory.createValueState(channelConfig, channelTypeUID.getId());
ChannelState channelState = createChannelState(channelConfig, channel.getUID(), value); ChannelState channelState = createChannelState(channelConfig, channel.getUID(), value);
channelStateByChannelUID.put(channel.getUID(), channelState); channelStateByChannelUID.put(channel.getUID(), channelState);
StateDescription description = value StateDescription description = value.createStateDescription(channelConfig.commandTopic.isBlank())
.createStateDescription(StringUtils.isBlank(channelConfig.commandTopic)).build() .build().toStateDescription();
.toStateDescription();
if (description != null) { if (description != null) {
stateDescProvider.setDescription(channel.getUID(), description); stateDescProvider.setDescription(channel.getUID(), description);
} }

View File

@ -12,12 +12,13 @@
*/ */
package org.openhab.binding.mqtt.generic.values; package org.openhab.binding.mqtt.generic.values;
import static java.util.function.Predicate.not;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.CoreItemFactory; import org.openhab.core.library.CoreItemFactory;
@ -45,7 +46,7 @@ public class TextValue extends Value {
*/ */
public TextValue(String[] states) { public TextValue(String[] states) {
super(CoreItemFactory.STRING, Collections.singletonList(StringType.class)); 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()) { if (!s.isEmpty()) {
this.states = s; this.states = s;
} else { } else {

View File

@ -12,7 +12,6 @@
*/ */
package org.openhab.binding.mqtt.generic.values; package org.openhab.binding.mqtt.generic.values;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.mqtt.generic.ChannelConfig; import org.openhab.binding.mqtt.generic.ChannelConfig;
import org.openhab.binding.mqtt.generic.internal.MqttBindingConstants; import org.openhab.binding.mqtt.generic.internal.MqttBindingConstants;
@ -35,7 +34,7 @@ public class ValueFactory {
Value value; Value value;
switch (channelTypeID) { switch (channelTypeID) {
case MqttBindingConstants.STRING: case MqttBindingConstants.STRING:
value = StringUtils.isBlank(config.allowedStates) ? new TextValue() value = config.allowedStates.isBlank() ? new TextValue()
: new TextValue(config.allowedStates.split(",")); : new TextValue(config.allowedStates.split(","));
break; break;
case MqttBindingConstants.DATETIME: case MqttBindingConstants.DATETIME:

View File

@ -16,7 +16,6 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.MqttChannelTypeProvider; import org.openhab.binding.mqtt.generic.MqttChannelTypeProvider;
@ -54,8 +53,8 @@ public class MqttThingHandlerFactory extends BaseThingHandlerFactory implements
} }
private boolean isHomeassistantDynamicType(ThingTypeUID thingTypeUID) { private boolean isHomeassistantDynamicType(ThingTypeUID thingTypeUID) {
return StringUtils.equals(MqttBindingConstants.BINDING_ID, thingTypeUID.getBindingId()) return MqttBindingConstants.BINDING_ID.equals(thingTypeUID.getBindingId())
&& StringUtils.startsWith(thingTypeUID.getId(), MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId()); && thingTypeUID.getId().startsWith(MqttBindingConstants.HOMEASSISTANT_MQTT_THING.getId());
} }
@Activate @Activate

View File

@ -16,7 +16,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.Thing; import org.openhab.core.thing.Thing;
@ -103,9 +102,9 @@ public abstract class BaseChannelConfiguration {
protected @Nullable String name; protected @Nullable String name;
protected @Nullable String sw_version; protected @Nullable String sw_version;
@Nullable public @Nullable String getId() {
public String getId() { List<String> identifiers = this.identifiers;
return StringUtils.join(identifiers, "_"); return identifiers == null ? null : String.join("_", identifiers);
} }
} }

View File

@ -16,7 +16,6 @@ import java.net.URI;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.ChannelConfigBuilder; import org.openhab.binding.mqtt.generic.ChannelConfigBuilder;
@ -149,9 +148,9 @@ public class CChannel {
public Builder stateTopic(@Nullable String state_topic, @Nullable String... templates) { public Builder stateTopic(@Nullable String state_topic, @Nullable String... templates) {
this.state_topic = state_topic; this.state_topic = state_topic;
if (StringUtils.isNotBlank(state_topic)) { if (state_topic != null && !state_topic.isBlank()) {
for (String template : templates) { for (String template : templates) {
if (StringUtils.isNotBlank(template)) { if (template != null && !template.isBlank()) {
this.templateIn = template; this.templateIn = template;
break; break;
} }
@ -204,7 +203,8 @@ public class CChannel {
.withCommandTopic(command_topic).makeTrigger(trigger).build(), .withCommandTopic(command_topic).makeTrigger(trigger).build(),
channelUID, valueState, channelStateUpdateListener); 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) type = ChannelTypeBuilder.trigger(channelTypeUID, label)
.withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL)).build(); .withConfigDescriptionURI(URI.create(MqttBindingConstants.CONFIG_HA_CHANNEL)).build();
} else { } else {

View File

@ -15,7 +15,6 @@ package org.openhab.binding.mqtt.homeassistant.internal;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
@ -119,7 +118,7 @@ public class ChannelConfigurationTypeAdapterFactory implements TypeAdapterFactor
final String oldValue = (String) field.get(config); final String oldValue = (String) field.get(config);
String newValue = oldValue; String newValue = oldValue;
if (StringUtils.isNotBlank(oldValue)) { if (oldValue != null && !oldValue.isBlank()) {
if (oldValue.charAt(0) == '~') { if (oldValue.charAt(0) == '~') {
newValue = tilde + oldValue.substring(1); newValue = tilde + oldValue.substring(1);
} else if (oldValue.charAt(oldValue.length() - 1) == '~') { } else if (oldValue.charAt(oldValue.length() - 1) == '~') {

View File

@ -12,7 +12,6 @@
*/ */
package org.openhab.binding.mqtt.homeassistant.internal; package org.openhab.binding.mqtt.homeassistant.internal;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.generic.values.OnOffValue; import org.openhab.binding.mqtt.generic.values.OnOffValue;
@ -46,7 +45,7 @@ public class ComponentLock extends AbstractComponent<ComponentLock.ChannelConfig
super(componentConfiguration, ChannelConfiguration.class); super(componentConfiguration, ChannelConfiguration.class);
// We do not support all HomeAssistant quirks // 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"); 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