Checks if an array of Objects is empty or {@code null}. + * + * @param array the array to test + * @return {@code true} if the array is empty or {@code null} + * @since 2.1 + */ + public static boolean isEmpty(final Object[] array) { + return getLength(array) == 0; + } + + //----------------------------------------------------------------------- + /** + *
Returns the length of the specified array. + * This method can deal with {@code Object} arrays and with primitive arrays. + * + *
If the input array is {@code null}, {@code 0} is returned. + * + *
+ * ArrayUtils.getLength(null) = 0 + * ArrayUtils.getLength([]) = 0 + * ArrayUtils.getLength([null]) = 1 + * ArrayUtils.getLength([true, false]) = 2 + * ArrayUtils.getLength([1, 2, 3]) = 3 + * ArrayUtils.getLength(["a", "b", "c"]) = 3 + *+ * + * @param array the array to retrieve the length from, may be null + * @return The length of the array, or {@code 0} if the array is {@code null} + * @throws IllegalArgumentException if the object argument is not an array. + * @since 2.1 + */ + public static int getLength(final Object array) { + if (array == null) { + return 0; + } + return Array.getLength(array); + } + +} diff --git a/common-common/src/main/java/cn/azxo/framework/common/utils/StringUtils.java b/common-common/src/main/java/cn/azxo/framework/common/utils/StringUtils.java new file mode 100644 index 0000000..fae822b --- /dev/null +++ b/common-common/src/main/java/cn/azxo/framework/common/utils/StringUtils.java @@ -0,0 +1,41 @@ +package cn.azxo.framework.common.utils; + +/** + * 字符串工具类 + * + * @author zhaoyong_sh + * @see StringUtils + * @since 2021-04-12 15:29 + */ +public abstract class StringUtils { + + /** + *
Checks if a CharSequence is whitespace, empty ("") or null.
+ * + *
+ * StringUtils.isBlank(null) = true
+ * StringUtils.isBlank("") = true
+ * StringUtils.isBlank(" ") = true
+ * StringUtils.isBlank("bob") = false
+ * StringUtils.isBlank(" bob ") = false
+ *
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {@code true} if the CharSequence is null, empty or whitespace
+ * @since 2.0
+ * @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
+ */
+ public static boolean isBlank(final CharSequence cs) {
+ int strLen;
+ if (cs == null || (strLen = cs.length()) == 0) {
+ return true;
+ }
+ for (int i = 0; i < strLen; i++) {
+ if (Character.isWhitespace(cs.charAt(i)) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index a1012e0..c6e4cba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,11 @@