Class StringToDoubleConverter

    • Constructor Detail

      • StringToDoubleConverter

        public StringToDoubleConverter​(String errorMessage)
        Creates a new converter instance with the given error message. Empty strings are converted to null.
        Parameters:
        errorMessage - the error message to use if conversion fails
      • StringToDoubleConverter

        public StringToDoubleConverter​(Double emptyValue,
                                       String errorMessage)
        Creates a new converter instance with the given presentation value for empty string and error message.
        Parameters:
        emptyValue - the presentation value to return when converting an empty string, may be null
        errorMessage - the error message to use if conversion fails
      • StringToDoubleConverter

        public StringToDoubleConverter​(ErrorMessageProvider errorMessageProvider)
        Creates a new converter instance with the given error message provider. Empty strings are converted to null.
        Parameters:
        errorMessageProvider - the error message provider to use if conversion fails
      • StringToDoubleConverter

        public StringToDoubleConverter​(Double emptyValue,
                                       ErrorMessageProvider errorMessageProvider)
        Creates a new converter instance with the given presentation value for empty string and error message provider.
        Parameters:
        emptyValue - the presentation value to return when converting an empty string, may be null
        errorMessageProvider - the error message provider to use if conversion fails
    • Method Detail

      • convertToModel

        public Result<Double> convertToModel​(String value,
                                             ValueContext context)
        Description copied from interface: Converter
        Converts the given value from presentation type to model type.

        A converter can optionally use locale to do the conversion.

        Parameters:
        value - The value to convert. Can be null
        context - The value context for the conversion.
        Returns:
        The converted value compatible with the source type