Skip to content

Commit 9bc465c

Browse files
committed
add missing function from Number and add compatibility functions for old project
1 parent 3fc8025 commit 9bc465c

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

src/main/java/it/aboutbits/springboot/toolbox/type/ScaledBigDecimal.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public ScaledBigDecimal roundToScale(int scale) {
207207
}
208208

209209
@Override
210+
@NonNull
210211
public String toString() {
211212
return this.value().toString();
212213
}
@@ -233,4 +234,48 @@ public int hashCode() {
233234
public int compareTo(@NonNull ScaledBigDecimal o) {
234235
return this.value().compareTo(o.value());
235236
}
237+
238+
/**
239+
* @deprecated Allow drop-in-replacement of ScaledBigDecimal in the original project.
240+
* This is temporary. We need to avoid changing any rounding logic at the moment.
241+
*/
242+
@Deprecated
243+
@NonNull
244+
public BigDecimal toCurrency() {
245+
return this.value().setScale(2, RoundingMode.HALF_UP);
246+
}
247+
248+
/**
249+
* @deprecated Allow drop-in-replacement of ScaledBigDecimal in the original project.
250+
* This is temporary. We need to avoid changing any rounding logic at the moment.
251+
*/
252+
@Deprecated
253+
@NonNull
254+
public ScaledBigDecimal roundToCurrency() {
255+
return new ScaledBigDecimal(this.value().setScale(2, RoundingMode.HALF_UP));
256+
}
257+
258+
public int intValue() {
259+
return this.value().intValue();
260+
}
261+
262+
public long longValue() {
263+
return this.value().longValue();
264+
}
265+
266+
public float floatValue() {
267+
return this.value().floatValue();
268+
}
269+
270+
public double doubleValue() {
271+
return this.value().doubleValue();
272+
}
273+
274+
public byte byteValue() {
275+
return (byte) intValue();
276+
}
277+
278+
public short shortValue() {
279+
return (short) intValue();
280+
}
236281
}

0 commit comments

Comments
 (0)