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