|
27 | 27 | import org.reactivestreams.Subscriber;
|
28 | 28 |
|
29 | 29 | import java.util.List;
|
| 30 | +import java.util.Objects; |
30 | 31 | import java.util.Optional;
|
31 | 32 | import java.util.concurrent.CompletionStage;
|
32 | 33 | import java.util.function.BiConsumer;
|
33 |
| -import java.util.function.BiFunction; |
34 | 34 | import java.util.function.BinaryOperator;
|
35 | 35 | import java.util.function.Consumer;
|
36 | 36 | import java.util.function.Function;
|
@@ -241,6 +241,7 @@ public PublisherBuilder<T> dropWhile(Predicate<? super T> predicate) {
|
241 | 241 | * @return A new completion builder.
|
242 | 242 | */
|
243 | 243 | public CompletionRunner<Void> forEach(Consumer<? super T> action) {
|
| 244 | + Objects.requireNonNull(action, "Action must not be null"); |
244 | 245 | return collect(Collector.<T, Void, Void>of(
|
245 | 246 | () -> null,
|
246 | 247 | (n, t) -> action.accept(t),
|
@@ -301,24 +302,6 @@ public CompletionRunner<Optional<T>> reduce(BinaryOperator<T> accumulator) {
|
301 | 302 | return addTerminalStage(new Stage.Collect(Reductions.reduce(accumulator)));
|
302 | 303 | }
|
303 | 304 |
|
304 |
| - /** |
305 |
| - * Perform a reduction on the elements of this stream, using the provided identity value, accumulation function and |
306 |
| - * combiner function. |
307 |
| - * <p> |
308 |
| - * The result of the reduction is returned in the {@link CompletionStage}. |
309 |
| - * |
310 |
| - * @param identity The identity value. |
311 |
| - * @param accumulator The accumulator function. |
312 |
| - * @param combiner The combiner function. |
313 |
| - * @return A new completion builder. |
314 |
| - */ |
315 |
| - public <S> CompletionRunner<S> reduce(S identity, |
316 |
| - BiFunction<S, ? super T, S> accumulator, |
317 |
| - BinaryOperator<S> combiner) { |
318 |
| - |
319 |
| - return addTerminalStage(new Stage.Collect(Reductions.reduce(identity, accumulator, combiner))); |
320 |
| - } |
321 |
| - |
322 | 305 | /**
|
323 | 306 | * Find the first element emitted by the {@link Publisher}, and return it in a
|
324 | 307 | * {@link CompletionStage}.
|
@@ -390,6 +373,7 @@ public CompletionRunner<Void> to(Subscriber<T> subscriber) {
|
390 | 373 | * @return A {@link CompletionRunner} that completes when the stream completes.
|
391 | 374 | */
|
392 | 375 | public <R> CompletionRunner<R> to(SubscriberBuilder<T, R> subscriber) {
|
| 376 | + Objects.requireNonNull(subscriber, "Subscriber must not be null"); |
393 | 377 | return addTerminalStage(new InternalStages.Nested(subscriber.getGraphBuilder()));
|
394 | 378 | }
|
395 | 379 |
|
@@ -536,6 +520,7 @@ public Publisher<T> buildRs() {
|
536 | 520 | * @return A {@link Publisher} that will run this stream.
|
537 | 521 | */
|
538 | 522 | public Publisher<T> buildRs(ReactiveStreamsEngine engine) {
|
| 523 | + Objects.requireNonNull(engine, "Engine must not be null"); |
539 | 524 | return engine.buildPublisher(toGraph());
|
540 | 525 | }
|
541 | 526 |
|
|
0 commit comments