解决excel读到时空白行rowHanler重复执行的问题。

This commit is contained in:
hellozrh
2023-01-16 15:06:25 +08:00
parent 9994083fe1
commit c660d79bf2
4 changed files with 88 additions and 2 deletions

View File

@@ -1652,6 +1652,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 );
}
}