@Test public void create() { Flowable<Integer> flowable = Flowable.fromArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .subscribeOn(Schedulers.computation()); Optional<Integer> optional = ReactiveStreams.fromPublisher(flowable).filter(i -> i > 5) .findFirst().run().toCompletableFuture().join(); assertThat(optional).contains(6); }
@SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; }
FindFirstStageFactory implements TerminalStageFactory<Stage.FindFirst> { @SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; } }
FindFirstStageFactory implements TerminalStageFactory<Stage.FindFirst> { @SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; }  }
FindFirstStageFactory implements TerminalStageFactory<Stage.FindFirst> { @SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; }  @SuppressWarnings("unchecked") @Override TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage); }
FindFirstStageFactory implements TerminalStageFactory<Stage.FindFirst> { @SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; }  @SuppressWarnings("unchecked") @Override TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage);  }