Upgrade Units of Measurement dependencies (#10583)
* Fix code/tests for upgrade * Resolve runbundles * Update Checkstyle ruleset for changed packages Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -231,10 +231,9 @@ public class ModbusGainOffsetProfile<Q extends Quantity<Q>> implements StateProf
|
||||
* When the conversion is towards the handler (towardsItem=false), unit will be ONE
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // Safe cast since QU = Dimensionless * QU
|
||||
private <QU extends Quantity<QU>> QuantityType<QU> applyGainTowardsItem(QuantityType<Dimensionless> qtState,
|
||||
QuantityType<QU> gainDelta) {
|
||||
return (QuantityType<QU>) qtState.multiply(gainDelta);
|
||||
return new QuantityType<>(qtState.toBigDecimal().multiply(gainDelta.toBigDecimal()), gainDelta.getUnit());
|
||||
}
|
||||
|
||||
private QuantityType<Dimensionless> applyGainTowardsHandler(QuantityType<?> qtState, QuantityType<?> gainDelta) {
|
||||
|
||||
@@ -172,10 +172,7 @@ public class ModbusGainOffsetProfileTest {
|
||||
// Workaround for errors like "java.lang.UnsupportedOperationException: °C is non-linear, cannot convert"
|
||||
if (expectedStateUpdateTowardsItem instanceof QuantityType<?>) {
|
||||
assertTrue(actualStateUpdateTowardsItem instanceof QuantityType<?>);
|
||||
assertEquals(((QuantityType<?>) expectedStateUpdateTowardsItem).getUnit(),
|
||||
((QuantityType<?>) actualStateUpdateTowardsItem).getUnit());
|
||||
assertEquals(((QuantityType<?>) expectedStateUpdateTowardsItem).toBigDecimal(),
|
||||
((QuantityType<?>) actualStateUpdateTowardsItem).toBigDecimal());
|
||||
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
|
||||
} else {
|
||||
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user