布尔工具类工具
and(boolean... array) 逻辑与code
BooleanUtils.and(true, true) = true BooleanUtils.and(false, false) = false BooleanUtils.and(true, false) = false BooleanUtils.and(true, true, false) = false BooleanUtils.and(true, true, true) = true
compare(boolean x, boolean y) 比较两个布尔值并返回int类型 若是x == y返回0, !x && y 返回小于 0 ,x && !y 返回大于0对象
isFalse(Boolean bool) 是不是假并返回booleanstring
isTrue(Boolean bool) 是不是真并返回boolean数据类型
negate(Boolean bool) 逻辑非数据
BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE; BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; BooleanUtils.negate(null) = null;
or(boolean... array) 逻辑或类型转换
BooleanUtils.or(true, true) = true BooleanUtils.or(false, false) = false BooleanUtils.or(true, false) = true BooleanUtils.or(true, true, false) = true BooleanUtils.or(true, true, true) = true BooleanUtils.or(false, false, false) = false
toBoolean(Boolean bool) 将对象类型转换为基本数据类型并返回co
BooleanUtils.toBoolean(Boolean.TRUE) = true BooleanUtils.toBoolean(Boolean.FALSE) = false BooleanUtils.toBoolean(null) = false
toBoolean(int value) 将int类型转换为boolean类型并返回
BooleanUtils.toBoolean(0) = false BooleanUtils.toBoolean(1) = true BooleanUtils.toBoolean(2) = true
toBoolean(String str) 将string类型转换为boolean类型并返回
BooleanUtils.toBoolean(null) = false BooleanUtils.toBoolean("true") = true BooleanUtils.toBoolean("TRUE") = true BooleanUtils.toBoolean("tRUe") = true BooleanUtils.toBoolean("on") = true BooleanUtils.toBoolean("yes") = true BooleanUtils.toBoolean("false") = false BooleanUtils.toBoolean("x gti") = false BooleanUtils.toBooleanObject("y") = true BooleanUtils.toBooleanObject("n") = false BooleanUtils.toBooleanObject("t") = true BooleanUtils.toBooleanObject("f") = false
toInteger(boolean bool) 将boolean类型数据转换为int类型并返回
BooleanUtils.toInteger(true) = 1 BooleanUtils.toInteger(false) = 0
toStringOnOff(boolean bool) 将boolean类型数据转换为String类型'on' or 'off'并返回
BooleanUtils.toStringOnOff(true) = "on" BooleanUtils.toStringOnOff(false) = "off"
toStringTrueFalse(Boolean bool) 将boolean类型数据转换为String类型''true' or 'false'并返回
BooleanUtils.toStringTrueFalse(true) = "true" BooleanUtils.toStringTrueFalse(false) = "false"
toStringYesNo(boolean bool) 将boolean类型数据转换为String类型'yes' or 'no'并返回
BooleanUtils.toStringYesNo(true) = "yes" BooleanUtils.toStringYesNo(false) = "no"
xor(boolean... array) 异或
BooleanUtils.xor(true, true) = false BooleanUtils.xor(false, false) = false BooleanUtils.xor(true, false) = true