@Test public void create() throws ExecutionException, InterruptedException { Flowable<Integer> flowable = Flowable.fromArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .subscribeOn(Schedulers.computation()); List<Integer> list = ReactiveStreams.fromPublisher(flowable).takeWhile(i -> i < 6).toList().run() .toCompletableFuture().get(); assertThat(list).hasSize(5).containsExactly(1, 2, 3, 4, 5); }
@SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage) { Predicate<I> predicate = (Predicate<I>) Objects.requireNonNull(stage.getPredicate()); return source -> (Flowable<O>) source.takeWhile(predicate::test); }
TakeWhileStageFactory implements ProcessingStageFactory<Stage.TakeWhile> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage) { Predicate<I> predicate = (Predicate<I>) Objects.requireNonNull(stage.getPredicate()); return source -> (Flowable<O>) source.takeWhile(predicate::test); } }
TakeWhileStageFactory implements ProcessingStageFactory<Stage.TakeWhile> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage) { Predicate<I> predicate = (Predicate<I>) Objects.requireNonNull(stage.getPredicate()); return source -> (Flowable<O>) source.takeWhile(predicate::test); }  }
TakeWhileStageFactory implements ProcessingStageFactory<Stage.TakeWhile> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage) { Predicate<I> predicate = (Predicate<I>) Objects.requireNonNull(stage.getPredicate()); return source -> (Flowable<O>) source.takeWhile(predicate::test); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage); }
TakeWhileStageFactory implements ProcessingStageFactory<Stage.TakeWhile> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage) { Predicate<I> predicate = (Predicate<I>) Objects.requireNonNull(stage.getPredicate()); return source -> (Flowable<O>) source.takeWhile(predicate::test); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.TakeWhile stage);  }