!919 修复“sax方式读取excel2003版本,会调用两次doAfterAllAnalysed方法”问题。

Merge pull request !919 from hellozrh/v5-dev
This commit is contained in:
Looly
2023-02-09 11:37:01 +00:00
committed by Gitee
6 changed files with 94 additions and 1 deletions

View File

@@ -1659,6 +1659,35 @@ public class CollUtil {
return collection == null || collection.isEmpty();
}
/**
* 集合是否为空。
* 如果集合中所有元素为null或空串也认为此集合为空。
* @param collection
* @return
*/
public static boolean isBlank(Collection<?> collection) {
if(isEmpty(collection)){
return true;
}
for(Object o: collection){
if(ObjectUtil.isNotEmpty(o)){
return false;
}
}
return true;
}
/**
* 集合是否为非空。
* 集合长度大于0且所有元素中至少有一个不为null或空串。
* @param collection
* @return
*/
public static boolean isNotBlank(Collection<?> collection) {
return false == isBlank(collection);
}
/**
* 如果给定集合为空,返回默认集合
*

View File

@@ -1047,4 +1047,27 @@ public class CollUtilTest {
final Object first = CollUtil.getFirst(nullList);
Assert.assertNull(first);
}
@Test
public void blankTest() {
List<String> strs = new ArrayList<>();
strs.add(null);
strs.add("");
strs.add("");
boolean c = CollUtil.isBlank(strs);
Assert.assertEquals(true, c );
List<String> arrs = new ArrayList<>();
arrs.add(null);
arrs.add("");
arrs.add(" ");
arrs.add("");
arrs.add(" a ");
boolean d = CollUtil.isNotBlank(arrs);
Assert.assertEquals(true, d );
}
}