@Test public void testConsecutiveMappers() { StreamSupplier<Integer> supplier = StreamSupplier.of(1, 2, 3, 4, 5, 6); StreamConsumerToList<Integer> consumer = StreamConsumerToList.create(); StreamMapper<Integer, Integer> squareMapper = StreamMapper.create(input -> input * input); StreamMapper<Integer, Integer> doubleMapper = StreamMapper.create(input -> input * 2); StreamMapper<Integer, Integer> mul10Mapper = StreamMapper.create(input -> input * 10); await(supplier.transformWith(squareMapper).transformWith(doubleMapper) .streamTo(consumer.transformWith(mul10Mapper).transformWith(randomlySuspending()))); assertEquals(asList(20, 80, 180, 320, 500, 720), consumer.getList()); assertEndOfStream(supplier); assertEndOfStream(squareMapper); assertEndOfStream(doubleMapper); assertEndOfStream(mul10Mapper); assertEndOfStream(consumer); }
public static <I, O> StreamMapper<I, O> create(Function<I, O> function) { return new StreamMapper<>(function); }
StreamMapper implements StreamTransformer<I, O> { public static <I, O> StreamMapper<I, O> create(Function<I, O> function) { return new StreamMapper<>(function); } }
StreamMapper implements StreamTransformer<I, O> { public static <I, O> StreamMapper<I, O> create(Function<I, O> function) { return new StreamMapper<>(function); } private  StreamMapper(Function<I, O> function); }
StreamMapper implements StreamTransformer<I, O> { public static <I, O> StreamMapper<I, O> create(Function<I, O> function) { return new StreamMapper<>(function); } private  StreamMapper(Function<I, O> function); static StreamMapper<I, O> create(Function<I, O> function); @Override StreamConsumer<I> getInput(); @Override StreamSupplier<O> getOutput(); }
StreamMapper implements StreamTransformer<I, O> { public static <I, O> StreamMapper<I, O> create(Function<I, O> function) { return new StreamMapper<>(function); } private  StreamMapper(Function<I, O> function); static StreamMapper<I, O> create(Function<I, O> function); @Override StreamConsumer<I> getInput(); @Override StreamSupplier<O> getOutput();  }