也许你两个都不知道,也许你除了isEmpty/isNotEmpty/isNotBlank/isBlank外,并不知道还有isAnyEmpty/isNoneEmpty/isAnyBlank/isNoneBlank的存在, come on ,让我们一起来探索org.apache.commons.lang3.StringUtils;这个工具类
NOTE: This method changed in Lang version 2.0. * It no longer trims the CharSequence. * That functionality is available in isBlank().
* * @param cs the CharSequence to check, may be null * @return {@codetrue} if the CharSequence is empty or null * @since3.0Changed signature from isEmpty(String) to isEmpty(CharSequence) */ publicstaticbooleanisEmpty(final CharSequence cs){ return cs == null || cs.length() == 0; }
* * @param css the CharSequences to check, may be null or empty * @return {@codetrue} if none of the CharSequences are empty or null * @since3.2 */ publicstaticbooleanisNoneEmpty(final CharSequence... css){
基于 Spring Boot + MyBatis Plus + Vue & Element 实现的后台管理系统 + 用户小程序,支持 RBAC 动态权限、多租户、数据权限、工作流、三方登录、支付、短信、商城等功能
Checks if a CharSequence is whitespace, empty ("") or null.
* @param cs the CharSequence to check, may be null * @return {@codetrue} if the CharSequence is null, empty or whitespace * @since2.0 * @since3.0Changed signature from isBlank(String) to isBlank(CharSequence) */ publicstaticbooleanisBlank(final CharSequence cs){ int strLen; if (cs == null || (strLen = cs.length()) == 0) { returntrue; } for (int i = 0; i if (Character.isWhitespace(cs.charAt(i)) == false) { returnfalse; } } returntrue; }
Checks if any one of the CharSequences are blank("") or null and not whitespace only..
* @param css the CharSequences to check, may be null or empty * @return {@codetrue} if any of the CharSequences are blank or null or whitespace only * @since3.2 */ publicstaticbooleanisAnyBlank(final CharSequence... css){ if (ArrayUtils.isEmpty(css)) { returntrue; } for (final CharSequence cs : css){ if (isBlank(cs)) { returntrue; } } returnfalse; }
Checks if none of the CharSequences are blank("") or null and whitespace only..
* @param css the CharSequences to check, may be null or empty * @return {@codetrue} if none of the CharSequences are blank or null or whitespace only * @since3.2 */ publicstaticbooleanisNoneBlank(final CharSequence... css){ return !isAnyBlank(css); }
基于 Spring Cloud Alibaba + Gateway + Nacos + RocketMQ + Vue & Element 实现的后台管理系统 + 用户小程序,支持 RBAC 动态权限、多租户、数据权限、工作流、三方登录、支付、短信、商城等功能