From a932da8b7fadac20b5b4b59b0b6dafadaf8f9e0e Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sat, 29 Apr 2023 17:45:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20MoreStrings=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plusone/commons/util/MoreStrings.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/xyz/zhouxy/plusone/commons/util/MoreStrings.java 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"); + } +}