public class BooleanUtil extends Object
Constructor and Description |
---|
BooleanUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
and(boolean... array)
对Boolean数组取与
BooleanUtil.and(true, true) = true
BooleanUtil.and(false, false) = false
BooleanUtil.and(true, false) = false
BooleanUtil.and(true, true, false) = false
BooleanUtil.and(true, true, true) = true
|
static Boolean |
andOfWrap(Boolean... array)
对Boolean数组取与
BooleanUtil.and(Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.and(Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE
BooleanUtil.and(Boolean.TRUE, Boolean.FALSE) = Boolean.FALSE
BooleanUtil.and(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.and(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE) = Boolean.FALSE
BooleanUtil.and(Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) = Boolean.FALSE
|
static boolean |
isBoolean(Class<?> clazz)
给定类是否为Boolean或者boolean
|
static boolean |
isFalse(Boolean bool)
检查
Boolean 值是否为 false
BooleanUtil.isFalse(Boolean.TRUE) = false
BooleanUtil.isFalse(Boolean.FALSE) = true
BooleanUtil.isFalse(null) = false
|
static boolean |
isTrue(Boolean bool)
检查
Boolean 值是否为 true
BooleanUtil.isTrue(Boolean.TRUE) = true
BooleanUtil.isTrue(Boolean.FALSE) = false
BooleanUtil.isTrue(null) = false
|
static boolean |
negate(boolean bool)
取相反值
|
static Boolean |
negate(Boolean bool)
取相反值
|
static boolean |
or(boolean... array)
对Boolean数组取或
BooleanUtil.or(true, true) = true
BooleanUtil.or(false, false) = false
BooleanUtil.or(true, false) = true
BooleanUtil.or(true, true, false) = true
BooleanUtil.or(true, true, true) = true
BooleanUtil.or(false, false, false) = false
|
static Boolean |
orOfWrap(Boolean... array)
对Boolean数组取或
BooleanUtil.or(Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.or(Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE
BooleanUtil.or(Boolean.TRUE, Boolean.FALSE) = Boolean.TRUE
BooleanUtil.or(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.or(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.or(Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) = Boolean.TRUE
BooleanUtil.or(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE
|
static boolean |
toBoolean(String valueStr)
转换字符串为boolean值
|
static Boolean |
toBooleanObject(String valueStr)
转换字符串为boolean值
如果为["true", "yes", "y", "t", "ok", "1", "on", "是", "对", "真", "對", "√"],返回 true 如果为["false", "no", "n", "f", "0", "off", "否", "错", "假", "錯", "×"],返回 false 其他情况返回 null |
static byte |
toByte(boolean value)
boolean值转为byte
|
static Byte |
toByteObj(boolean value)
boolean值转为Byte
|
static char |
toChar(boolean value)
boolean值转为char
|
static Character |
toCharacter(boolean value)
boolean值转为Character
|
static double |
toDouble(boolean value)
boolean值转为double
|
static Double |
toDoubleObj(boolean value)
boolean值转为double
|
static float |
toFloat(boolean value)
boolean值转为float
|
static Float |
toFloatObj(boolean value)
boolean值转为Float
|
static int |
toInt(boolean value)
boolean值转为int
|
static Integer |
toInteger(boolean value)
boolean值转为Integer
|
static long |
toLong(boolean value)
boolean值转为long
|
static Long |
toLongObj(boolean value)
boolean值转为Long
|
static short |
toShort(boolean value)
boolean值转为short
|
static Short |
toShortObj(boolean value)
boolean值转为Short
|
static String |
toString(boolean bool,
String trueString,
String falseString)
将boolean转换为字符串
BooleanUtil.toString(true, "true", "false") = "true"
BooleanUtil.toString(false, "true", "false") = "false"
|
static String |
toString(Boolean bool,
String trueString,
String falseString,
String nullString)
将boolean转换为字符串
BooleanUtil.toString(true, "true", "false", null) = "true"
BooleanUtil.toString(false, "true", "false", null) = "false"
BooleanUtil.toString(null, "true", "false", null) = null
|
static String |
toStringOnOff(boolean bool)
将boolean转换为字符串
'on' 或者 'off' . |
static String |
toStringTrueFalse(boolean bool)
将boolean转换为字符串
'true' 或者 'false' . |
static String |
toStringYesNo(boolean bool)
将boolean转换为字符串
'yes' 或者 'no' . |
static boolean |
xor(boolean... array)
对Boolean数组取异或
BooleanUtil.xor(true, true) = false
BooleanUtil.xor(false, false) = false
BooleanUtil.xor(true, false) = true
BooleanUtil.xor(true, true) = false
BooleanUtil.xor(false, false) = false
BooleanUtil.xor(true, false) = true
|
static Boolean |
xorOfWrap(Boolean... array)
对Boolean数组取异或
BooleanUtil.xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) = Boolean.FALSE
BooleanUtil.xor(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) = Boolean.FALSE
BooleanUtil.xor(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) = Boolean.TRUE
|
public static Boolean negate(Boolean bool)
bool
- Boolean值public static boolean isTrue(Boolean bool)
Boolean
值是否为 true
BooleanUtil.isTrue(Boolean.TRUE) = true BooleanUtil.isTrue(Boolean.FALSE) = false BooleanUtil.isTrue(null) = false
bool
- 被检查的Boolean值true
public static boolean isFalse(Boolean bool)
Boolean
值是否为 false
BooleanUtil.isFalse(Boolean.TRUE) = false BooleanUtil.isFalse(Boolean.FALSE) = true BooleanUtil.isFalse(null) = false
bool
- 被检查的Boolean值true
public static boolean negate(boolean bool)
bool
- Boolean值public static boolean toBoolean(String valueStr)
valueStr
- 字符串public static Boolean toBooleanObject(String valueStr)
true
false
null
valueStr
- 字符串public static int toInt(boolean value)
value
- Boolean值public static Integer toInteger(boolean value)
value
- Boolean值public static char toChar(boolean value)
value
- Boolean值public static Character toCharacter(boolean value)
value
- Boolean值public static byte toByte(boolean value)
value
- Boolean值public static Byte toByteObj(boolean value)
value
- Boolean值public static long toLong(boolean value)
value
- Boolean值public static Long toLongObj(boolean value)
value
- Boolean值public static short toShort(boolean value)
value
- Boolean值public static Short toShortObj(boolean value)
value
- Boolean值public static float toFloat(boolean value)
value
- Boolean值public static Float toFloatObj(boolean value)
value
- Boolean值public static double toDouble(boolean value)
value
- Boolean值public static Double toDoubleObj(boolean value)
value
- Boolean值public static String toStringTrueFalse(boolean bool)
'true'
或者 'false'
.
BooleanUtil.toStringTrueFalse(true) = "true" BooleanUtil.toStringTrueFalse(false) = "false"
bool
- Boolean值'true'
, 'false'
public static String toStringOnOff(boolean bool)
'on'
或者 'off'
.
BooleanUtil.toStringOnOff(true) = "on" BooleanUtil.toStringOnOff(false) = "off"
bool
- Boolean值'on'
, 'off'
public static String toStringYesNo(boolean bool)
'yes'
或者 'no'
.
BooleanUtil.toStringYesNo(true) = "yes" BooleanUtil.toStringYesNo(false) = "no"
bool
- Boolean值'yes'
, 'no'
public static String toString(boolean bool, String trueString, String falseString)
BooleanUtil.toString(true, "true", "false") = "true" BooleanUtil.toString(false, "true", "false") = "false"
bool
- Boolean值trueString
- 当值为 true
时返回此字符串, 可能为 null
falseString
- 当值为 false
时返回此字符串, 可能为 null
public static String toString(Boolean bool, String trueString, String falseString, String nullString)
BooleanUtil.toString(true, "true", "false", null) = "true" BooleanUtil.toString(false, "true", "false", null) = "false" BooleanUtil.toString(null, "true", "false", null) = null
bool
- Boolean值trueString
- 当值为 true
时返回此字符串, 可能为 null
falseString
- 当值为 false
时返回此字符串, 可能为 null
nullString
- 当值为 null
时返回此字符串, 可能为 null
public static boolean and(boolean... array)
BooleanUtil.and(true, true) = true BooleanUtil.and(false, false) = false BooleanUtil.and(true, false) = false BooleanUtil.and(true, true, false) = false BooleanUtil.and(true, true, true) = true
array
- Boolean
数组true
public static Boolean andOfWrap(Boolean... array)
BooleanUtil.and(Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.and(Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE BooleanUtil.and(Boolean.TRUE, Boolean.FALSE) = Boolean.FALSE BooleanUtil.and(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.and(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE) = Boolean.FALSE BooleanUtil.and(Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) = Boolean.FALSE
array
- Boolean
数组true
public static boolean or(boolean... array)
BooleanUtil.or(true, true) = true BooleanUtil.or(false, false) = false BooleanUtil.or(true, false) = true BooleanUtil.or(true, true, false) = true BooleanUtil.or(true, true, true) = true BooleanUtil.or(false, false, false) = false
array
- Boolean
数组true
public static Boolean orOfWrap(Boolean... array)
BooleanUtil.or(Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.or(Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE BooleanUtil.or(Boolean.TRUE, Boolean.FALSE) = Boolean.TRUE BooleanUtil.or(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.or(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.or(Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) = Boolean.TRUE BooleanUtil.or(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE) = Boolean.FALSE
array
- Boolean
数组true
public static boolean xor(boolean... array)
BooleanUtil.xor(true, true) = false BooleanUtil.xor(false, false) = false BooleanUtil.xor(true, false) = true BooleanUtil.xor(true, true) = false BooleanUtil.xor(false, false) = false BooleanUtil.xor(true, false) = true
array
- boolean
数组true
public static Boolean xorOfWrap(Boolean... array)
BooleanUtil.xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) = Boolean.FALSE BooleanUtil.xor(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) = Boolean.FALSE BooleanUtil.xor(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) = Boolean.TRUE
array
- Boolean
数组true
public static boolean isBoolean(Class<?> clazz)
clazz
- 类Copyright © 2024. All rights reserved.