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:
@@ -42,7 +42,7 @@ public class OnOffTypeConverter extends AbstractTypeConverter<OnOffType> {
|
||||
|
||||
@Override
|
||||
protected OnOffType fromBinding(HmDatapoint dp) throws ConverterException {
|
||||
return (((Boolean) dp.getValue()) == Boolean.FALSE) != isInvert(dp) ? OnOffType.OFF : OnOffType.ON;
|
||||
return Boolean.FALSE.equals(dp.getValue()) != isInvert(dp) ? OnOffType.OFF : OnOffType.ON;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,8 +42,7 @@ public class OpenClosedTypeConverter extends AbstractTypeConverter<OpenClosedTyp
|
||||
|
||||
@Override
|
||||
protected OpenClosedType fromBinding(HmDatapoint dp) throws ConverterException {
|
||||
return (((Boolean) dp.getValue()) == Boolean.FALSE) != isInvert(dp) ? OpenClosedType.CLOSED
|
||||
: OpenClosedType.OPEN;
|
||||
return Boolean.FALSE.equals(dp.getValue()) != isInvert(dp) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,9 +71,9 @@ public class PercentTypeConverter extends AbstractTypeConverter<PercentType> {
|
||||
Double number = (type.doubleValue() / 100) * maxValue;
|
||||
|
||||
if (MetadataUtils.isRollerShutter(dp)) {
|
||||
if (type == PercentType.HUNDRED) { // means DOWN
|
||||
if (PercentType.HUNDRED.equals(type)) { // means DOWN
|
||||
return dp.getMinValue().doubleValue();
|
||||
} else if (type == PercentType.ZERO) { // means UP
|
||||
} else if (PercentType.ZERO.equals(type)) { // means UP
|
||||
return maxValue;
|
||||
}
|
||||
return maxValue - number;
|
||||
|
||||
@@ -41,14 +41,14 @@ public class MiscUtils {
|
||||
* Returns true, if the value is not null and true.
|
||||
*/
|
||||
public static boolean isTrueValue(Object value) {
|
||||
return value != null && value == Boolean.TRUE;
|
||||
return Boolean.TRUE.equals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the value is not null and false.
|
||||
*/
|
||||
public static boolean isFalseValue(Object value) {
|
||||
return value != null && value == Boolean.FALSE;
|
||||
return Boolean.FALSE.equals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,7 +175,7 @@ public class MetadataUtils {
|
||||
if ("%%".equals(unit)) {
|
||||
return "%d %%";
|
||||
}
|
||||
if (unit != null && unit != "") {
|
||||
if (unit != null && !unit.isEmpty()) {
|
||||
String pattern = getPattern(dp);
|
||||
if (pattern != null) {
|
||||
return String.format("%s %s", pattern, "%unit%");
|
||||
|
||||
Reference in New Issue
Block a user