[insteon] Fix SAT warnings (#10688)

Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
This commit is contained in:
robnielsen 2021-05-14 03:22:55 -05:00 committed by GitHub
parent 801100cee1
commit 9ba28a50cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 44 deletions

View File

@ -218,7 +218,7 @@ public class InsteonCommandExtension extends AbstractConsoleCommandExtension imp
}
private void startMonitoring(Console console, String addr) {
if (addr.equalsIgnoreCase("all")) {
if ("all".equalsIgnoreCase(addr)) {
if (!monitorAllDevices) {
monitorAllDevices = true;
monitoredAddresses.clear();
@ -255,7 +255,7 @@ public class InsteonCommandExtension extends AbstractConsoleCommandExtension imp
return;
}
if (addr.equalsIgnoreCase("all")) {
if ("all".equalsIgnoreCase(addr)) {
if (monitorAllDevices) {
monitorAllDevices = false;
console.println("Stopped monitoring all devices.");

View File

@ -18,7 +18,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -119,7 +118,7 @@ public class DeviceTypeLoader {
*/
private void processDevice(Element e) throws SAXException {
String productKey = e.getAttribute("productKey");
if (productKey.equals("")) {
if ("".equals(productKey)) {
throw new SAXException("device in device_types file has no product key!");
}
if (deviceTypes.containsKey(productKey)) {
@ -135,13 +134,14 @@ public class DeviceTypeLoader {
continue;
}
Element subElement = (Element) node;
if (subElement.getNodeName().equals("model")) {
String nodeName = subElement.getNodeName();
if ("model".equals(nodeName)) {
devType.setModel(subElement.getTextContent());
} else if (subElement.getNodeName().equals("description")) {
} else if ("description".equals(nodeName)) {
devType.setDescription(subElement.getTextContent());
} else if (subElement.getNodeName().equals("feature")) {
} else if ("feature".equals(nodeName)) {
processFeature(devType, subElement);
} else if (subElement.getNodeName().equals("feature_group")) {
} else if ("feature_group".equals(nodeName)) {
processFeatureGroup(devType, subElement);
}
deviceTypes.put(productKey, devType);
@ -150,7 +150,7 @@ public class DeviceTypeLoader {
private String processFeature(DeviceType devType, Element e) throws SAXException {
String name = e.getAttribute("name");
if (name.equals("")) {
if ("".equals(name)) {
throw new SAXException("feature " + e.getNodeName() + " has feature without name!");
}
if (!name.equals(name.toLowerCase())) {
@ -164,11 +164,11 @@ public class DeviceTypeLoader {
private String processFeatureGroup(DeviceType devType, Element e) throws SAXException {
String name = e.getAttribute("name");
if (name.equals("")) {
if ("".equals(name)) {
throw new SAXException("feature group " + e.getNodeName() + " has no name attr!");
}
String type = e.getAttribute("type");
if (type.equals("")) {
if ("".equals(type)) {
throw new SAXException("feature group " + e.getNodeName() + " has no type attr!");
}
FeatureGroup fg = new FeatureGroup(name, type);
@ -179,9 +179,10 @@ public class DeviceTypeLoader {
continue;
}
Element subElement = (Element) node;
if (subElement.getNodeName().equals("feature")) {
String nodeName = subElement.getNodeName();
if ("feature".equals(nodeName)) {
fg.addFeature(processFeature(devType, subElement));
} else if (subElement.getNodeName().equals("feature_group")) {
} else if ("feature_group".equals(nodeName)) {
fg.addFeature(processFeatureGroup(devType, subElement));
}
}
@ -191,16 +192,6 @@ public class DeviceTypeLoader {
return (name);
}
/**
* Helper function for debugging
*/
private void logDeviceTypes() {
for (Entry<String, DeviceType> dt : getDeviceTypes().entrySet()) {
String msg = String.format("%-10s->", dt.getKey()) + dt.getValue();
logger.debug("{}", msg);
}
}
/**
* Singleton instance function, creates DeviceTypeLoader
*

View File

@ -70,7 +70,7 @@ public class FeatureTemplateLoader {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element e = (Element) node;
if (e.getTagName().equals("feature")) {
if ("feature".equals(e.getTagName())) {
features.add(parseFeature(e));
}
}
@ -126,7 +126,7 @@ public class FeatureTemplateLoader {
private static void parseMessageHandler(Element e, FeatureTemplate f) throws DOMException, ParsingException {
HandlerEntry he = makeHandlerEntry(e);
if (e.getAttribute("default").equals("true")) {
if ("true".equals(e.getAttribute("default"))) {
f.setDefaultMessageHandler(he);
} else {
String attr = e.getAttribute("cmd");
@ -137,7 +137,7 @@ public class FeatureTemplateLoader {
private static void parseCommandHandler(Element e, FeatureTemplate f) throws ParsingException {
HandlerEntry he = makeHandlerEntry(e);
if (e.getAttribute("default").equals("true")) {
if ("true".equals(e.getAttribute("default"))) {
f.setDefaultCommandHandler(he);
} else {
Class<? extends Command> command = parseCommandClass(e.getAttribute("command"));
@ -156,13 +156,13 @@ public class FeatureTemplateLoader {
}
private static Class<? extends Command> parseCommandClass(String c) throws ParsingException {
if (c.equals("OnOffType")) {
if ("OnOffType".equals(c)) {
return OnOffType.class;
} else if (c.equals("PercentType")) {
} else if ("PercentType".equals(c)) {
return PercentType.class;
} else if (c.equals("DecimalType")) {
} else if ("DecimalType".equals(c)) {
return DecimalType.class;
} else if (c.equals("IncreaseDecreaseType")) {
} else if ("IncreaseDecreaseType".equals(c)) {
return IncreaseDecreaseType.class;
} else {
throw new ParsingException("Unknown Command Type");

View File

@ -1078,9 +1078,9 @@ public abstract class MessageHandler {
@Nullable
State state;
String scale = getStringParameter("scale", null);
if (scale != null && scale.equals("celsius")) {
if ("celsius".equals(scale)) {
state = new QuantityType<>(dvalue, SIUnits.CELSIUS);
} else if (scale != null && scale.equals("fahrenheit")) {
} else if ("fahrenheit".equals(scale)) {
state = new QuantityType<>(dvalue, ImperialUnits.FAHRENHEIT);
} else {
state = new DecimalType(dvalue);
@ -1102,7 +1102,7 @@ public abstract class MessageHandler {
return 0;
}
int value = 0;
if (lowByte.equals("group")) {
if ("group".equals(lowByte)) {
value = group;
} else {
value = msg.getByte(lowByte) & 0xFF;

View File

@ -58,7 +58,7 @@ public class SerialIOStream extends IOStream {
} else {
String key = paramParts[0];
String value = paramParts[1];
if (key.equals("baudRate")) {
if ("baudRate".equals(key)) {
try {
baudRate = Integer.parseInt(value);
} catch (NumberFormatException e) {

View File

@ -52,7 +52,6 @@ public class InsteonNetworkHandler extends BaseBridgeHandler {
private final Logger logger = LoggerFactory.getLogger(InsteonNetworkHandler.class);
private @Nullable InsteonNetworkConfiguration config;
private @Nullable InsteonBinding insteonBinding;
private @Nullable InsteonDeviceDiscoveryService insteonDeviceDiscoveryService;
private @Nullable ScheduledFuture<?> pollingJob = null;
@ -77,17 +76,9 @@ public class InsteonNetworkHandler extends BaseBridgeHandler {
@Override
public void initialize() {
logger.debug("Starting Insteon bridge");
config = getConfigAs(InsteonNetworkConfiguration.class);
InsteonNetworkConfiguration config = getConfigAs(InsteonNetworkConfiguration.class);
scheduler.execute(() -> {
InsteonNetworkConfiguration config = this.config;
if (config == null) {
String msg = "Initialization failed, configuration is null.";
logger.warn(msg);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, msg);
return;
}
SerialPortManager serialPortManager = this.serialPortManager;
if (serialPortManager == null) {
String msg = "Initialization failed, serial port manager is null.";