mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
Merge pull request #2816 from 847689421/v5-dev
BooleanUtil增加toString(Boolean bool, String trueString, String falseString, String nullString)方法
This commit is contained in:
commit
0cf4a8d6c1
@ -311,6 +311,28 @@ public class BooleanUtil {
|
||||
return bool ? trueString : falseString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将boolean转换为字符串
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtil.toString(true, "true", "false", null) = "true"
|
||||
* BooleanUtil.toString(false, "true", "false", null) = "false"
|
||||
* BooleanUtil.toString(null, "true", "false", null) = null
|
||||
* </pre>
|
||||
*
|
||||
* @param bool Boolean值
|
||||
* @param trueString 当值为 {@code true}时返回此字符串, 可能为 {@code null}
|
||||
* @param falseString 当值为 {@code false}时返回此字符串, 可能为 {@code null}
|
||||
* @param nullString 当值为 {@code null}时返回此字符串, 可能为 {@code null}
|
||||
* @return 结果值
|
||||
*/
|
||||
public static String toString(Boolean bool, String trueString, String falseString, String nullString) {
|
||||
if (bool == null) {
|
||||
return nullString;
|
||||
}
|
||||
return bool ? trueString : falseString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对Boolean数组取与
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user