mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make flatten() support nulls
This commit is contained in:
@@ -304,6 +304,11 @@ public class TreeTraverserTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testFlatten() {
|
||||
JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(3).flatten(i -> i % 2 == 0 ? null : JBIterable.of(i - 1, i));
|
||||
assertEquals(Arrays.asList(0, 1, 2, 3), it.toList());
|
||||
}
|
||||
|
||||
public void testStatefulFilter() {
|
||||
JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(5).filter(new JBIterable.StatefulFilter<Integer>() {
|
||||
int prev;
|
||||
|
||||
@@ -391,7 +391,8 @@ public abstract class JBIterable<E> implements Iterable<E> {
|
||||
public T nextImpl() {
|
||||
if (cur != null && cur.hasNext()) return cur.next();
|
||||
if (!iterator.hasNext()) return stop();
|
||||
cur = fun.fun(iterator.next()).iterator();
|
||||
Iterable<? extends T> next = fun.fun(iterator.next());
|
||||
cur = next == null ? null : next.iterator();
|
||||
return skip();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user