[knx] Code cleanup (#14719)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
parent
a96701f7a2
commit
bc03e8c5cf
|
@ -130,7 +130,7 @@ public class SerialTransportAdapter implements SerialCom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// should not throw, create a dummy return value
|
// should not throw, create a dummy return value
|
||||||
byte buf[] = {};
|
byte[] buf = {};
|
||||||
return new ByteArrayInputStream(buf);
|
return new ByteArrayInputStream(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class DPTUnits {
|
||||||
try {
|
try {
|
||||||
Object o = field.get(null);
|
Object o = field.get(null);
|
||||||
if (o instanceof DPT dpt) {
|
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
|
// Calimero provides some units (like "ms⁻²") that can't be parsed by our library because of the
|
||||||
// negative exponent
|
// negative exponent
|
||||||
// replace with /
|
// replace with /
|
||||||
|
|
|
@ -90,17 +90,17 @@ public class ValueEncoder {
|
||||||
if (value instanceof HSBType type) {
|
if (value instanceof HSBType type) {
|
||||||
return handleHSBType(dptId, type);
|
return handleHSBType(dptId, type);
|
||||||
} else if (value instanceof OnOffType) {
|
} 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) {
|
} 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) {
|
} else if (value instanceof IncreaseDecreaseType) {
|
||||||
DPT valueDPT = ((DPTXlator3BitControlled.DPT3BitControlled) dpt).getControlDPT();
|
DPT valueDPT = ((DPTXlator3BitControlled.DPT3BitControlled) dpt).getControlDPT();
|
||||||
return IncreaseDecreaseType.DECREASE.equals(value) ? valueDPT.getLowerValue() + " 5"
|
return IncreaseDecreaseType.DECREASE == value ? valueDPT.getLowerValue() + " 5"
|
||||||
: valueDPT.getUpperValue() + " 5";
|
: valueDPT.getUpperValue() + " 5";
|
||||||
} else if (value instanceof OpenClosedType) {
|
} 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) {
|
} 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) {
|
} else if (value instanceof PercentType type) {
|
||||||
int intValue = type.intValue();
|
int intValue = type.intValue();
|
||||||
return "251.600".equals(dptId) ? String.format("- - - %d %%", intValue) : String.valueOf(intValue);
|
return "251.600".equals(dptId) ? String.format("- - - %d %%", intValue) : String.valueOf(intValue);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.openhab.core.i18n.LocaleProvider;
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MockedLocaleProvider implements LocaleProvider {
|
public class MockedLocaleProvider implements LocaleProvider {
|
||||||
|
@Override
|
||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
return Locale.ENGLISH;
|
return Locale.ENGLISH;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue