public class StringToBigIntegerConverter extends AbstractStringToNumberConverter<BigInteger>
String
to BigInteger
and back.
Uses the given locale and a NumberFormat
instance for formatting and
parsing.
Leading and trailing white spaces are ignored when converting from a String.
Override and overwrite getFormat(Locale)
to use a different format.
Constructor and Description |
---|
StringToBigIntegerConverter(BigInteger emptyValue,
ErrorMessageProvider errorMessageProvider)
Creates a new converter instance with the given presentation value for
empty string and error message provider.
|
StringToBigIntegerConverter(BigInteger emptyValue,
String errorMessage)
Creates a new converter instance with the given presentation value for
empty string and error message.
|
StringToBigIntegerConverter(ErrorMessageProvider errorMessageProvider)
Creates a new converter instance with the given error message provider.
|
StringToBigIntegerConverter(String errorMessage)
Creates a new converter instance with the given error message.
|
Modifier and Type | Method and Description |
---|---|
Result<BigInteger> |
convertToModel(String value,
ValueContext context)
Converts the given value from presentation type to model type.
|
protected NumberFormat |
getFormat(Locale locale)
Returns the format used by
Converter.convertToPresentation(Object, ValueContext) and
Converter.convertToModel(Object, ValueContext) . |
convertToNumber, convertToPresentation, getErrorMessage
public StringToBigIntegerConverter(String errorMessage)
null
.errorMessage
- the error message to use if conversion failspublic StringToBigIntegerConverter(BigInteger emptyValue, String errorMessage)
emptyValue
- the presentation value to return when converting an empty
string, may be null
errorMessage
- the error message to use if conversion failspublic StringToBigIntegerConverter(ErrorMessageProvider errorMessageProvider)
null
.errorMessageProvider
- the error message provider to use if conversion failspublic StringToBigIntegerConverter(BigInteger emptyValue, ErrorMessageProvider errorMessageProvider)
emptyValue
- the presentation value to return when converting an empty
string, may be null
errorMessageProvider
- the error message provider to use if conversion failsprotected NumberFormat getFormat(Locale locale)
AbstractStringToNumberConverter
Converter.convertToPresentation(Object, ValueContext)
and
Converter.convertToModel(Object, ValueContext)
.getFormat
in class AbstractStringToNumberConverter<BigInteger>
locale
- The locale to usepublic Result<BigInteger> convertToModel(String value, ValueContext context)
Converter
A converter can optionally use locale to do the conversion.
value
- The value to convert. Can be nullcontext
- The value context for the conversion.Copyright © 2019. All rights reserved.