Interface StringToObjectConverter

All Known Implementing Classes:
FallbackStringToObjectConverter, StringToBooleanConverter, StringToCharacterConverter, StringToClassConverter, StringToCommonJavaTypesConverter, StringToEnumConverter, StringToJavaTimeConverter, StringToNumberConverter

interface StringToObjectConverter
Internal API for converting arguments of type String to a specified target type.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canConvert(Class<?> targetType)
    Determine if this converter can convert from a String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).
    convert(String source, Class<?> targetType)
    Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).
    default Object
    convert(String source, Class<?> targetType, ClassLoader classLoader)
    Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).
  • Method Details

    • canConvert

      boolean canConvert(Class<?> targetType)
      Determine if this converter can convert from a String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).
    • convert

      Object convert(String source, Class<?> targetType) throws Exception
      Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).
      Throws:
      Exception
    • convert

      default Object convert(String source, Class<?> targetType, ClassLoader classLoader) throws Exception
      Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

      The default implementation simply delegates to convert(String, Class). Can be overridden by concrete implementations of this interface that need access to the supplied ClassLoader.

      Throws:
      Exception