public class EnumConverter extends AbstractConverter<Object>
| Constructor and Description |
|---|
EnumConverter(Class enumClass)
构造
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
convertInternal(Object value)
内部转换器,被
AbstractConverter.convert(Object, Object) 调用,实现基本转换逻辑内部转换器转换后如果转换失败可以做如下操作,处理结果都为返回默认值: 1、返回 null
2、抛出一个RuntimeException异常
|
Class |
getTargetType()
获得此类实现类的泛型类型
|
protected static Enum |
tryConvertEnum(Object value,
Class enumClass)
尝试转换,转换规则为:
如果实现
EnumItem接口,则调用fromInt或fromStr转换
找到类似转换的静态方法调用实现转换且优先使用
约定枚举类应该提供 valueOf(String) 和 valueOf(Integer)用于转换
oriInt /name 转换托底
|
convert, convertQuietly, convertToStrclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertWithCheckpublic EnumConverter(Class enumClass)
enumClass - 转换成的目标Enum类protected Object convertInternal(Object value)
AbstractConverterAbstractConverter.convert(Object, Object) 调用,实现基本转换逻辑1、返回null2、抛出一个RuntimeException异常
convertInternal in class AbstractConverter<Object>value - 值public Class getTargetType()
AbstractConvertergetTargetType in class AbstractConverter<Object>nullCopyright © 2025. All rights reserved.