public class CompositeConverter extends Object implements Converter, Serializable
处理null、Opt、Optional --> 自定义匹配转换器 --> 自定义类型转换器 --> 预注册的标准转换器 --> Map、集合、Enum等特殊转换器 --> Bean转换器
| Modifier and Type | Method and Description |
|---|---|
Object |
convert(Type type,
Object value)
转换值为指定类型
|
<T> T |
convert(Type type,
Object value,
T defaultValue)
转换值为指定类型
自定义转换器优先 |
<T> T |
convert(Type type,
Object value,
T defaultValue,
boolean isCustomFirst)
转换值为指定类型
|
static CompositeConverter |
getInstance()
获得单例的 CompositeConverter
|
CompositeConverter |
register(MatcherConverter converter)
登记自定义转换器,符合
MatcherConverter.match(Type, Class, Object)则使用其转换器注意:如果单例使用,此方法会影响全局 |
CompositeConverter |
register(Type type,
Converter converter)
登记自定义转换器,登记的目标类型必须一致
注意:如果单例使用,此方法会影响全局 |
public static CompositeConverter getInstance()
public CompositeConverter register(MatcherConverter converter)
MatcherConverter.match(Type, Class, Object)则使用其转换器converter - 转换器public CompositeConverter register(Type type, Converter converter)
type - 转换的目标类型converter - 转换器public Object convert(Type type, Object value) throws ConvertException
convert in interface Convertertype - 类型value - 值nullConvertException - 转换器不存在public <T> T convert(Type type, Object value, T defaultValue) throws ConvertException
convert in interface ConverterT - 转换的目标类型(转换器转换到的类型)type - 类型value - 值defaultValue - 默认值ConvertException - 转换器不存在public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFirst) throws ConvertException
T - 转换的目标类型(转换器转换到的类型)type - 类型目标value - 被转换值defaultValue - 默认值isCustomFirst - 是否自定义转换器优先ConvertException - 转换器不存在Copyright © 2025. All rights reserved.