Fix cherry-picking issues

Signed-off-by: Kai Kreuzer <kai@openhab.org>
4.1.x
Kai Kreuzer 2024-01-06 11:33:26 +01:00
parent f028598596
commit 9c1cddce0d
1 changed files with 2 additions and 35 deletions

View File

@ -98,10 +98,12 @@ public final class CurrencyUnit extends AbstractUnit<Currency> {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public @Nullable String getSymbol() {
return symbol;
}
@ -151,41 +153,6 @@ public final class CurrencyUnit extends AbstractUnit<Currency> {
"Could not get factor for converting " + this.getName() + " to " + that.getName());
}
public final Unit<?> multiply(@NonNullByDefault({}) Unit<?> that) {
return that.equals(ONE) ? this : ProductUnit.ofProduct(this, that);
}
@Override
public final Unit<?> inverse() {
return ProductUnit.ofQuotient(ONE, this);
}
@Override
public final Unit<Currency> divide(@NonNullByDefault({}) Number divisor) {
if (Calculus.currentNumberSystem().isOne(divisor)) {
return this;
}
BigDecimal factor = BigDecimal.ONE.divide(new BigDecimal(divisor.toString()), MathContext.DECIMAL128);
return transform(MultiplyConverter.of(factor));
}
@Override
public final Unit<?> divide(@NonNullByDefault({}) Unit<?> that) {
return this.multiply(that.inverse());
}
@Override
public final Unit<?> root(int n) {
if (n > 0) {
return ProductUnit.ofRoot(this, n);
} else if (n == 0) {
throw new ArithmeticException("Root's order of zero");
} else {
// n < 0
return ONE.divide(this.root(-n));
}
}
@Override
public Unit<?> pow(int n) {
if (n > 0) {