Class PairConverter

java.lang.Object
org.miaixz.bus.core.convert.PairConverter
All Implemented Interfaces:
Converter

public class PairConverter extends Object implements Converter
Pair 转换器,支持以下类型转为Pair
  • Map
  • Map.Entry
  • 带分隔符的字符串,支持分隔符:=,
  • Bean,包含getLeftgetRight方法
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

  • Constructor Details

    • PairConverter

      public PairConverter()
  • 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 Pair<?,?> convert(Type leftType, Type rightType, Object value) throws ConvertException
      转换对象为指定键值类型的指定类型Map
      Parameters:
      leftType - 键类型
      rightType - 值类型
      value - 被转换的值
      Returns:
      转换后的Map
      Throws:
      ConvertException - 转换异常或不支持的类型