Java Code Examples for com.annimon.stream.Stream#findFirst()
The following examples show how to use
com.annimon.stream.Stream#findFirst() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OnCloseTest.java From Lightweight-Stream-API with Apache License 2.0 | 6 votes |
@Test public void testOnCloseWithOtherOperators() { final boolean[] state = new boolean[] { false }; Stream<Integer> stream = Stream.of(0, 1, 2, 2, 3, 4, 4, 5) .filter(new Predicate<Integer>() { @Override public boolean test(Integer value) { return value < 4; } }) .onClose(new Runnable() { @Override public void run() { state[0] = true; } }) .distinct() .limit(2); stream.findFirst(); stream.close(); assertTrue(state[0]); }
Example 2
Source File: OnCloseTest.java From Lightweight-Stream-API with Apache License 2.0 | 6 votes |
@Test public void testOnCloseWithOtherOperators() { final boolean[] state = new boolean[] { false }; Stream<Integer> stream = Stream.of(0, 1, 2, 2, 3, 4, 4, 5) .filter(new Predicate<Integer>() { @Override public boolean test(Integer value) { return value < 4; } }) .onClose(new Runnable() { @Override public void run() { state[0] = true; } }) .distinct() .limit(2); stream.findFirst(); stream.close(); assertTrue(state[0]); }
Example 3
Source File: OnCloseTest.java From Lightweight-Stream-API with Apache License 2.0 | 5 votes |
@Test public void testOnClose() { final boolean[] state = new boolean[] { false }; Stream<Integer> stream = Stream.of(0, 1, 2) .onClose(new Runnable() { @Override public void run() { state[0] = true; } }); stream.findFirst(); stream.close(); assertTrue(state[0]); }
Example 4
Source File: OnCloseTest.java From Lightweight-Stream-API with Apache License 2.0 | 5 votes |
@Test public void testOnClose() { final boolean[] state = new boolean[] { false }; Stream<Integer> stream = Stream.of(0, 1, 2) .onClose(new Runnable() { @Override public void run() { state[0] = true; } }); stream.findFirst(); stream.close(); assertTrue(state[0]); }