[knx] Code cleanup (#14719)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-03-29 09:22:23 +02:00 committed by GitHub
parent a96701f7a2
commit bc03e8c5cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -130,7 +130,7 @@ public class SerialTransportAdapter implements SerialCom {
}
}
// should not throw, create a dummy return value
byte buf[] = {};
byte[] buf = {};
return new ByteArrayInputStream(buf);
}

View File

@ -79,7 +79,7 @@ public class DPTUnits {
try {
Object o = field.get(null);
if (o instanceof DPT dpt) {
String unit = dpt.getUnit().replaceAll(" ", "");
String unit = dpt.getUnit().replace(" ", "");
// Calimero provides some units (like "ms⁻²") that can't be parsed by our library because of the
// negative exponent
// replace with /

View File

@ -90,17 +90,17 @@ public class ValueEncoder {
if (value instanceof HSBType type) {
return handleHSBType(dptId, type);
} else if (value instanceof OnOffType) {
return OnOffType.OFF.equals(value) ? dpt.getLowerValue() : dpt.getUpperValue();
return OnOffType.OFF == value ? dpt.getLowerValue() : dpt.getUpperValue();
} else if (value instanceof UpDownType) {
return UpDownType.UP.equals(value) ? dpt.getLowerValue() : dpt.getUpperValue();
return UpDownType.UP == value ? dpt.getLowerValue() : dpt.getUpperValue();
} else if (value instanceof IncreaseDecreaseType) {
DPT valueDPT = ((DPTXlator3BitControlled.DPT3BitControlled) dpt).getControlDPT();
return IncreaseDecreaseType.DECREASE.equals(value) ? valueDPT.getLowerValue() + " 5"
return IncreaseDecreaseType.DECREASE == value ? valueDPT.getLowerValue() + " 5"
: valueDPT.getUpperValue() + " 5";
} else if (value instanceof OpenClosedType) {
return OpenClosedType.CLOSED.equals(value) ? dpt.getLowerValue() : dpt.getUpperValue();
return OpenClosedType.CLOSED == value ? dpt.getLowerValue() : dpt.getUpperValue();
} else if (value instanceof StopMoveType) {
return StopMoveType.STOP.equals(value) ? dpt.getLowerValue() : dpt.getUpperValue();
return StopMoveType.STOP == value ? dpt.getLowerValue() : dpt.getUpperValue();
} else if (value instanceof PercentType type) {
int intValue = type.intValue();
return "251.600".equals(dptId) ? String.format("- - - %d %%", intValue) : String.valueOf(intValue);

View File

@ -24,6 +24,7 @@ import org.openhab.core.i18n.LocaleProvider;
*/
@NonNullByDefault
public class MockedLocaleProvider implements LocaleProvider {
@Override
public Locale getLocale() {
return Locale.ENGLISH;
}