Search in sources :

Example 1 with IntFunction

use of com.annimon.stream.function.IntFunction in project Lightweight-Stream-API by aNNiMON.

the class FilterTest method testFilterWithMap.

@Test
public void testFilterWithMap() {
    final List<Integer> items = Arrays.asList(0, 1, 2, 3, 4);
    IntStream.range(0, items.size()).filter(new IntPredicate() {

        @Override
        public boolean test(int value) {
            return items.get(value) % 2 == 0;
        }
    }).mapToObj(new IntFunction<String>() {

        @Override
        public String apply(int value) {
            return Integer.toString(value);
        }
    }).custom(StreamMatcher.assertElements(contains("0", "2", "4")));
}
Also used : IntPredicate(com.annimon.stream.function.IntPredicate) IntFunction(com.annimon.stream.function.IntFunction) Test(org.junit.Test)

Aggregations

IntFunction (com.annimon.stream.function.IntFunction)1 IntPredicate (com.annimon.stream.function.IntPredicate)1 Test (org.junit.Test)1