Integer to and from MathNumeric and BigDecimal to and from MathNumeric
Mapping between published integer fields and internal math numeric fields requires a data type transformation. You use the set methods of the internal value object to make these transformations. An overloaded method takes either an integer or a math numeric data type when setting the field value.
The same rule applies to mapping between big decimal and math numeric fields. The business service foundation provides multiple math numeric constructors. The null check is performed because the constructor throws an error if a null parameter is passed.
This code sample shows set methods where a new math numeric data type is created by passing an integer type value or a big decimal type value:
---------------Integer to MathNumeric---------------------- public void setNumberField(Integer numberField){ if(numberField!=null) this.numberField= new MathNumeric(numberField); } ---------------BigDecimal to MathNumeric------------------- public void setNumberField(BigDecimal numberField){ if(numberField!=null) this.numberField= new MathNumeric(numberField); } ---------------MathNumeric to BigDecimal-------------------- public void setNumberField(MathNumeric numberField){ if(numberField!= null) this.numberField= numberField.asBigDecimal(); } ---------------MathNumeric to Integer----------------------- public void setNumberField(MathNumeric numberField){ if(numberField!= null) this.numberField= new Integer(numberField.intValue()); }