集合类型
CollectionUtils.isNotEmpty (plBillProvLevelDetailVOS)
package org.apache.commons.collections;
//源码
public static boolean isEmpty(Collection coll) {
return (coll == null || coll.isEmpty());
}
package org.springframework.util;
//源码
public static boolean isEmpty(@Nullable Collection<?> collection) {
return (collection == null || collection.isEmpty());
}
两种抽象类中调用的isEmpty()均来自java.util的 boolean isEmpty();方法
package java.util;
//源码
* true if this collection contains no elements
boolean isEmpty();
字符串类型
StringUtils.isNotBlank(v.getMemberId())
判断 null length=0 且 “” " "
package org.apache.commons.lang3;
//源码
* StringUtils.isBlank(null) = true
* StringUtils.isBlank("") = true
* StringUtils.isBlank(" ") = true
* StringUtils.isBlank("bob") = false
* StringUtils.isBlank(" bob ") = false
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) { //判断str是否为null或者str长度是否等于0
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(cs.charAt(i))) { //空白字符的判断
return false;
}
}
return true;
}
StringUtils.isNotEmpty (billVo.getMemberType ())
判断 null “”
package org.springframework.util;
//源码
public static boolean isEmpty(@Nullable Object str) {
return (str == null || "".equals(str));
}
StringUtils.isNotEmpty(" ") //true
StringUtils.isNotBlank(" ") //false