Module bus.core

Class SpecialConverter

java.lang.Object
org.miaixz.bus.core.convert.ConverterWithRoot
org.miaixz.bus.core.convert.SpecialConverter
All Implemented Interfaces:
Serializable, Converter

public class SpecialConverter extends ConverterWithRoot implements Serializable
特殊类型转换器,如果不符合特殊类型,则返回null继续其它转换规则 对于特殊对象(如集合、Map、Enum、数组)等的转换器,实现转换 注意:此类中的转换器查找是通过遍历方式
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • SpecialConverter

      public SpecialConverter(Converter rootConverter)
      构造
      Parameters:
      rootConverter - 父转换器
  • Method Details

    • convert

      public Object convert(Type targetType, Object value) throws ConvertException
      Description copied from interface: Converter
      转换为指定类型 如果类型无法确定,将读取默认值的类型做为目标类型
      Specified by:
      convert in interface Converter
      Parameters:
      targetType - 目标Type,非泛型类使用
      value - 原始值,如果对象实现了此接口,则value为this
      Returns:
      转换后的值
      Throws:
      ConvertException - 转换无法正常完成或转换异常时抛出此异常
    • convert

      public Object convert(Type targetType, Class<?> rawType, Object value) throws ConvertException
      转换值
      Parameters:
      targetType - 目标类型
      rawType - 目标原始类型(即目标的Class)
      value - 被转换的值
      Returns:
      转换后的值,如果无转换器,返回null
      Throws:
      ConvertException - 转换异常,即找到了对应的转换器,但是转换失败
    • getConverter

      public Converter getConverter(Type type, Class<?> rawType, Object value)
      获得匹配的转换器
      Parameters:
      type - 类型
      rawType - 目标类型的Class
      value - 被转换的值
      Returns:
      转换器