Re-introduce removed DecimalType ctors to maintain compatibility (#2803)

Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
J-N-K 2022-02-26 13:30:56 +01:00 committed by GitHub
parent c267e8f876
commit f79d85da87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,6 +49,20 @@ public class DecimalType extends Number implements PrimitiveType, State, Command
this(bigDecimal(value));
}
// TODO: Remove these constructors. They are still in place to maintain binary compatibility and will be removed
// once another change breaking binary compatibility is merged
public DecimalType(BigDecimal value) {
this.value = value;
}
public DecimalType(long value) {
this(bigDecimal(value));
}
public DecimalType(double value) {
this(bigDecimal(value));
}
private static BigDecimal bigDecimal(Number value) {
if (value instanceof QuantityType) {
return ((QuantityType<?>) value).toBigDecimal();
@ -61,10 +75,6 @@ public class DecimalType extends Number implements PrimitiveType, State, Command
return new BigDecimal(value.toString());
}
public DecimalType(BigDecimal value) {
this.value = value;
}
/**
* Creates a new {@link DecimalType} with the given value.
* The English locale is used to determine (decimal/grouping) separator characters.