布爾工具類工具
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