Conversion<java.lang.String,T>
, FormattedConversion<java.text.DecimalFormat>
public class FormattedBigDecimalConversion extends NumericConversion<java.math.BigDecimal>
BigDecimal
and vice versa.
This class supports multiple numeric formats. For example, you can define conversions from numbers represented by different Strings such as "1,000,000.00 and $5.00".
The reverse conversion from a BigDecimal to String (in revert(BigDecimal)
will return a formatted String using the pattern provided in this class constructor
The numeric patterns must follow the pattern rules of DecimalFormat
DecimalFormat
Constructor | Description |
---|---|
FormattedBigDecimalConversion() |
Defines a conversion from String to
BigDecimal using a sequence of acceptable numeric patterns. |
FormattedBigDecimalConversion(java.lang.String... numericFormats) |
Defines a conversion from String to
BigDecimal using a sequence of acceptable numeric patterns. |
FormattedBigDecimalConversion(java.math.BigDecimal valueIfStringIsNull,
java.lang.String valueIfObjectIsNull) |
Defines a conversion from String to
BigDecimal using a sequence of acceptable numeric patterns. |
FormattedBigDecimalConversion(java.math.BigDecimal valueIfStringIsNull,
java.lang.String valueIfObjectIsNull,
java.lang.String... numericFormats) |
Defines a conversion from String to
BigDecimal using a sequence of acceptable numeric patterns. |
FormattedBigDecimalConversion(java.text.DecimalFormat... numericFormatters) |
Defines a conversion from String to
BigDecimal using a sequence of acceptable numeric patterns. |
Modifier and Type | Method | Description |
---|---|---|
protected void |
configureFormatter(java.text.DecimalFormat formatter) |
Configures the Decimal format instance created by the parent class to parse BigDecimals.
|
getValueOnNullInput, getValueOnNullOutput, setValueOnNullInput, setValueOnNullOutput
addFormat, fromString, getFormatterObjects, getNumberType, revert, setNumberType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, fromInput, getValueIfObjectIsNull, getValueIfStringIsNull, setValueIfObjectIsNull, setValueIfStringIsNull, undo
public FormattedBigDecimalConversion(java.math.BigDecimal valueIfStringIsNull, java.lang.String valueIfObjectIsNull, java.lang.String... numericFormats)
BigDecimal
using a sequence of acceptable numeric patterns.
This constructor assumes the output of a conversion should be null when input is nullvalueIfStringIsNull
- default BigDecimal to be returned when the input String is null. Used when ObjectConversion.execute(String)
is invoked.valueIfObjectIsNull
- default String value to be returned when a BigDecimal input is null. Used when revert(BigDecimal)
is invoked.numericFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in revert(BigDecimal)
.public FormattedBigDecimalConversion(java.math.BigDecimal valueIfStringIsNull, java.lang.String valueIfObjectIsNull)
BigDecimal
using a sequence of acceptable numeric patterns. The patterns
must be added to this conversion class through the NumericConversion.addFormat(String, String...)
method.valueIfStringIsNull
- default BigDecimal to be returned when the input String is null. Used when ObjectConversion.execute(String)
is invoked.valueIfObjectIsNull
- default String value to be returned when a BigDecimal input is null. Used when NumericConversion.revert(Number)
is invoked.public FormattedBigDecimalConversion(java.lang.String... numericFormats)
BigDecimal
using a sequence of acceptable numeric patterns.
This constructor assumes the output of a conversion should be null when input is nullnumericFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion.revert(Number)
.public FormattedBigDecimalConversion(java.text.DecimalFormat... numericFormatters)
BigDecimal
using a sequence of acceptable numeric patterns.
This constructor assumes the output of a conversion should be null when input is nullnumericFormatters
- list formatters of acceptable numeric patterns. The first formatter in this sequence will be used to convert a BigDecimal into a String in NumericConversion.revert(Number)
.public FormattedBigDecimalConversion()
BigDecimal
using a sequence of acceptable numeric patterns. The patterns
must be added to this conversion class through the NumericConversion.addFormat(String, String...)
method.
This constructor assumes the output of a conversion should be null when input is nullprotected void configureFormatter(java.text.DecimalFormat formatter)
configureFormatter
in class NumericConversion<java.math.BigDecimal>
formatter
- a DecimalFormat instance initialized with one of the patterns provided in the constructor of this class.