diff --git a/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java
index 1940a18a6..eff4b7e3c 100644
--- a/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java
@@ -293,8 +293,21 @@ public class StrUtil {
*
{@code StrUtil.isBlank("abc") // false}
*
*
+ * 注意:该方法与 {@link #isEmpty(CharSequence)} 的区别是:
+ * 该方法会校验空白字符,且性能相对于 {@link #isEmpty(CharSequence)} 略慢。
+ *
+ *
+ * 建议:
+ *
+ * - 该方法建议仅对于客户端(或第三方接口)传入的参数使用该方法。
+ * - 需要同时校验多个字符串时,建议采用 {@link #hasBlank(CharSequence...)} 或 {@link #isAllBlank(CharSequence...)}
+ *
+ *
* @param str 被检测的字符串
* @return 若为空白,则返回 true
+ *
+ * @see #isEmpty(CharSequence)
+ * @since 1.0.0
*/
public static boolean isBlank(CharSequence str) {
int length;
@@ -329,6 +342,9 @@ public class StrUtil {
* {@code StrUtil.isBlankIfStr("abc") // false}
*
*
+ * 注意:该方法与 {@link #isEmptyIfStr(Object)} 的区别是:
+ * 该方法会校验空白字符,且性能相对于 {@link #isEmptyIfStr(Object)} 略慢。
+ *
* @param obj 对象
* @return 如果为字符串是否为空串
* @see StrUtil#isBlank(CharSequence)
@@ -344,20 +360,52 @@ public class StrUtil {
}
/**
- * 字符串是否为非空白,非空白的定义如下:
- * 1、不为null
- * 2、不为不可见字符(如空格)
- * 3、不为""
+ * 字符串是否为非空白,非空白的定义如下:
+ *
+ * - 不为 {@code null}
+ * - 不为空字符串:{@code ""}
+ * - 不为空格、全角空格、制表符、换行符,等不可见字符
+ *
+ *
+ * 例:
+ *
+ * - {@code StrUtil.isNotBlank(null) // false}
+ * - {@code StrUtil.isNotBlank("") // false}
+ * - {@code StrUtil.isNotBlank(" \t\n") // false}
+ * - {@code StrUtil.isNotBlank("abc") // true}
+ *
+ *
+ * 注意:该方法与 {@link #isNotEmpty(CharSequence)} 的区别是:
+ * 该方法会校验空白字符,且性能相对于 {@link #isNotEmpty(CharSequence)} 略慢。
+ * 建议:仅对于客户端(或第三方接口)传入的参数使用该方法。
*
* @param str 被检测的字符串
* @return 是否为非空
+ *
+ * @see StrUtil#isBlank(CharSequence)
*/
public static boolean isNotBlank(CharSequence str) {
return false == isBlank(str);
}
/**
- * 是否包含空字符串
+ * 指定字符串数组中,是否包含空字符串。
+ * 如果指定的字符串数组的长度为 0,或者其中的任意一个元素是空字符串,则返回 true。
+ *
+ *
+ * 例:
+ *
+ * - {@code StrUtil.hasBlank() // true}
+ * - {@code StrUtil.hasBlank("", null, " ") // true}
+ * - {@code StrUtil.hasBlank("123", " ") // true}
+ * - {@code StrUtil.hasBlank("123", "abc") // false}
+ *
+ *
+ * 注意:该方法与 {@link #isAllBlank(CharSequence...)} 的区别在于:
+ *
+ * hasBlank(CharSequence...) 等价于 {@code isBlank(...) || isBlank(...) || ...}
+ * {@link #isAllBlank(CharSequence...)} 等价于 {@code isBlank(...) && isBlank(...) && ...}
+ *
*
* @param strs 字符串列表
* @return 是否包含空字符串
@@ -376,9 +424,25 @@ public class StrUtil {
}
/**
- * 给定所有字符串是否为空白
+ * 指定字符串数组中的元素,是否全部为空字符串。
+ * 如果指定的字符串数组的长度为 0,或者所有元素都是空字符串,则返回 true。
+ *
*
- * @param strs 字符串
+ * 例:
+ *
+ * - {@code StrUtil.isAllBlank() // true}
+ * - {@code StrUtil.isAllBlank("", null, " ") // true}
+ * - {@code StrUtil.isAllBlank("123", " ") // false}
+ * - {@code StrUtil.isAllBlank("123", "abc") // false}
+ *
+ *
+ * 注意:该方法与 {@link #hasBlank(CharSequence...)} 的区别在于:
+ *
+ * {@link #hasBlank(CharSequence...)} 等价于 {@code isBlank(...) || isBlank(...) || ...}
+ * isAllBlank(CharSequence...) 等价于 {@code isBlank(...) && isBlank(...) && ...}
+ *
+ *
+ * @param strs 字符串列表
* @return 所有字符串是否为空白
*/
public static boolean isAllBlank(CharSequence... strs) {