@Test public void create() throws ExecutionException, InterruptedException { Predicate<Integer> even = i -> i % 2 == 0; Multi<Integer> publisher = Multi.createFrom().items(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .emitOn(executor); List<Integer> list = ReactiveStreams.fromPublisher(publisher).filter(even).toList().run() .toCompletableFuture().get(); assertThat(list).hasSize(5).containsExactly(2, 4, 6, 8, 10); }
@SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.Filter stage) { Objects.requireNonNull(stage); Predicate predicate = Objects.requireNonNull(stage.getPredicate()); return source -> (Multi<O>) source.transform().byFilteringItemsWith(predicate); }
FilterStageFactory implements ProcessingStageFactory<Stage.Filter> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.Filter stage) { Objects.requireNonNull(stage); Predicate predicate = Objects.requireNonNull(stage.getPredicate()); return source -> (Multi<O>) source.transform().byFilteringItemsWith(predicate); } }
FilterStageFactory implements ProcessingStageFactory<Stage.Filter> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.Filter stage) { Objects.requireNonNull(stage); Predicate predicate = Objects.requireNonNull(stage.getPredicate()); return source -> (Multi<O>) source.transform().byFilteringItemsWith(predicate); }  }
FilterStageFactory implements ProcessingStageFactory<Stage.Filter> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.Filter stage) { Objects.requireNonNull(stage); Predicate predicate = Objects.requireNonNull(stage.getPredicate()); return source -> (Multi<O>) source.transform().byFilteringItemsWith(predicate); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.Filter stage); }
FilterStageFactory implements ProcessingStageFactory<Stage.Filter> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.Filter stage) { Objects.requireNonNull(stage); Predicate predicate = Objects.requireNonNull(stage.getPredicate()); return source -> (Multi<O>) source.transform().byFilteringItemsWith(predicate); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.Filter stage);  }