public class BooleanConverter extends AbstractConverter
对象转为boolean,规则如下:
1、数字0为false,其它数字为true
2、转换为字符串,形如"true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√"为true,其它字符串为false.
| Modifier and Type | Field and Description |
|---|---|
static BooleanConverter |
INSTANCE
单例
|
| Constructor and Description |
|---|
BooleanConverter() |
| Modifier and Type | Method and Description |
|---|---|
protected Boolean |
convertInternal(Class<?> targetClass,
Object value)
内部转换器,被
AbstractConverter.convert(Type, Object) 调用,实现基本转换逻辑内部转换器转换后如果转换失败可以做如下操作,处理结果都为返回默认值: 1、返回 null
2、抛出一个RuntimeException异常
|
convert, convertToStrpublic static final BooleanConverter INSTANCE
protected Boolean convertInternal(Class<?> targetClass, Object value)
AbstractConverterAbstractConverter.convert(Type, Object) 调用,实现基本转换逻辑1、返回null2、抛出一个RuntimeException异常
convertInternal in class AbstractConvertertargetClass - 目标类型value - 值Copyright © 2025. All rights reserved.