org.springframework.beans

## 类 TypeConverterSupport

- java.lang.Object
- - org.springframework.beans.PropertyEditorRegistrySupport
  - - org.springframework.beans.TypeConverterSupport

- 所有已实现的接口:
    PropertyEditorRegistry, TypeConverter
  直接已知子类:
    AbstractPropertyAccessor, SimpleTypeConverter

      public abstract class TypeConverterSupport
      extends PropertyEditorRegistrySupport
      implements TypeConverter

  Base implementation of the `TypeConverter` interface, using a package-private delegate. Mainly serves as base class for `BeanWrapperImpl`.
  从以下版本开始:
    3.2
  作者:
    Juergen Hoeller
  另请参阅:
    `SimpleTypeConverter`

- - ### 构造器概要

    构造器
    构造器和说明
    `TypeConverterSupport()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `<T> T` | `convertIfNecessary(Object value, Class<T> requiredType)` Convert the value to the required type (if necessary from a String).
    `<T> T` | `convertIfNecessary(Object value, Class<T> requiredType, Field field)` Convert the value to the required type (if necessary from a String).
    `<T> T` | `convertIfNecessary(Object value, Class<T> requiredType, org.springframework.core.MethodParameter methodParam)` Convert the value to the required type (if necessary from a String).

    - ### 从类继承的方法 org.springframework.beans.PropertyEditorRegistrySupport

      `copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, getPropertyType, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, useConfigValueEditors`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### TypeConverterSupport

          public TypeConverterSupport()

  - ### 方法详细资料

    - #### convertIfNecessary

          @Nullable
          public <T> T convertIfNecessary(@Nullable
                                                     Object value,
                                                     @Nullable
                                                     Class<T> requiredType)
                                              throws TypeMismatchException

      从接口复制的说明: `TypeConverter`
      Convert the value to the required type (if necessary from a String).

      Conversions from String to any type will typically use the `setAsText` method of the PropertyEditor class, or a Spring Converter in a ConversionService.

      指定者:
        `convertIfNecessary` 在接口中 `TypeConverter`
      参数:
        `value` - the value to convert
        `requiredType` - the type we must convert to (or `null` if not known, for example in case of a collection element)
      返回:
        the new value, possibly the result of type conversion
      抛出:
        `TypeMismatchException` - if type conversion failed
      另请参阅:
        `PropertyEditor.setAsText(String)`, `PropertyEditor.getValue()`, `ConversionService`, `org.springframework.core.convert.converter.Converter`

    - #### convertIfNecessary

          @Nullable
          public <T> T convertIfNecessary(@Nullable
                                                     Object value,
                                                     @Nullable
                                                     Class<T> requiredType,
                                                     @Nullable
                                                     org.springframework.core.MethodParameter methodParam)
                                              throws TypeMismatchException

      从接口复制的说明: `TypeConverter`
      Convert the value to the required type (if necessary from a String).

      Conversions from String to any type will typically use the `setAsText` method of the PropertyEditor class, or a Spring Converter in a ConversionService.

      指定者:
        `convertIfNecessary` 在接口中 `TypeConverter`
      参数:
        `value` - the value to convert
        `requiredType` - the type we must convert to (or `null` if not known, for example in case of a collection element)
        `methodParam` - the method parameter that is the target of the conversion (for analysis of generic types; may be `null`)
      返回:
        the new value, possibly the result of type conversion
      抛出:
        `TypeMismatchException` - if type conversion failed
      另请参阅:
        `PropertyEditor.setAsText(String)`, `PropertyEditor.getValue()`, `ConversionService`, `org.springframework.core.convert.converter.Converter`

    - #### convertIfNecessary

          @Nullable
          public <T> T convertIfNecessary(@Nullable
                                                     Object value,
                                                     @Nullable
                                                     Class<T> requiredType,
                                                     @Nullable
                                                     Field field)
                                              throws TypeMismatchException

      从接口复制的说明: `TypeConverter`
      Convert the value to the required type (if necessary from a String).

      Conversions from String to any type will typically use the `setAsText` method of the PropertyEditor class, or a Spring Converter in a ConversionService.

      指定者:
        `convertIfNecessary` 在接口中 `TypeConverter`
      参数:
        `value` - the value to convert
        `requiredType` - the type we must convert to (or `null` if not known, for example in case of a collection element)
        `field` - the reflective field that is the target of the conversion (for analysis of generic types; may be `null`)
      返回:
        the new value, possibly the result of type conversion
      抛出:
        `TypeMismatchException` - if type conversion failed
      另请参阅:
        `PropertyEditor.setAsText(String)`, `PropertyEditor.getValue()`, `ConversionService`, `org.springframework.core.convert.converter.Converter`