diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/MoreStrings.java b/src/main/java/xyz/zhouxy/plusone/commons/util/MoreStrings.java new file mode 100644 index 0000000..a1bd9e7 --- /dev/null +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/MoreStrings.java @@ -0,0 +1,23 @@ +package xyz.zhouxy.plusone.commons.util; + +import javax.annotation.Nullable; + +public class MoreStrings { + public static boolean hasText(@Nullable String str) { + return (str != null && !str.isEmpty() && containsText(str)); + } + + private static boolean containsText(CharSequence str) { + int strLen = str.length(); + for (int i = 0; i < strLen; i++) { + if (!Character.isWhitespace(str.charAt(i))) { + return true; + } + } + return false; + } + + private MoreStrings() { + throw new IllegalStateException("Utility class"); + } +}