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

@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -277,8 +278,8 @@ public class GreeAirDevice {
// If commanding Fahrenheit set halfStep to 1 or 0 to tell the A/C which F integer
// temperature to use as celsius alone is ambigious
double newVal = temp.doubleValue();
int CorF = temp.getUnit() == SIUnits.CELSIUS ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius,
// 1=Fahrenheit
int CorF = SIUnits.CELSIUS.equals(temp.getUnit()) ? TEMP_UNIT_CELSIUS : TEMP_UNIT_FAHRENHEIT; // 0=Celsius,
// 1=Fahrenheit
if (((CorF == TEMP_UNIT_CELSIUS) && (newVal < TEMP_MIN_C || newVal > TEMP_MAX_C))
|| ((CorF == TEMP_UNIT_FAHRENHEIT) && (newVal < TEMP_MIN_F || newVal > TEMP_MAX_F))) {
throw new IllegalArgumentException("Temp Value out of Range");
@@ -404,7 +405,7 @@ public class GreeAirDevice {
}
// Finally Compare the values
return currvalList.get(currvalueArrayposition) != prevvalList.get(prevvalueArrayposition);
return !Objects.equals(currvalList.get(currvalueArrayposition), prevvalList.get(prevvalueArrayposition));
}
protected void executeCommand(DatagramSocket clientSocket, Map<String, Integer> parameters) throws GreeException {