mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Merge pull request #1137 from akiyamaneko/BOOLEAN_IMPROVED
优化BooleanUtil的校验逻辑
This commit is contained in:
commit
2619bdd1df
@ -11,7 +11,7 @@ import cn.hutool.core.convert.Convert;
|
|||||||
public class BooleanUtil {
|
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) {
|
public static boolean toBoolean(String valueStr) {
|
||||||
if (StrUtil.isNotBlank(valueStr)) {
|
if (StrUtil.isNotBlank(valueStr)) {
|
||||||
valueStr = valueStr.trim().toLowerCase();
|
valueStr = valueStr.trim().toLowerCase();
|
||||||
return ArrayUtil.contains(TRUE_ARRAY, valueStr);
|
return TRUE_SET.contains(valueStr);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user