mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
!779 解决FilterIter 类中构造器filter 传入null 无法进行迭代器迭代
Merge pull request !779 from Joker7001/v5-dev
This commit is contained in:
commit
5febb65d7c
@ -0,0 +1,31 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* {@link FilterIter} 单元测试
|
||||
* @author chao.wang
|
||||
*/
|
||||
public class FilterIterTest {
|
||||
|
||||
@Test
|
||||
public void checkFilterIter() {
|
||||
Iterator<String> it = ListUtil.of("1", "2").iterator();
|
||||
// filter 为null
|
||||
FilterIter<String> filterIter = new FilterIter<>(it, null);
|
||||
while (filterIter.hasNext()) {
|
||||
System.out.println(filterIter.next());
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
it = ListUtil.of("1", "2").iterator();
|
||||
// filter 不为空
|
||||
filterIter = new FilterIter<>(it, (key) -> key.equals("1"));
|
||||
while (filterIter.hasNext()) {
|
||||
System.out.println(filterIter.next());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user