com.holonplatform.vaadin.flow.components.converters

## Interface StringToNumberConverter<T extends Number>

- Type Parameters:
    `T` - Number type
  All Superinterfaces:
    com.vaadin.flow.data.converter.Converter<String,T>, Serializable

      public interface StringToNumberConverter<T extends Number>
      extends com.vaadin.flow.data.converter.Converter<String,T>

  A `Converter`s that convert from `Number` types to `String` and back.

  The String value is trimmed before conversion. Null or empty String values will be converted into `null` Number values.

  Since:
    5.2.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `StringToNumberConverter.Builder<T extends Number>` `StringToNumberConverter` builder.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T extends Number> StringToNumberConverter.Builder<T>` | `builder(Class<? extends T> numberType)` Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type.
    `static <T extends Number> StringToNumberConverter.Builder<T>` | `builder(Class<? extends T> numberType, Locale locale)` Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and given `Locale`.
    `static <T extends Number> StringToNumberConverter.Builder<T>` | `builder(Class<? extends T> numberType, NumberFormat numberFormat)` Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and using given `NumberFormat`.
    `static <T extends Number> StringToNumberConverter.Builder<T>` | `builder(Class<? extends T> numberType, String numberFormatPattern)` Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and using given number format pattern.
    `static <T extends Number> StringToNumberConverter<T>` | `create(Class<T> numberType)` Create a new `StringToNumberConverter` for given number type.
    `static <T extends Number> StringToNumberConverter<T>` | `create(Class<T> numberType, Locale locale)` Create a new `StringToNumberConverter` for given number type and given `Locale`.
    `static <T extends Number> StringToNumberConverter<T>` | `create(Class<T> numberType, NumberFormat numberFormat)` Create a new `StringToNumberConverter` for given number type and using given `NumberFormat`.
    `static <T extends Number> StringToNumberConverter<T>` | `create(Class<T> numberType, String numberFormatPattern)` Create a new `StringToNumberConverter` for given number type and using given number format pattern.
    `Optional<Character>` | `getDecimalSymbol()` Get the decimal separator character, if available
    `int` | `getMaxDecimals()` Get the maximum decimal digits allowed.
    `int` | `getMinDecimals()` Get the minimum decimal digits to display.
    `String` | `getValidationPattern()` Get the regex validation pattern which corresponds to the converter configuration.
    `boolean` | `isAllowNegatives()` Get whether to allow negative numbers.
    `void` | `setAllowNegatives(boolean allowNegatives)` Set whether to allow negative numbers.
    `void` | `setMaxDecimals(int maxDecimals)` Set the maximum decimal digits allowed.
    `void` | `setMinDecimals(int minDecimals)` Set the minimum decimal digits to display.

    - ### Methods inherited from interface com.vaadin.flow.data.converter.Converter

      `chain, convertToModel, convertToPresentation, from, from, identity`

- - ### Method Detail

    - #### isAllowNegatives

          boolean isAllowNegatives()

      Get whether to allow negative numbers.
      Returns:
        whether to allow negative number

    - #### setAllowNegatives

          void setAllowNegatives(boolean allowNegatives)

      Set whether to allow negative numbers.
      Parameters:
        `allowNegatives` - whether to allow negative numbers

    - #### getMinDecimals

          int getMinDecimals()

      Get the minimum decimal digits to display.
      Returns:
        the minimum decimal digits, `-1` if not configured

    - #### setMinDecimals

          void setMinDecimals(int minDecimals)

      Set the minimum decimal digits to display.
      Parameters:
        `minDecimals` - the minimum decimal digits to display, `-1` for no limit

    - #### getMaxDecimals

          int getMaxDecimals()

      Get the maximum decimal digits allowed.
      Returns:
        the maximum decimal digits, `-1` if no limit

    - #### setMaxDecimals

          void setMaxDecimals(int maxDecimals)

      Set the maximum decimal digits allowed.
      Parameters:
        `maxDecimals` - the maximum decimal digits, `-1` for no limit

    - #### getDecimalSymbol

          Optional<Character> getDecimalSymbol()

      Get the decimal separator character, if available
      Returns:
        the decimal separator character, or empty if the number type is not a decimal number

    - #### getValidationPattern

          String getValidationPattern()

      Get the regex validation pattern which corresponds to the converter configuration.
      Returns:
        the regex validation pattern

    - #### create

          static <T extends Number> StringToNumberConverter<T> create(Class<T> numberType)

      Create a new `StringToNumberConverter` for given number type.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
      Returns:
        A new `StringToNumberConverter`

    - #### create

          static <T extends Number> StringToNumberConverter<T> create(Class<T> numberType,
                                                                      Locale locale)

      Create a new `StringToNumberConverter` for given number type and given `Locale`.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `locale` - The `Locale` to use
      Returns:
        A new `StringToNumberConverter`

    - #### create

          static <T extends Number> StringToNumberConverter<T> create(Class<T> numberType,
                                                                      String numberFormatPattern)

      Create a new `StringToNumberConverter` for given number type and using given number format pattern.

      The pattern style must be consistent with the Java DecimalFormat pattern conventions.

      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `numberFormatPattern` - The number format pattern to use
      Returns:
        A new `StringToNumberConverter`

    - #### create

          static <T extends Number> StringToNumberConverter<T> create(Class<T> numberType,
                                                                      NumberFormat numberFormat)

      Create a new `StringToNumberConverter` for given number type and using given `NumberFormat`.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `numberFormat` - The `NumberFormat` to use
      Returns:
        A new `StringToNumberConverter`

    - #### builder

          static <T extends Number> StringToNumberConverter.Builder<T> builder(Class<? extends T> numberType)

      Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
      Returns:
        A new `StringToNumberConverter` builder

    - #### builder

          static <T extends Number> StringToNumberConverter.Builder<T> builder(Class<? extends T> numberType,
                                                                               Locale locale)

      Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and given `Locale`.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `locale` - The `Locale` to use
      Returns:
        A new `StringToNumberConverter` builder

    - #### builder

          static <T extends Number> StringToNumberConverter.Builder<T> builder(Class<? extends T> numberType,
                                                                               String numberFormatPattern)

      Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and using given number format pattern.

      The pattern style must be consistent with the Java DecimalFormat pattern conventions.

      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `numberFormatPattern` - The number format pattern to use
      Returns:
        A new `StringToNumberConverter` builder

    - #### builder

          static <T extends Number> StringToNumberConverter.Builder<T> builder(Class<? extends T> numberType,
                                                                               NumberFormat numberFormat)

      Get a `StringToNumberConverter.Builder` to create and configure a `StringToNumberConverter` for given number type and using given `NumberFormat`.
      Type Parameters:
        `T` - Number type
      Parameters:
        `numberType` - Number type (not null)
        `numberFormat` - The `NumberFormat` to use
      Returns:
        A new `StringToNumberConverter` builder

Copyright © 2019 The Holon Platform. All rights reserved.