use of com.annimon.stream.DoubleStream in project Lightweight-Stream-API by aNNiMON.
the class OnCloseTest method testOnClose.
@Test
public void testOnClose() {
final boolean[] state = new boolean[] { false };
DoubleStream stream = DoubleStream.of(0, 1, 2).onClose(new Runnable() {
@Override
public void run() {
state[0] = true;
}
});
stream.findFirst();
stream.close();
assertTrue(state[0]);
}
use of com.annimon.stream.DoubleStream in project Lightweight-Stream-API by aNNiMON.
the class OnCloseTest method testOnCloseWithOtherOperators.
@Test
public void testOnCloseWithOtherOperators() {
final boolean[] state = new boolean[] { false };
DoubleStream stream = DoubleStream.of(0, 1, 2, 2, 3, 4, 4, 5).filter(new DoublePredicate() {
@Override
public boolean test(double value) {
return value < 4;
}
}).onClose(new Runnable() {
@Override
public void run() {
state[0] = true;
}
}).distinct().limit(2);
stream.findFirst();
stream.close();
assertTrue(state[0]);
}
Aggregations