MCPcopy Create free account
hub / github.com/SeanDragon/protools / init

Method init

common/src/main/java/pro/tools/data/decimal/Decimal.java:67–87  ·  view source on GitHub ↗
(Object initValue)

Source from the content-addressed store, hash-verified

65 }
66
67 private void init(Object initValue) {
68 if (initValue instanceof Decimal) {
69 Decimal value = (Decimal) initValue;
70 bigDecimal = ToolClone.clone(value.getBigDecimal());
71 } else if (initValue instanceof BigDecimal) {
72 bigDecimal = ToolClone.clone((BigDecimal) initValue);
73 } else if (initValue instanceof BigInteger) {
74 BigInteger value = (BigInteger) initValue;
75 bigDecimal = new BigDecimal(ToolClone.clone(value), mathContext);
76 } else if (initValue instanceof Number) {
77 Number value = (Number) initValue;
78 bigDecimal = new BigDecimal(value.toString(), mathContext);
79 } else if (initValue instanceof String) {
80 String value = (String) initValue;
81 bigDecimal = new BigDecimal(value, mathContext);
82 } else if (initValue == null) {
83 bigDecimal = new BigDecimal(0, mathContext);
84 } else {
85 throw new UnsupportedOperationException("初始化Decimal失败,传入值为" + ToolJson.anyToJson(initValue));
86 }
87 }
88
89
90 //endregion

Callers 1

DecimalMethod · 0.95

Calls 4

cloneMethod · 0.95
anyToJsonMethod · 0.95
getBigDecimalMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected