Fix/suppress PMD CompareObjectsWithEquals findings (#11476)

Newer PMD versions discover more CompareObjectsWithEquals findings.

Related to https://github.com/openhab/static-code-analysis/pull/423

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-11-02 10:43:53 +01:00
committed by GitHub
parent b67b9fcb25
commit 589400e223
82 changed files with 175 additions and 141 deletions

View File

@@ -206,7 +206,9 @@ public class IAqualinkHandler extends BaseThingHandler {
Optional<Auxiliary> optional = Arrays.stream(auxs).filter(o -> o.getName().equals(channelName))
.findFirst();
if (optional.isPresent()) {
if (toState(channelName, "Switch", optional.get().getState()) != command) {
OnOffType onOffCommand = (OnOffType) command;
State currentState = toState(channelName, "Switch", optional.get().getState());
if (!currentState.equals(onOffCommand)) {
client.auxSetCommand(serialNumber, sessionId, channelName);
}
}
@@ -225,20 +227,23 @@ public class IAqualinkHandler extends BaseThingHandler {
}
}
} else if (command instanceof OnOffType) {
OnOffType onOffCommand = (OnOffType) command;
// these are toggle commands and require we have the current state to turn on/off
if (channelName.startsWith("onetouch_")) {
OneTouch[] ota = client.getOneTouch(serialNumber, sessionId);
Optional<OneTouch> optional = Arrays.stream(ota).filter(o -> o.getName().equals(channelName))
.findFirst();
if (optional.isPresent()) {
if (toState(channelName, "Switch", optional.get().getState()) != command) {
State currentState = toState(channelName, "Switch", optional.get().getState());
if (!currentState.equals(onOffCommand)) {
logger.debug("Sending command {} to {}", command, channelName);
client.oneTouchSetCommand(serialNumber, sessionId, channelName);
}
}
} else if (channelName.endsWith("heater") || channelName.endsWith("pump")) {
String value = client.getHome(serialNumber, sessionId).getSerializedMap().get(channelName);
if (toState(channelName, "Switch", value) != command) {
State currentState = toState(channelName, "Switch", value);
if (!currentState.equals(onOffCommand)) {
logger.debug("Sending command {} to {}", command, channelName);
client.homeScreenSetCommand(serialNumber, sessionId, channelName);
}