Search in sources :

Example 1 with IntUnaryOperator

use of java8.util.function.IntUnaryOperator in project streamsupport by stefan-zobel.

the class IntPrimitiveOpsTests method testMap.

public void testMap() {
    long sum = IntStreams.range(1, 10).filter(new IntPredicate() {

        @Override
        public boolean test(int i) {
            return i % 2 == 0;
        }
    }).map(new IntUnaryOperator() {

        @Override
        public int applyAsInt(int i) {
            return i * 2;
        }
    }).sum();
    assertEquals(sum, 40);
}
Also used : IntPredicate(java8.util.function.IntPredicate) IntUnaryOperator(java8.util.function.IntUnaryOperator)

Aggregations

IntPredicate (java8.util.function.IntPredicate)1 IntUnaryOperator (java8.util.function.IntUnaryOperator)1