Skip to content

Commit

Permalink
[powermax] Removed dependency on 'org.apache.commons.lang' (openhab#7726
Browse files Browse the repository at this point in the history
)

* [powermax] Removed dependency on 'org.apache.commons.lang'

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and andrewfg committed Aug 31, 2020
1 parent 638f8b6 commit 017414f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang.StringUtils;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.thing.Bridge;
Expand Down Expand Up @@ -144,7 +143,8 @@ public void initialize() {

private String initializeBridgeSerial(PowermaxSerialConfiguration config) {
String errorMsg = null;
if (StringUtils.isNotBlank(config.serialPort) && !config.serialPort.startsWith("rfc2217")) {
if (config.serialPort != null && !config.serialPort.trim().isEmpty()
&& !config.serialPort.trim().startsWith("rfc2217")) {
motionOffDelay = getMotionOffDelaySetting(config.motionOffDelay, DEFAULT_MOTION_OFF_DELAY);
boolean allowArming = getBooleanSetting(config.allowArming, false);
boolean allowDisarming = getBooleanSetting(config.allowDisarming, false);
Expand All @@ -164,7 +164,7 @@ private String initializeBridgeSerial(PowermaxSerialConfiguration config) {
commManager = new PowermaxCommManager(config.serialPort, panelType, forceStandardMode, autoSyncTime,
serialPortManager);
} else {
if (StringUtils.isNotBlank(config.serialPort) && config.serialPort.startsWith("rfc2217")) {
if (config.serialPort != null && config.serialPort.trim().startsWith("rfc2217")) {
errorMsg = "Please use the IP Connection thing type for a serial over IP connection.";
} else {
errorMsg = "serialPort setting must be defined in thing configuration";
Expand All @@ -175,7 +175,7 @@ private String initializeBridgeSerial(PowermaxSerialConfiguration config) {

private String initializeBridgeIp(PowermaxIpConfiguration config) {
String errorMsg = null;
if (StringUtils.isNotBlank(config.ip) && config.tcpPort != null) {
if (config.ip != null && !config.ip.trim().isEmpty() && config.tcpPort != null) {
motionOffDelay = getMotionOffDelaySetting(config.motionOffDelay, DEFAULT_MOTION_OFF_DELAY);
boolean allowArming = getBooleanSetting(config.allowArming, false);
boolean allowDisarming = getBooleanSetting(config.allowDisarming, false);
Expand Down Expand Up @@ -577,42 +577,25 @@ private synchronized void updateChannelsFromAlarmState(String channel, PowermaxS
*/
private void updatePropertiesFromPanelSettings() {
String value;
boolean update = false;

Map<String, String> properties = editProperties();
PowermaxPanelSettings panelSettings = getPanelSettings();

value = (panelSettings.getPanelType() != null) ? panelSettings.getPanelType().getLabel() : null;
if (StringUtils.isNotEmpty(value) && ((properties.get(Thing.PROPERTY_MODEL_ID) == null)
|| !properties.get(Thing.PROPERTY_MODEL_ID).equals(value))) {
update = true;
if (value != null && !value.isEmpty()) {
properties.put(Thing.PROPERTY_MODEL_ID, value);
}

value = panelSettings.getPanelSerial();
if (StringUtils.isNotEmpty(value) && ((properties.get(Thing.PROPERTY_SERIAL_NUMBER) == null)
|| !properties.get(Thing.PROPERTY_SERIAL_NUMBER).equals(value))) {
update = true;
if (value != null && !value.isEmpty()) {
properties.put(Thing.PROPERTY_SERIAL_NUMBER, value);
}

value = panelSettings.getPanelEprom();
if (StringUtils.isNotEmpty(value) && ((properties.get(Thing.PROPERTY_HARDWARE_VERSION) == null)
|| !properties.get(Thing.PROPERTY_HARDWARE_VERSION).equals(value))) {
update = true;
if (value != null && !value.isEmpty()) {
properties.put(Thing.PROPERTY_HARDWARE_VERSION, value);
}

value = panelSettings.getPanelSoftware();
if (StringUtils.isNotEmpty(value) && ((properties.get(Thing.PROPERTY_FIRMWARE_VERSION) == null)
|| !properties.get(Thing.PROPERTY_FIRMWARE_VERSION).equals(value))) {
update = true;
if (value != null && !value.isEmpty()) {
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, value);
}

if (update) {
updateProperties(properties);
}
updateProperties(properties);
}

public boolean registerPanelSettingsListener(PowermaxPanelSettingsListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang.StringUtils;
import org.eclipse.smarthome.core.common.ThreadPoolManager;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.util.HexUtils;
Expand Down Expand Up @@ -107,7 +106,7 @@ public PowermaxCommManager(String sPort, PowermaxPanelType panelType, boolean fo
this.forceStandardMode = forceStandardMode;
this.autoSyncTime = autoSyncTime;
this.panelSettings = new PowermaxPanelSettings(panelType);
String serialPort = StringUtils.isNotBlank(sPort) ? sPort : null;
String serialPort = (sPort != null && !sPort.trim().isEmpty()) ? sPort.trim() : null;
if (serialPort != null) {
connector = new PowermaxSerialConnector(serialPortManager, serialPort, DEFAULT_BAUD_RATE);
} else {
Expand All @@ -131,7 +130,7 @@ public PowermaxCommManager(String ip, int port, PowermaxPanelType panelType, boo
this.forceStandardMode = forceStandardMode;
this.autoSyncTime = autoSyncTime;
this.panelSettings = new PowermaxPanelSettings(panelType);
String ipAddress = StringUtils.isNotBlank(ip) ? ip : null;
String ipAddress = (ip != null && !ip.trim().isEmpty()) ? ip.trim() : null;
int tcpPort = (port > 0) ? port : DEFAULT_TCP_PORT;
if (ipAddress != null) {
connector = new PowermaxTcpConnector(ipAddress, tcpPort, TCP_CONNECTION_TIMEOUT);
Expand Down

0 comments on commit 017414f

Please sign in to comment.