添加 MoreStrings。

feature/net-util
ZhouXY108 2023-04-29 17:45:02 +08:00
parent fc848eadc8
commit a932da8b7f
1 changed files with 23 additions and 0 deletions

View File

@ -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");
}
}