@@ -118,7 +118,7 @@ public static <T> ParallelFlowable<T> from(Publisher<? extends T> source,
118
118
ObjectHelper .verifyPositive (parallelism , "parallelism" );
119
119
ObjectHelper .verifyPositive (prefetch , "prefetch" );
120
120
121
- return new ParallelFromPublisher <T >(source , parallelism , prefetch );
121
+ return RxJavaPlugins . onAssembly ( new ParallelFromPublisher <T >(source , parallelism , prefetch ) );
122
122
}
123
123
124
124
/**
@@ -132,7 +132,7 @@ public static <T> ParallelFlowable<T> from(Publisher<? extends T> source,
132
132
@ CheckReturnValue
133
133
public final <R > ParallelFlowable <R > map (Function <? super T , ? extends R > mapper ) {
134
134
ObjectHelper .requireNonNull (mapper , "mapper" );
135
- return new ParallelMap <T , R >(this , mapper );
135
+ return RxJavaPlugins . onAssembly ( new ParallelMap <T , R >(this , mapper ) );
136
136
}
137
137
138
138
/**
@@ -145,7 +145,7 @@ public final <R> ParallelFlowable<R> map(Function<? super T, ? extends R> mapper
145
145
@ CheckReturnValue
146
146
public final ParallelFlowable <T > filter (Predicate <? super T > predicate ) {
147
147
ObjectHelper .requireNonNull (predicate , "predicate" );
148
- return new ParallelFilter <T >(this , predicate );
148
+ return RxJavaPlugins . onAssembly ( new ParallelFilter <T >(this , predicate ) );
149
149
}
150
150
151
151
/**
@@ -197,7 +197,7 @@ public final ParallelFlowable<T> runOn(Scheduler scheduler) {
197
197
public final ParallelFlowable <T > runOn (Scheduler scheduler , int prefetch ) {
198
198
ObjectHelper .requireNonNull (scheduler , "scheduler" );
199
199
ObjectHelper .verifyPositive (prefetch , "prefetch" );
200
- return new ParallelRunOn <T >(this , scheduler , prefetch );
200
+ return RxJavaPlugins . onAssembly ( new ParallelRunOn <T >(this , scheduler , prefetch ) );
201
201
}
202
202
203
203
/**
@@ -229,7 +229,7 @@ public final Flowable<T> reduce(BiFunction<T, T, T> reducer) {
229
229
public final <R > ParallelFlowable <R > reduce (Callable <R > initialSupplier , BiFunction <R , ? super T , R > reducer ) {
230
230
ObjectHelper .requireNonNull (initialSupplier , "initialSupplier" );
231
231
ObjectHelper .requireNonNull (reducer , "reducer" );
232
- return new ParallelReduce <T , R >(this , initialSupplier , reducer );
232
+ return RxJavaPlugins . onAssembly ( new ParallelReduce <T , R >(this , initialSupplier , reducer ) );
233
233
}
234
234
235
235
/**
@@ -304,6 +304,8 @@ public final Flowable<T> sorted(Comparator<? super T> comparator) {
304
304
*/
305
305
@ CheckReturnValue
306
306
public final Flowable <T > sorted (Comparator <? super T > comparator , int capacityHint ) {
307
+ ObjectHelper .requireNonNull (comparator , "comparator is null" );
308
+ ObjectHelper .verifyPositive (capacityHint , "capacityHint" );
307
309
int ch = capacityHint / parallelism () + 1 ;
308
310
ParallelFlowable <List <T >> railReduced = reduce (Functions .<T >createArrayList (ch ), ListAddBiConsumer .<T >instance ());
309
311
ParallelFlowable <List <T >> railSorted = railReduced .map (new SorterFunction <T >(comparator ));
@@ -334,6 +336,9 @@ public final Flowable<List<T>> toSortedList(Comparator<? super T> comparator) {
334
336
*/
335
337
@ CheckReturnValue
336
338
public final Flowable <List <T >> toSortedList (Comparator <? super T > comparator , int capacityHint ) {
339
+ ObjectHelper .requireNonNull (comparator , "comparator is null" );
340
+ ObjectHelper .verifyPositive (capacityHint , "capacityHint" );
341
+
337
342
int ch = capacityHint / parallelism () + 1 ;
338
343
ParallelFlowable <List <T >> railReduced = reduce (Functions .<T >createArrayList (ch ), ListAddBiConsumer .<T >instance ());
339
344
ParallelFlowable <List <T >> railSorted = railReduced .map (new SorterFunction <T >(comparator ));
@@ -351,7 +356,8 @@ public final Flowable<List<T>> toSortedList(Comparator<? super T> comparator, in
351
356
*/
352
357
@ CheckReturnValue
353
358
public final ParallelFlowable <T > doOnNext (Consumer <? super T > onNext ) {
354
- return new ParallelPeek <T >(this ,
359
+ ObjectHelper .requireNonNull (onNext , "onNext is null" );
360
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
355
361
onNext ,
356
362
Functions .emptyConsumer (),
357
363
Functions .emptyConsumer (),
@@ -360,7 +366,7 @@ public final ParallelFlowable<T> doOnNext(Consumer<? super T> onNext) {
360
366
Functions .emptyConsumer (),
361
367
Functions .EMPTY_LONG_CONSUMER ,
362
368
Functions .EMPTY_ACTION
363
- );
369
+ )) ;
364
370
}
365
371
366
372
/**
@@ -372,7 +378,8 @@ public final ParallelFlowable<T> doOnNext(Consumer<? super T> onNext) {
372
378
*/
373
379
@ CheckReturnValue
374
380
public final ParallelFlowable <T > doAfterNext (Consumer <? super T > onAfterNext ) {
375
- return new ParallelPeek <T >(this ,
381
+ ObjectHelper .requireNonNull (onAfterNext , "onAfterNext is null" );
382
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
376
383
Functions .emptyConsumer (),
377
384
onAfterNext ,
378
385
Functions .emptyConsumer (),
@@ -381,7 +388,7 @@ public final ParallelFlowable<T> doAfterNext(Consumer<? super T> onAfterNext) {
381
388
Functions .emptyConsumer (),
382
389
Functions .EMPTY_LONG_CONSUMER ,
383
390
Functions .EMPTY_ACTION
384
- );
391
+ )) ;
385
392
}
386
393
387
394
/**
@@ -392,7 +399,8 @@ public final ParallelFlowable<T> doAfterNext(Consumer<? super T> onAfterNext) {
392
399
*/
393
400
@ CheckReturnValue
394
401
public final ParallelFlowable <T > doOnError (Consumer <Throwable > onError ) {
395
- return new ParallelPeek <T >(this ,
402
+ ObjectHelper .requireNonNull (onError , "onError is null" );
403
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
396
404
Functions .emptyConsumer (),
397
405
Functions .emptyConsumer (),
398
406
onError ,
@@ -401,7 +409,7 @@ public final ParallelFlowable<T> doOnError(Consumer<Throwable> onError) {
401
409
Functions .emptyConsumer (),
402
410
Functions .EMPTY_LONG_CONSUMER ,
403
411
Functions .EMPTY_ACTION
404
- );
412
+ )) ;
405
413
}
406
414
407
415
/**
@@ -412,7 +420,8 @@ public final ParallelFlowable<T> doOnError(Consumer<Throwable> onError) {
412
420
*/
413
421
@ CheckReturnValue
414
422
public final ParallelFlowable <T > doOnComplete (Action onComplete ) {
415
- return new ParallelPeek <T >(this ,
423
+ ObjectHelper .requireNonNull (onComplete , "onComplete is null" );
424
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
416
425
Functions .emptyConsumer (),
417
426
Functions .emptyConsumer (),
418
427
Functions .emptyConsumer (),
@@ -421,7 +430,7 @@ public final ParallelFlowable<T> doOnComplete(Action onComplete) {
421
430
Functions .emptyConsumer (),
422
431
Functions .EMPTY_LONG_CONSUMER ,
423
432
Functions .EMPTY_ACTION
424
- );
433
+ )) ;
425
434
}
426
435
427
436
/**
@@ -432,7 +441,8 @@ public final ParallelFlowable<T> doOnComplete(Action onComplete) {
432
441
*/
433
442
@ CheckReturnValue
434
443
public final ParallelFlowable <T > doAfterTerminated (Action onAfterTerminate ) {
435
- return new ParallelPeek <T >(this ,
444
+ ObjectHelper .requireNonNull (onAfterTerminate , "onAfterTerminate is null" );
445
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
436
446
Functions .emptyConsumer (),
437
447
Functions .emptyConsumer (),
438
448
Functions .emptyConsumer (),
@@ -441,7 +451,7 @@ public final ParallelFlowable<T> doAfterTerminated(Action onAfterTerminate) {
441
451
Functions .emptyConsumer (),
442
452
Functions .EMPTY_LONG_CONSUMER ,
443
453
Functions .EMPTY_ACTION
444
- );
454
+ )) ;
445
455
}
446
456
447
457
/**
@@ -452,7 +462,8 @@ public final ParallelFlowable<T> doAfterTerminated(Action onAfterTerminate) {
452
462
*/
453
463
@ CheckReturnValue
454
464
public final ParallelFlowable <T > doOnSubscribe (Consumer <? super Subscription > onSubscribe ) {
455
- return new ParallelPeek <T >(this ,
465
+ ObjectHelper .requireNonNull (onSubscribe , "onSubscribe is null" );
466
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
456
467
Functions .emptyConsumer (),
457
468
Functions .emptyConsumer (),
458
469
Functions .emptyConsumer (),
@@ -461,7 +472,7 @@ public final ParallelFlowable<T> doOnSubscribe(Consumer<? super Subscription> on
461
472
onSubscribe ,
462
473
Functions .EMPTY_LONG_CONSUMER ,
463
474
Functions .EMPTY_ACTION
464
- );
475
+ )) ;
465
476
}
466
477
467
478
/**
@@ -472,7 +483,8 @@ public final ParallelFlowable<T> doOnSubscribe(Consumer<? super Subscription> on
472
483
*/
473
484
@ CheckReturnValue
474
485
public final ParallelFlowable <T > doOnRequest (LongConsumer onRequest ) {
475
- return new ParallelPeek <T >(this ,
486
+ ObjectHelper .requireNonNull (onRequest , "onRequest is null" );
487
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
476
488
Functions .emptyConsumer (),
477
489
Functions .emptyConsumer (),
478
490
Functions .emptyConsumer (),
@@ -481,7 +493,7 @@ public final ParallelFlowable<T> doOnRequest(LongConsumer onRequest) {
481
493
Functions .emptyConsumer (),
482
494
onRequest ,
483
495
Functions .EMPTY_ACTION
484
- );
496
+ )) ;
485
497
}
486
498
487
499
/**
@@ -492,7 +504,8 @@ public final ParallelFlowable<T> doOnRequest(LongConsumer onRequest) {
492
504
*/
493
505
@ CheckReturnValue
494
506
public final ParallelFlowable <T > doOnCancel (Action onCancel ) {
495
- return new ParallelPeek <T >(this ,
507
+ ObjectHelper .requireNonNull (onCancel , "onCancel is null" );
508
+ return RxJavaPlugins .onAssembly (new ParallelPeek <T >(this ,
496
509
Functions .emptyConsumer (),
497
510
Functions .emptyConsumer (),
498
511
Functions .emptyConsumer (),
@@ -501,7 +514,7 @@ public final ParallelFlowable<T> doOnCancel(Action onCancel) {
501
514
Functions .emptyConsumer (),
502
515
Functions .EMPTY_LONG_CONSUMER ,
503
516
onCancel
504
- );
517
+ )) ;
505
518
}
506
519
507
520
/**
@@ -515,7 +528,9 @@ public final ParallelFlowable<T> doOnCancel(Action onCancel) {
515
528
*/
516
529
@ CheckReturnValue
517
530
public final <C > ParallelFlowable <C > collect (Callable <? extends C > collectionSupplier , BiConsumer <? super C , ? super T > collector ) {
518
- return new ParallelCollect <T , C >(this , collectionSupplier , collector );
531
+ ObjectHelper .requireNonNull (collectionSupplier , "collectionSupplier is null" );
532
+ ObjectHelper .requireNonNull (collector , "collector is null" );
533
+ return RxJavaPlugins .onAssembly (new ParallelCollect <T , C >(this , collectionSupplier , collector ));
519
534
}
520
535
521
536
/**
@@ -531,7 +546,7 @@ public static <T> ParallelFlowable<T> fromArray(Publisher<T>... publishers) {
531
546
if (publishers .length == 0 ) {
532
547
throw new IllegalArgumentException ("Zero publishers not supported" );
533
548
}
534
- return new ParallelFromArray <T >(publishers );
549
+ return RxJavaPlugins . onAssembly ( new ParallelFromArray <T >(publishers ) );
535
550
}
536
551
537
552
/**
@@ -562,7 +577,7 @@ public final <U> U to(Function<? super ParallelFlowable<T>, U> converter) {
562
577
*/
563
578
@ CheckReturnValue
564
579
public final <U > ParallelFlowable <U > compose (Function <? super ParallelFlowable <T >, ParallelFlowable <U >> composer ) {
565
- return to (composer );
580
+ return RxJavaPlugins . onAssembly ( to (composer ) );
566
581
}
567
582
568
583
/**
@@ -629,7 +644,10 @@ public final <R> ParallelFlowable<R> flatMap(
629
644
public final <R > ParallelFlowable <R > flatMap (
630
645
Function <? super T , ? extends Publisher <? extends R >> mapper ,
631
646
boolean delayError , int maxConcurrency , int prefetch ) {
632
- return new ParallelFlatMap <T , R >(this , mapper , delayError , maxConcurrency , prefetch );
647
+ ObjectHelper .requireNonNull (mapper , "mapper is null" );
648
+ ObjectHelper .verifyPositive (maxConcurrency , "maxConcurrency" );
649
+ ObjectHelper .verifyPositive (prefetch , "prefetch" );
650
+ return RxJavaPlugins .onAssembly (new ParallelFlatMap <T , R >(this , mapper , delayError , maxConcurrency , prefetch ));
633
651
}
634
652
635
653
/**
@@ -661,7 +679,9 @@ public final <R> ParallelFlowable<R> concatMap(
661
679
public final <R > ParallelFlowable <R > concatMap (
662
680
Function <? super T , ? extends Publisher <? extends R >> mapper ,
663
681
int prefetch ) {
664
- return new ParallelConcatMap <T , R >(this , mapper , prefetch , ErrorMode .IMMEDIATE );
682
+ ObjectHelper .requireNonNull (mapper , "mapper is null" );
683
+ ObjectHelper .verifyPositive (prefetch , "prefetch" );
684
+ return RxJavaPlugins .onAssembly (new ParallelConcatMap <T , R >(this , mapper , prefetch , ErrorMode .IMMEDIATE ));
665
685
}
666
686
667
687
/**
@@ -697,6 +717,9 @@ public final <R> ParallelFlowable<R> concatMapDelayError(
697
717
public final <R > ParallelFlowable <R > concatMapDelayError (
698
718
Function <? super T , ? extends Publisher <? extends R >> mapper ,
699
719
int prefetch , boolean tillTheEnd ) {
700
- return new ParallelConcatMap <T , R >(this , mapper , prefetch , tillTheEnd ? ErrorMode .END : ErrorMode .BOUNDARY );
720
+ ObjectHelper .requireNonNull (mapper , "mapper is null" );
721
+ ObjectHelper .verifyPositive (prefetch , "prefetch" );
722
+ return RxJavaPlugins .onAssembly (new ParallelConcatMap <T , R >(
723
+ this , mapper , prefetch , tillTheEnd ? ErrorMode .END : ErrorMode .BOUNDARY ));
701
724
}
702
725
}
0 commit comments