java.lang.Object
ru.vyarus.dropwizard.guice.module.context.option.mapper.StringConverter

public final class StringConverter extends Object
Simple converter from string source to target type. Supports:
  • String
  • Boolean
  • Integer
  • Double
  • Short
  • Byte
  • Enum type value (when target type is exact enum type and string is enum constant)
  • Enum recognition (when target type is generic Enum and string is "fullEnumClass.constantName"
Also, could parse comma-separated lists to arrays of any of the above types (String[], Boolean[] etc).

Special support for EnumSet: it must be a list of fully qualified enum values (enumClass.enumValue).

Since:
27.04.2018
  • Method Details

    • convert

      public static <V> V convert(Class<V> target, String value)
      Convert string to type.
      Type Parameters:
      V - targe type
      Parameters:
      target - target type
      value - value to convert
      Returns:
      converted value