mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Boolean优化字符串转换boolean的逻辑
This commit is contained in:
parent
322c95fde2
commit
5d33c34574
@ -11,7 +11,7 @@ import cn.hutool.core.convert.Convert;
|
||||
public class BooleanUtil {
|
||||
|
||||
/** 表示为真的字符串 */
|
||||
private static final String[] TRUE_ARRAY = { "true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√"};
|
||||
private static final Set<String> TRUE_SET = new HashSet<>(Arrays.asList("true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√"));
|
||||
|
||||
/**
|
||||
* 取相反值
|
||||
@ -77,7 +77,7 @@ public class BooleanUtil {
|
||||
public static boolean toBoolean(String valueStr) {
|
||||
if (StrUtil.isNotBlank(valueStr)) {
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
return ArrayUtil.contains(TRUE_ARRAY, valueStr);
|
||||
return TRUE_SET.contains(valueStr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user