Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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