diff --git a/src/main/java/io/reactivex/rxjava3/core/Completable.java b/src/main/java/io/reactivex/rxjava3/core/Completable.java index 46ec666337..00591742e4 100644 --- a/src/main/java/io/reactivex/rxjava3/core/Completable.java +++ b/src/main/java/io/reactivex/rxjava3/core/Completable.java @@ -2335,7 +2335,7 @@ public final void subscribe(@NonNull CompletableObserver observer) { * applied by {@link #subscribe(CompletableObserver)} before this method gets called. * @param observer the CompletableObserver instance, never null */ - protected abstract void subscribeActual(CompletableObserver observer); + protected abstract void subscribeActual(@NonNull CompletableObserver observer); /** * Subscribes a given CompletableObserver (subclass) to this Completable and returns the given diff --git a/src/main/java/io/reactivex/rxjava3/core/Flowable.java b/src/main/java/io/reactivex/rxjava3/core/Flowable.java index c5bdb06b2c..15b1864d8b 100644 --- a/src/main/java/io/reactivex/rxjava3/core/Flowable.java +++ b/src/main/java/io/reactivex/rxjava3/core/Flowable.java @@ -183,7 +183,7 @@ public abstract class Flowable implements Publisher { @NonNull @BackpressureSupport(BackpressureKind.PASS_THROUGH) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable amb(Iterable> sources) { + public static Flowable amb(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new FlowableAmb<>(null, sources)); } @@ -232,6 +232,7 @@ public static Flowable ambArray(Publisher... sources) { * before the Flowable class is loaded. * @return the default internal buffer size. */ + @CheckReturnValue public static int bufferSize() { return BUFFER_SIZE; } @@ -673,6 +674,7 @@ public static Flowable combineLatest( @NonNull BiFunction combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2 }, Functions.toFunction(combiner), bufferSize()); } @@ -723,6 +725,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3 }, Functions.toFunction(combiner), bufferSize()); } @@ -777,6 +780,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4 }, Functions.toFunction(combiner), bufferSize()); } @@ -836,6 +840,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4, source5 }, Functions.toFunction(combiner), bufferSize()); } @@ -899,6 +904,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4, source5, source6 }, Functions.toFunction(combiner), bufferSize()); } @@ -967,6 +973,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4, source5, source6, source7 }, Functions.toFunction(combiner), bufferSize()); } @@ -1039,6 +1046,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4, source5, source6, source7, source8 }, Functions.toFunction(combiner), bufferSize()); } @@ -1116,6 +1124,7 @@ public static Flowable combineLatest( Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new Publisher[] { source1, source2, source3, source4, source5, source6, source7, source8, source9 }, Functions.toFunction(combiner), bufferSize()); } @@ -4735,6 +4744,7 @@ public static Flowable zip( @NonNull BiFunction zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2); } @@ -4796,6 +4806,7 @@ public static Flowable zip( @NonNull BiFunction zipper, boolean delayError) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), delayError, bufferSize(), source1, source2); } @@ -4858,6 +4869,7 @@ public static Flowable zip( @NonNull BiFunction zipper, boolean delayError, int bufferSize) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), delayError, bufferSize, source1, source2); } @@ -4923,6 +4935,7 @@ public static Flowable zip( Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3); } @@ -4993,6 +5006,7 @@ public static Flowable zip( Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4); } @@ -5067,6 +5081,7 @@ public static Flowable zip( Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5); } @@ -5144,6 +5159,7 @@ public static Flowable zip( Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6); } @@ -5226,6 +5242,7 @@ public static Flowable zip( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7); } @@ -5312,6 +5329,7 @@ public static Flowable zip( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7, source8); } @@ -5403,6 +5421,7 @@ public static Flowable zip( Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7, source8, source9); } @@ -6791,7 +6810,7 @@ public final Flowable> buffer(@NonNull Publisher boundaryIndicato @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.NONE) @NonNull - public final Flowable> buffer(@NonNull Publisher boundaryIndicator, final int initialCapacity) { + public final Flowable> buffer(@NonNull Publisher boundaryIndicator, int initialCapacity) { ObjectHelper.verifyPositive(initialCapacity, "initialCapacity"); return buffer(boundaryIndicator, Functions.createArrayList(initialCapacity)); } @@ -12899,7 +12918,7 @@ public final Flowable replay(@NonNull Function, ? ext @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public final Flowable replay(@NonNull Function, ? extends Publisher> selector, final int bufferSize) { + public final Flowable replay(@NonNull Function, ? extends Publisher> selector, int bufferSize) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this, bufferSize, false), selector); @@ -12942,7 +12961,7 @@ public final Flowable replay(@NonNull Function, ? ext @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public final Flowable replay(@NonNull Function, ? extends Publisher> selector, final int bufferSize, boolean eagerTruncate) { + public final Flowable replay(@NonNull Function, ? extends Publisher> selector, int bufferSize, boolean eagerTruncate) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this, bufferSize, eagerTruncate), selector); @@ -13551,7 +13570,7 @@ public final ConnectableFlowable replay(long time, @NonNull TimeUnit unit, @N @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.CUSTOM) @NonNull - public final ConnectableFlowable replay(final long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { + public final ConnectableFlowable replay(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return FlowableReplay.create(this, time, unit, scheduler, eagerTruncate); @@ -16930,7 +16949,7 @@ public final Flowable timeout( @NonNull Publisher firstTimeoutIndicator, @NonNull Function> itemTimeoutIndicator, @NonNull Publisher other) { - Objects.requireNonNull(firstTimeoutIndicator, "firstTimeoutSelector is null"); + Objects.requireNonNull(firstTimeoutIndicator, "firstTimeoutIndicator is null"); Objects.requireNonNull(other, "other is null"); return timeout0(firstTimeoutIndicator, itemTimeoutIndicator, other); } @@ -17152,7 +17171,7 @@ public final Single> toList() { @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) @NonNull - public final Single> toList(final int capacityHint) { + public final Single> toList(int capacityHint) { ObjectHelper.verifyPositive(capacityHint, "capacityHint"); return RxJavaPlugins.onAssembly(new FlowableToListSingle<>(this, Functions.createArrayList(capacityHint))); } @@ -18470,6 +18489,7 @@ public final Flowable> window( @NonNull Function3 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); return withLatestFrom(new Publisher[] { source1, source2 }, f); } @@ -18513,6 +18533,7 @@ public final Flowable> window( Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); return withLatestFrom(new Publisher[] { source1, source2, source3 }, f); } @@ -18559,6 +18580,7 @@ public final Flowable> window( Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); return withLatestFrom(new Publisher[] { source1, source2, source3, source4 }, f); } diff --git a/src/main/java/io/reactivex/rxjava3/core/Maybe.java b/src/main/java/io/reactivex/rxjava3/core/Maybe.java index bb0a6dcbdb..d5336f96ce 100644 --- a/src/main/java/io/reactivex/rxjava3/core/Maybe.java +++ b/src/main/java/io/reactivex/rxjava3/core/Maybe.java @@ -127,7 +127,7 @@ public abstract class Maybe implements MaybeSource { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Maybe amb(final Iterable> sources) { + public static Maybe amb(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new MaybeAmb<>(null, sources)); } @@ -452,7 +452,7 @@ public static Flowable concatArrayEager(@NonNull MaybeSource @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable concatDelayError(Iterable> sources) { + public static Flowable concatDelayError(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return Flowable.fromIterable(sources).concatMapDelayError((Function)MaybeToPublisher.instance()); } @@ -678,7 +678,7 @@ public static Maybe error(@NonNull Throwable exception) { @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Maybe error(@NonNull Supplier supplier) { - Objects.requireNonNull(supplier, "errorSupplier is null"); + Objects.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new MaybeErrorCallable(supplier)); } @@ -788,7 +788,7 @@ public static Maybe fromSingle(@NonNull SingleSource singleSource) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static <@NonNull T> Maybe fromCallable(@NonNull final Callable callable) { + public static <@NonNull T> Maybe fromCallable(@NonNull Callable callable) { Objects.requireNonNull(callable, "callable is null"); return RxJavaPlugins.onAssembly(new MaybeFromCallable(callable)); } @@ -928,7 +928,7 @@ public static Maybe fromRunnable(@NonNull Runnable run) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static <@NonNull T> Maybe fromSupplier(@NonNull final Supplier supplier) { + public static <@NonNull T> Maybe fromSupplier(@NonNull Supplier supplier) { Objects.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new MaybeFromSupplier(supplier)); } @@ -1064,7 +1064,7 @@ public static Flowable merge(@NonNull Publisher Flowable merge(@NonNull Publisher> sources, int maxConcurrency) { - Objects.requireNonNull(sources, "source is null"); + Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); return RxJavaPlugins.onAssembly(new FlowableFlatMapPublisher(sources, MaybeToPublisher.instance(), false, maxConcurrency, 1)); } @@ -1449,7 +1449,7 @@ public static Flowable mergeDelayError(@NonNull Publisher Flowable mergeDelayError(@NonNull Publisher> sources, int maxConcurrency) { - Objects.requireNonNull(sources, "source is null"); + Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); return RxJavaPlugins.onAssembly(new FlowableFlatMapPublisher(sources, MaybeToPublisher.instance(), true, maxConcurrency, 1)); } @@ -1806,7 +1806,7 @@ public static Maybe using(@NonNull Supplier resourceSuppl @NonNull Consumer resourceDisposer, boolean eager) { Objects.requireNonNull(resourceSupplier, "resourceSupplier is null"); Objects.requireNonNull(sourceSupplier, "sourceSupplier is null"); - Objects.requireNonNull(resourceDisposer, "disposer is null"); + Objects.requireNonNull(resourceDisposer, "resourceDisposer is null"); return RxJavaPlugins.onAssembly(new MaybeUsing(resourceSupplier, sourceSupplier, resourceDisposer, eager)); } @@ -1828,7 +1828,7 @@ public static Maybe wrap(@NonNull MaybeSource source) { if (source instanceof Maybe) { return RxJavaPlugins.onAssembly((Maybe)source); } - Objects.requireNonNull(source, "onSubscribe is null"); + Objects.requireNonNull(source, "source is null"); return RxJavaPlugins.onAssembly(new MaybeUnsafeCreate<>(source)); } @@ -1902,6 +1902,7 @@ public static Maybe zip( @NonNull BiFunction zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2); } @@ -1943,6 +1944,7 @@ public static Maybe zip( Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3); } @@ -1989,6 +1991,7 @@ public static Maybe zip( Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4); } @@ -2039,6 +2042,7 @@ public static Maybe zip( Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5); } @@ -2093,6 +2097,7 @@ public static Maybe zip( Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6); } @@ -2152,6 +2157,7 @@ public static Maybe zip( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7); } @@ -2215,6 +2221,7 @@ public static Maybe zip( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7, source8); } @@ -2282,6 +2289,7 @@ public static Maybe zip( Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7, source8, source9); } diff --git a/src/main/java/io/reactivex/rxjava3/core/Observable.java b/src/main/java/io/reactivex/rxjava3/core/Observable.java index 42d7f3d00a..16e1454af3 100644 --- a/src/main/java/io/reactivex/rxjava3/core/Observable.java +++ b/src/main/java/io/reactivex/rxjava3/core/Observable.java @@ -118,7 +118,7 @@ public abstract class Observable implements ObservableSource { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable amb(Iterable> sources) { + public static Observable amb(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new ObservableAmb<>(null, sources)); } @@ -146,7 +146,7 @@ public static Observable amb(Iterable Observable ambArray(ObservableSource... sources) { + public static Observable ambArray(@NonNull ObservableSource... sources) { Objects.requireNonNull(sources, "sources is null"); int len = sources.length; if (len == 0) { @@ -165,6 +165,7 @@ public static Observable ambArray(ObservableSource... source * before the {@link Flowable} class is loaded. * @return the default 'island' size or capacity-increment hint */ + @CheckReturnValue public static int bufferSize() { return Flowable.bufferSize(); } @@ -206,8 +207,10 @@ public static int bufferSize() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable combineLatest(Iterable> sources, - Function combiner) { + @NonNull + public static Observable combineLatest( + @NonNull Iterable> sources, + @NonNull Function combiner) { return combineLatest(sources, combiner, bufferSize()); } @@ -251,8 +254,9 @@ public static Observable combineLatest(Iterable Observable combineLatest(Iterable> sources, - Function combiner, int bufferSize) { + public static Observable combineLatest( + @NonNull Iterable> sources, + @NonNull Function combiner, int bufferSize) { Objects.requireNonNull(sources, "sources is null"); Objects.requireNonNull(combiner, "combiner is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -299,8 +303,10 @@ public static Observable combineLatest(Iterable Observable combineLatestArray(ObservableSource[] sources, - Function combiner) { + @NonNull + public static Observable combineLatestArray( + @NonNull ObservableSource[] sources, + @NonNull Function combiner) { return combineLatestArray(sources, combiner, bufferSize()); } @@ -344,8 +350,9 @@ public static Observable combineLatestArray(ObservableSource Observable combineLatestArray(ObservableSource[] sources, - Function combiner, int bufferSize) { + public static Observable combineLatestArray( + @NonNull ObservableSource[] sources, + @NonNull Function combiner, int bufferSize) { Objects.requireNonNull(sources, "sources is null"); if (sources.length == 0) { return empty(); @@ -391,10 +398,11 @@ public static Observable combineLatestArray(ObservableSource Observable combineLatest( - ObservableSource source1, ObservableSource source2, - BiFunction combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiFunction combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2 }, Functions.toFunction(combiner), bufferSize()); } @@ -434,12 +442,13 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, - Function3 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, + @NonNull Function3 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3 }, Functions.toFunction(combiner), bufferSize()); } @@ -482,13 +491,14 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - Function4 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull Function4 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4 }, Functions.toFunction(combiner), bufferSize()); } @@ -534,15 +544,16 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - ObservableSource source5, - Function5 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull ObservableSource source5, + @NonNull Function5 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4, source5 }, Functions.toFunction(combiner), bufferSize()); } @@ -591,16 +602,17 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - ObservableSource source5, ObservableSource source6, - Function6 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull Function6 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4, source5, source6 }, Functions.toFunction(combiner), bufferSize()); } @@ -652,11 +664,11 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - ObservableSource source5, ObservableSource source6, - ObservableSource source7, - Function7 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, + @NonNull Function7 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -664,6 +676,7 @@ public static Observable combineLatest( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4, source5, source6, source7 }, Functions.toFunction(combiner), bufferSize()); } @@ -718,11 +731,11 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - ObservableSource source5, ObservableSource source6, - ObservableSource source7, ObservableSource source8, - Function8 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, @NonNull ObservableSource source8, + @NonNull Function8 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -731,6 +744,7 @@ public static Observable combineLatest( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4, source5, source6, source7, source8 }, Functions.toFunction(combiner), bufferSize()); } @@ -788,12 +802,12 @@ public static Observable combineLatest( @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable combineLatest( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4, - ObservableSource source5, ObservableSource source6, - ObservableSource source7, ObservableSource source8, - ObservableSource source9, - Function9 combiner) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, @NonNull ObservableSource source8, + @NonNull ObservableSource source9, + @NonNull Function9 combiner) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -803,6 +817,7 @@ public static Observable combineLates Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(combiner, "combiner is null"); return combineLatestArray(new ObservableSource[] { source1, source2, source3, source4, source5, source6, source7, source8, source9 }, Functions.toFunction(combiner), bufferSize()); } @@ -843,8 +858,10 @@ public static Observable combineLates */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable combineLatestDelayError(ObservableSource[] sources, - Function combiner) { + @NonNull + public static Observable combineLatestDelayError( + @NonNull ObservableSource[] sources, + @NonNull Function combiner) { return combineLatestDelayError(sources, combiner, bufferSize()); } @@ -889,8 +906,8 @@ public static Observable combineLatestDelayError(ObservableSource Observable combineLatestDelayError(ObservableSource[] sources, - Function combiner, int bufferSize) { + public static Observable combineLatestDelayError(@NonNull ObservableSource[] sources, + @NonNull Function combiner, int bufferSize) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(combiner, "combiner is null"); if (sources.length == 0) { @@ -939,8 +956,9 @@ public static Observable combineLatestDelayError(ObservableSource Observable combineLatestDelayError(Iterable> sources, - Function combiner) { + @NonNull + public static Observable combineLatestDelayError(@NonNull Iterable> sources, + @NonNull Function combiner) { return combineLatestDelayError(sources, combiner, bufferSize()); } @@ -985,8 +1003,8 @@ public static Observable combineLatestDelayError(Iterable Observable combineLatestDelayError(Iterable> sources, - Function combiner, int bufferSize) { + public static Observable combineLatestDelayError(@NonNull Iterable> sources, + @NonNull Function combiner, int bufferSize) { Objects.requireNonNull(sources, "sources is null"); Objects.requireNonNull(combiner, "combiner is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -1013,7 +1031,7 @@ public static Observable combineLatestDelayError(Iterable Observable concat(Iterable> sources) { + public static Observable concat(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return fromIterable(sources).concatMapDelayError((Function)Functions.identity(), false, bufferSize()); } @@ -1037,7 +1055,8 @@ public static Observable concat(Iterable Observable concat(ObservableSource> sources) { + @NonNull + public static Observable concat(@NonNull ObservableSource> sources) { return concat(sources, bufferSize()); } @@ -1064,7 +1083,7 @@ public static Observable concat(ObservableSource Observable concat(ObservableSource> sources, int prefetch) { + public static Observable concat(@NonNull ObservableSource> sources, int prefetch) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMap(sources, Functions.identity(), prefetch, ErrorMode.IMMEDIATE)); @@ -1089,11 +1108,10 @@ public static Observable concat(ObservableSourceReactiveX operators documentation: Concat */ - @SuppressWarnings("unchecked") @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable concat(ObservableSource source1, ObservableSource source2) { + public static Observable concat(@NonNull ObservableSource source1, ObservableSource source2) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); return concatArray(source1, source2); @@ -1120,13 +1138,12 @@ public static Observable concat(ObservableSource source1, Ob * without interleaving them * @see ReactiveX operators documentation: Concat */ - @SuppressWarnings("unchecked") @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable concat( - ObservableSource source1, ObservableSource source2, - ObservableSource source3) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -1156,13 +1173,12 @@ public static Observable concat( * without interleaving them * @see ReactiveX operators documentation: Concat */ - @SuppressWarnings("unchecked") @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable concat( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -1188,7 +1204,9 @@ public static Observable concat( @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable concatArray(ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable concatArray(@NonNull ObservableSource... sources) { if (sources.length == 0) { return empty(); } @@ -1212,15 +1230,18 @@ public static Observable concatArray(ObservableSource... sou * @return the new Observable instance * @throws NullPointerException if sources is null */ - @SuppressWarnings({ "unchecked" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable concatArrayDelayError(ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable concatArrayDelayError(@NonNull ObservableSource... sources) { if (sources.length == 0) { return empty(); } if (sources.length == 1) { - return (Observable)wrap(sources[0]); + @SuppressWarnings("unchecked") + Observable source = (Observable)wrap(sources[0]); + return source; } return concatDelayError(fromArray(sources)); } @@ -1245,7 +1266,8 @@ public static Observable concatArrayDelayError(ObservableSource Observable concatArrayEager(ObservableSource... sources) { + @NonNull + public static Observable concatArrayEager(@NonNull ObservableSource... sources) { return concatArrayEager(bufferSize(), bufferSize(), sources); } @@ -1272,7 +1294,9 @@ public static Observable concatArrayEager(ObservableSource.. @SuppressWarnings({ "rawtypes", "unchecked" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable concatArrayEager(int maxConcurrency, int prefetch, ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable concatArrayEager(int maxConcurrency, int prefetch, @NonNull ObservableSource... sources) { return fromArray(sources).concatMapEagerDelayError((Function)Functions.identity(), false, maxConcurrency, prefetch); } @@ -1297,7 +1321,8 @@ public static Observable concatArrayEager(int maxConcurrency, int prefetc @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) @SafeVarargs - public static Observable concatArrayEagerDelayError(ObservableSource... sources) { + @NonNull + public static Observable concatArrayEagerDelayError(@NonNull ObservableSource... sources) { return concatArrayEagerDelayError(bufferSize(), bufferSize(), sources); } @@ -1325,7 +1350,9 @@ public static Observable concatArrayEagerDelayError(ObservableSource Observable concatArrayEagerDelayError(int maxConcurrency, int prefetch, ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable concatArrayEagerDelayError(int maxConcurrency, int prefetch, @NonNull ObservableSource... sources) { return fromArray(sources).concatMapEagerDelayError((Function)Functions.identity(), true, maxConcurrency, prefetch); } @@ -1346,7 +1373,7 @@ public static Observable concatArrayEagerDelayError(int maxConcurrency, i @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable concatDelayError(Iterable> sources) { + public static Observable concatDelayError(@NonNull Iterable> sources) { Objects.requireNonNull(sources, "sources is null"); return concatDelayError(fromIterable(sources)); } @@ -1367,7 +1394,8 @@ public static Observable concatDelayError(Iterable Observable concatDelayError(ObservableSource> sources) { + @NonNull + public static Observable concatDelayError(@NonNull ObservableSource> sources) { return concatDelayError(sources, bufferSize(), true); } @@ -1392,7 +1420,7 @@ public static Observable concatDelayError(ObservableSource Observable concatDelayError(ObservableSource> sources, int prefetch, boolean tillTheEnd) { + public static Observable concatDelayError(@NonNull ObservableSource> sources, int prefetch, boolean tillTheEnd) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(prefetch, "prefetch is null"); return RxJavaPlugins.onAssembly(new ObservableConcatMap(sources, Functions.identity(), prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY)); @@ -1417,7 +1445,8 @@ public static Observable concatDelayError(ObservableSource Observable concatEager(ObservableSource> sources) { + @NonNull + public static Observable concatEager(@NonNull ObservableSource> sources) { return concatEager(sources, bufferSize(), bufferSize()); } @@ -1444,7 +1473,8 @@ public static Observable concatEager(ObservableSource Observable concatEager(ObservableSource> sources, int maxConcurrency, int prefetch) { + @NonNull + public static Observable concatEager(@NonNull ObservableSource> sources, int maxConcurrency, int prefetch) { return wrap(sources).concatMapEager((Function)Functions.identity(), maxConcurrency, prefetch); } @@ -1467,7 +1497,8 @@ public static Observable concatEager(ObservableSource Observable concatEager(Iterable> sources) { + @NonNull + public static Observable concatEager(@NonNull Iterable> sources) { return concatEager(sources, bufferSize(), bufferSize()); } @@ -1494,7 +1525,8 @@ public static Observable concatEager(Iterable Observable concatEager(Iterable> sources, int maxConcurrency, int prefetch) { + @NonNull + public static Observable concatEager(@NonNull Iterable> sources, int maxConcurrency, int prefetch) { return fromIterable(sources).concatMapEagerDelayError((Function)Functions.identity(), false, maxConcurrency, prefetch); } @@ -1551,7 +1583,7 @@ public static Observable concatEager(Iterable Observable create(ObservableOnSubscribe source) { + public static Observable create(@NonNull ObservableOnSubscribe source) { Objects.requireNonNull(source, "source is null"); return RxJavaPlugins.onAssembly(new ObservableCreate<>(source)); } @@ -1583,7 +1615,7 @@ public static Observable create(ObservableOnSubscribe source) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable defer(Supplier> supplier) { + public static Observable defer(@NonNull Supplier> supplier) { Objects.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new ObservableDefer<>(supplier)); } @@ -1607,6 +1639,7 @@ public static Observable defer(Supplier Observable empty() { return RxJavaPlugins.onAssembly((Observable) ObservableEmpty.INSTANCE); } @@ -1632,7 +1665,7 @@ public static Observable empty() { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable error(Supplier errorSupplier) { + public static Observable error(@NonNull Supplier errorSupplier) { Objects.requireNonNull(errorSupplier, "errorSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableError(errorSupplier)); } @@ -1658,7 +1691,7 @@ public static Observable error(Supplier errorSupplie @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable error(final Throwable exception) { + public static Observable error(@NonNull Throwable exception) { Objects.requireNonNull(exception, "exception is null"); return error(Functions.justSupplier(exception)); } @@ -1683,7 +1716,7 @@ public static Observable error(final Throwable exception) { @SchedulerSupport(SchedulerSupport.NONE) @NonNull @SafeVarargs - public static Observable fromArray(T... items) { + public static Observable fromArray(@NonNull T... items) { Objects.requireNonNull(items, "items is null"); if (items.length == 0) { return empty(); @@ -1726,7 +1759,7 @@ public static Observable fromArray(T... items) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromCallable(Callable supplier) { + public static Observable fromCallable(@NonNull Callable supplier) { Objects.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new ObservableFromCallable(supplier)); } @@ -1760,7 +1793,7 @@ public static Observable fromCallable(Callable supplier) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromFuture(Future future) { + public static Observable fromFuture(@NonNull Future future) { Objects.requireNonNull(future, "future is null"); return RxJavaPlugins.onAssembly(new ObservableFromFuture(future, 0L, null)); } @@ -1798,7 +1831,7 @@ public static Observable fromFuture(Future future) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromFuture(Future future, long timeout, TimeUnit unit) { + public static Observable fromFuture(@NonNull Future future, long timeout, @NonNull TimeUnit unit) { Objects.requireNonNull(future, "future is null"); Objects.requireNonNull(unit, "unit is null"); return RxJavaPlugins.onAssembly(new ObservableFromFuture(future, timeout, unit)); @@ -1840,7 +1873,7 @@ public static Observable fromFuture(Future future, long time @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable fromFuture(Future future, long timeout, TimeUnit unit, Scheduler scheduler) { + public static Observable fromFuture(@NonNull Future future, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler is null"); Observable o = fromFuture(future, timeout, unit); return o.subscribeOn(scheduler); @@ -1876,7 +1909,7 @@ public static Observable fromFuture(Future future, long time @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable fromFuture(Future future, Scheduler scheduler) { + public static Observable fromFuture(@NonNull Future future, @NonNull Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler is null"); Observable o = fromFuture(future); return o.subscribeOn(scheduler); @@ -1902,7 +1935,7 @@ public static Observable fromFuture(Future future, Scheduler @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromIterable(Iterable source) { + public static Observable fromIterable(@NonNull Iterable source) { Objects.requireNonNull(source, "source is null"); return RxJavaPlugins.onAssembly(new ObservableFromIterable(source)); } @@ -1939,7 +1972,7 @@ public static Observable fromIterable(Iterable source) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromPublisher(Publisher publisher) { + public static Observable fromPublisher(@NonNull Publisher publisher) { Objects.requireNonNull(publisher, "publisher is null"); return RxJavaPlugins.onAssembly(new ObservableFromPublisher(publisher)); } @@ -1976,7 +2009,7 @@ public static Observable fromPublisher(Publisher publisher) @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable fromSupplier(Supplier supplier) { + public static Observable fromSupplier(@NonNull Supplier supplier) { Objects.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new ObservableFromSupplier(supplier)); } @@ -2005,7 +2038,7 @@ public static Observable fromSupplier(Supplier supplier) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(final Consumer> generator) { + public static Observable generate(@NonNull Consumer> generator) { Objects.requireNonNull(generator, "generator is null"); return generate(Functions.nullSupplier(), ObservableInternalHelper.simpleGenerator(generator), Functions.emptyConsumer()); @@ -2037,7 +2070,7 @@ public static Observable generate(final Consumer> generator) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Supplier initialState, final BiConsumer> generator) { + public static Observable generate(@NonNull Supplier initialState, @NonNull BiConsumer> generator) { Objects.requireNonNull(generator, "generator is null"); return generate(initialState, ObservableInternalHelper.simpleBiGenerator(generator), Functions.emptyConsumer()); } @@ -2071,9 +2104,9 @@ public static Observable generate(Supplier initialState, final BiCo @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable generate( - final Supplier initialState, - final BiConsumer> generator, - Consumer disposeState) { + @NonNull Supplier initialState, + @NonNull BiConsumer> generator, + @NonNull Consumer disposeState) { Objects.requireNonNull(generator, "generator is null"); return generate(initialState, ObservableInternalHelper.simpleBiGenerator(generator), disposeState); } @@ -2104,7 +2137,8 @@ public static Observable generate( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Supplier initialState, BiFunction, S> generator) { + @NonNull + public static Observable generate(@NonNull Supplier initialState, @NonNull BiFunction, S> generator) { return generate(initialState, generator, Functions.emptyConsumer()); } @@ -2137,8 +2171,8 @@ public static Observable generate(Supplier initialState, BiFunction @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Supplier initialState, BiFunction, S> generator, - Consumer disposeState) { + public static Observable generate(@NonNull Supplier initialState, @NonNull BiFunction, S> generator, + @NonNull Consumer disposeState) { Objects.requireNonNull(initialState, "initialState is null"); Objects.requireNonNull(generator, "generator is null"); Objects.requireNonNull(disposeState, "disposeState is null"); @@ -2168,7 +2202,8 @@ public static Observable generate(Supplier initialState, BiFunction */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public static Observable interval(long initialDelay, long period, TimeUnit unit) { + @NonNull + public static Observable interval(long initialDelay, long period, @NonNull TimeUnit unit) { return interval(initialDelay, period, unit, Schedulers.computation()); } @@ -2198,7 +2233,7 @@ public static Observable interval(long initialDelay, long period, TimeUnit @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable interval(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) { + public static Observable interval(long initialDelay, long period, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -2223,7 +2258,8 @@ public static Observable interval(long initialDelay, long period, TimeUnit */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public static Observable interval(long period, TimeUnit unit) { + @NonNull + public static Observable interval(long period, @NonNull TimeUnit unit) { return interval(period, period, unit, Schedulers.computation()); } @@ -2248,7 +2284,8 @@ public static Observable interval(long period, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable interval(long period, TimeUnit unit, Scheduler scheduler) { + @NonNull + public static Observable interval(long period, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return interval(period, period, unit, scheduler); } @@ -2271,7 +2308,8 @@ public static Observable interval(long period, TimeUnit unit, Scheduler sc */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public static Observable intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit) { + @NonNull + public static Observable intervalRange(long start, long count, long initialDelay, long period, @NonNull TimeUnit unit) { return intervalRange(start, count, initialDelay, period, unit, Schedulers.computation()); } @@ -2295,7 +2333,7 @@ public static Observable intervalRange(long start, long count, long initia @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit, Scheduler scheduler) { + public static Observable intervalRange(long start, long count, long initialDelay, long period, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { if (count < 0) { throw new IllegalArgumentException("count >= 0 required but it was " + count); } @@ -2345,7 +2383,7 @@ public static Observable intervalRange(long start, long count, long initia @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item) { + public static Observable just(@NonNull T item) { Objects.requireNonNull(item, "item is null"); return RxJavaPlugins.onAssembly(new ObservableJust<>(item)); } @@ -2371,7 +2409,7 @@ public static Observable just(T item) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2) { + public static Observable just(@NonNull T item1, @NonNull T item2) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); @@ -2401,7 +2439,7 @@ public static Observable just(T item1, T item2) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2434,7 +2472,7 @@ public static Observable just(T item1, T item2, T item3) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2470,7 +2508,7 @@ public static Observable just(T item1, T item2, T item3, T item4) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2509,7 +2547,7 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5, T item6) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2551,7 +2589,7 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5, T item6, T item7) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2596,7 +2634,7 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2644,7 +2682,7 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2695,7 +2733,7 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9, T item10) { + public static Observable just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9, @NonNull T item10) { Objects.requireNonNull(item1, "item1 is null"); Objects.requireNonNull(item2, "item2 is null"); Objects.requireNonNull(item3, "item3 is null"); @@ -2753,7 +2791,8 @@ public static Observable just(T item1, T item2, T item3, T item4, T item5 @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable merge(Iterable> sources, int maxConcurrency, int bufferSize) { + @NonNull + public static Observable merge(@NonNull Iterable> sources, int maxConcurrency, int bufferSize) { return fromIterable(sources).flatMap((Function)Functions.identity(), false, maxConcurrency, bufferSize); } @@ -2800,7 +2839,9 @@ public static Observable merge(Iterable Observable mergeArray(int maxConcurrency, int bufferSize, ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable mergeArray(int maxConcurrency, int bufferSize, @NonNull ObservableSource... sources) { return fromArray(sources).flatMap((Function)Functions.identity(), false, maxConcurrency, bufferSize); } @@ -2840,7 +2881,8 @@ public static Observable mergeArray(int maxConcurrency, int bufferSize, O @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable merge(Iterable> sources) { + @NonNull + public static Observable merge(@NonNull Iterable> sources) { return fromIterable(sources).flatMap((Function)Functions.identity()); } @@ -2885,7 +2927,8 @@ public static Observable merge(Iterable Observable merge(Iterable> sources, int maxConcurrency) { + @NonNull + public static Observable merge(@NonNull Iterable> sources, int maxConcurrency) { return fromIterable(sources).flatMap((Function)Functions.identity(), maxConcurrency); } @@ -2926,7 +2969,8 @@ public static Observable merge(Iterable Observable merge(ObservableSource> sources) { + @NonNull + public static Observable merge(@NonNull ObservableSource> sources) { Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), false, Integer.MAX_VALUE, bufferSize())); } @@ -2974,7 +3018,8 @@ public static Observable merge(ObservableSource Observable merge(ObservableSource> sources, int maxConcurrency) { + @NonNull + public static Observable merge(@NonNull ObservableSource> sources, int maxConcurrency) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), false, maxConcurrency, bufferSize())); @@ -3017,7 +3062,8 @@ public static Observable merge(ObservableSource Observable merge(ObservableSource source1, ObservableSource source2) { + @NonNull + public static Observable merge(@NonNull ObservableSource source1, @NonNull ObservableSource source2) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); return fromArray(source1, source2).flatMap((Function)Functions.identity(), false, 2); @@ -3062,7 +3108,10 @@ public static Observable merge(ObservableSource source1, Obs @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable merge(ObservableSource source1, ObservableSource source2, ObservableSource source3) { + @NonNull + public static Observable merge( + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -3110,9 +3159,10 @@ public static Observable merge(ObservableSource source1, Obs @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable merge( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -3155,7 +3205,9 @@ public static Observable merge( @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable mergeArray(ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable mergeArray(@NonNull ObservableSource... sources) { return fromArray(sources).flatMap((Function)Functions.identity(), sources.length); } @@ -3187,7 +3239,8 @@ public static Observable mergeArray(ObservableSource... sour @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable mergeDelayError(Iterable> sources) { + @NonNull + public static Observable mergeDelayError(@NonNull Iterable> sources) { return fromIterable(sources).flatMap((Function)Functions.identity(), true); } @@ -3223,7 +3276,8 @@ public static Observable mergeDelayError(Iterable Observable mergeDelayError(Iterable> sources, int maxConcurrency, int bufferSize) { + @NonNull + public static Observable mergeDelayError(@NonNull Iterable> sources, int maxConcurrency, int bufferSize) { return fromIterable(sources).flatMap((Function)Functions.identity(), true, maxConcurrency, bufferSize); } @@ -3259,7 +3313,9 @@ public static Observable mergeDelayError(Iterable Observable mergeArrayDelayError(int maxConcurrency, int bufferSize, ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable mergeArrayDelayError(int maxConcurrency, int bufferSize, @NonNull ObservableSource... sources) { return fromArray(sources).flatMap((Function)Functions.identity(), true, maxConcurrency, bufferSize); } @@ -3293,7 +3349,8 @@ public static Observable mergeArrayDelayError(int maxConcurrency, int buf @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable mergeDelayError(Iterable> sources, int maxConcurrency) { + @NonNull + public static Observable mergeDelayError(@NonNull Iterable> sources, int maxConcurrency) { return fromIterable(sources).flatMap((Function)Functions.identity(), true, maxConcurrency); } @@ -3325,7 +3382,8 @@ public static Observable mergeDelayError(Iterable Observable mergeDelayError(ObservableSource> sources) { + @NonNull + public static Observable mergeDelayError(@NonNull ObservableSource> sources) { Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), true, Integer.MAX_VALUE, bufferSize())); } @@ -3362,7 +3420,8 @@ public static Observable mergeDelayError(ObservableSource Observable mergeDelayError(ObservableSource> sources, int maxConcurrency) { + @NonNull + public static Observable mergeDelayError(@NonNull ObservableSource> sources, int maxConcurrency) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), true, maxConcurrency, bufferSize())); @@ -3397,7 +3456,9 @@ public static Observable mergeDelayError(ObservableSource Observable mergeDelayError(ObservableSource source1, ObservableSource source2) { + @NonNull + public static Observable mergeDelayError( + @NonNull ObservableSource source1, @NonNull ObservableSource source2) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); return fromArray(source1, source2).flatMap((Function)Functions.identity(), true, 2); @@ -3435,7 +3496,10 @@ public static Observable mergeDelayError(ObservableSource so @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable mergeDelayError(ObservableSource source1, ObservableSource source2, ObservableSource source3) { + @NonNull + public static Observable mergeDelayError( + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -3476,9 +3540,10 @@ public static Observable mergeDelayError(ObservableSource so @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable mergeDelayError( - ObservableSource source1, ObservableSource source2, - ObservableSource source3, ObservableSource source4) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -3514,7 +3579,9 @@ public static Observable mergeDelayError( @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable mergeArrayDelayError(ObservableSource... sources) { + @NonNull + @SafeVarargs + public static Observable mergeArrayDelayError(@NonNull ObservableSource... sources) { return fromArray(sources).flatMap((Function)Functions.identity(), true, sources.length); } @@ -3537,6 +3604,7 @@ public static Observable mergeArrayDelayError(ObservableSource Observable never() { return RxJavaPlugins.onAssembly((Observable) ObservableNever.INSTANCE); } @@ -3562,7 +3630,8 @@ public static Observable never() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable range(final int start, final int count) { + @NonNull + public static Observable range(int start, int count) { if (count < 0) { throw new IllegalArgumentException("count >= 0 required but it was " + count); } @@ -3599,6 +3668,7 @@ public static Observable range(final int start, final int count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable rangeLong(long start, long count) { if (count < 0) { throw new IllegalArgumentException("count >= 0 required but it was " + count); @@ -3641,7 +3711,8 @@ public static Observable rangeLong(long start, long count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Single sequenceEqual(ObservableSource source1, ObservableSource source2) { + @NonNull + public static Single sequenceEqual(@NonNull ObservableSource source1, @NonNull ObservableSource source2) { return sequenceEqual(source1, source2, ObjectHelper.equalsPredicate(), bufferSize()); } @@ -3670,8 +3741,10 @@ public static Single sequenceEqual(ObservableSource so */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Single sequenceEqual(ObservableSource source1, ObservableSource source2, - BiPredicate isEqual) { + @NonNull + public static Single sequenceEqual( + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiPredicate isEqual) { return sequenceEqual(source1, source2, isEqual, bufferSize()); } @@ -3702,8 +3775,10 @@ public static Single sequenceEqual(ObservableSource so */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Single sequenceEqual(ObservableSource source1, ObservableSource source2, - BiPredicate isEqual, int bufferSize) { + @NonNull + public static Single sequenceEqual( + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiPredicate isEqual, int bufferSize) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(isEqual, "isEqual is null"); @@ -3734,7 +3809,8 @@ public static Single sequenceEqual(ObservableSource so */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Single sequenceEqual(ObservableSource source1, ObservableSource source2, + @NonNull + public static Single sequenceEqual(@NonNull ObservableSource source1, @NonNull ObservableSource source2, int bufferSize) { return sequenceEqual(source1, source2, ObjectHelper.equalsPredicate(), bufferSize); } @@ -3769,7 +3845,8 @@ public static Single sequenceEqual(ObservableSource so @SuppressWarnings({ "rawtypes", "unchecked" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable switchOnNext(ObservableSource> sources, int bufferSize) { + @NonNull + public static Observable switchOnNext(@NonNull ObservableSource> sources, int bufferSize) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return RxJavaPlugins.onAssembly(new ObservableSwitchMap(sources, Functions.identity(), bufferSize, false)); @@ -3802,7 +3879,8 @@ public static Observable switchOnNext(ObservableSource Observable switchOnNext(ObservableSource> sources) { + @NonNull + public static Observable switchOnNext(@NonNull ObservableSource> sources) { return switchOnNext(sources, bufferSize()); } @@ -3835,7 +3913,8 @@ public static Observable switchOnNext(ObservableSource Observable switchOnNextDelayError(ObservableSource> sources) { + @NonNull + public static Observable switchOnNextDelayError(@NonNull ObservableSource> sources) { return switchOnNextDelayError(sources, bufferSize()); } @@ -3871,7 +3950,8 @@ public static Observable switchOnNextDelayError(ObservableSource Observable switchOnNextDelayError(ObservableSource> sources, int prefetch) { + @NonNull + public static Observable switchOnNextDelayError(@NonNull ObservableSource> sources, int prefetch) { Objects.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableSwitchMap(sources, Functions.identity(), prefetch, true)); @@ -3895,7 +3975,8 @@ public static Observable switchOnNextDelayError(ObservableSource timer(long delay, TimeUnit unit) { + @NonNull + public static Observable timer(long delay, @NonNull TimeUnit unit) { return timer(delay, unit, Schedulers.computation()); } @@ -3924,7 +4005,8 @@ public static Observable timer(long delay, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public static Observable timer(long delay, TimeUnit unit, Scheduler scheduler) { + @NonNull + public static Observable timer(long delay, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -3945,7 +4027,8 @@ public static Observable timer(long delay, TimeUnit unit, Scheduler schedu */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable unsafeCreate(ObservableSource onSubscribe) { + @NonNull + public static Observable unsafeCreate(@NonNull ObservableSource onSubscribe) { Objects.requireNonNull(onSubscribe, "onSubscribe is null"); if (onSubscribe instanceof Observable) { throw new IllegalArgumentException("unsafeCreate(Observable) should be upgraded"); @@ -3976,7 +4059,11 @@ public static Observable unsafeCreate(ObservableSource onSubscribe) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer) { + @NonNull + public static Observable using( + @NonNull Supplier resourceSupplier, + @NonNull Function> sourceSupplier, + @NonNull Consumer disposer) { return using(resourceSupplier, sourceSupplier, disposer, true); } @@ -4012,7 +4099,11 @@ public static Observable using(Supplier resourceSupplier, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer, boolean eager) { + @NonNull + public static Observable using( + @NonNull Supplier resourceSupplier, + @NonNull Function> sourceSupplier, + @NonNull Consumer disposer, boolean eager) { Objects.requireNonNull(resourceSupplier, "resourceSupplier is null"); Objects.requireNonNull(sourceSupplier, "sourceSupplier is null"); Objects.requireNonNull(disposer, "disposer is null"); @@ -4034,7 +4125,8 @@ public static Observable using(Supplier resourceSupplier, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable wrap(ObservableSource source) { + @NonNull + public static Observable wrap(@NonNull ObservableSource source) { Objects.requireNonNull(source, "source is null"); if (source instanceof Observable) { return RxJavaPlugins.onAssembly((Observable)source); @@ -4089,7 +4181,8 @@ public static Observable wrap(ObservableSource source) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable zip(Iterable> sources, Function zipper) { + @NonNull + public static Observable zip(@NonNull Iterable> sources, @NonNull Function zipper) { Objects.requireNonNull(zipper, "zipper is null"); Objects.requireNonNull(sources, "sources is null"); return RxJavaPlugins.onAssembly(new ObservableZip(null, sources, zipper, bufferSize(), false)); @@ -4147,8 +4240,9 @@ public static Observable zip(Iterable Observable zip(Iterable> sources, - Function zipper, boolean delayError, + @NonNull + public static Observable zip(@NonNull Iterable> sources, + @NonNull Function zipper, boolean delayError, int bufferSize) { Objects.requireNonNull(zipper, "zipper is null"); Objects.requireNonNull(sources, "sources is null"); @@ -4202,11 +4296,13 @@ public static Observable zip(Iterable Observable zip( - ObservableSource source1, ObservableSource source2, - BiFunction zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiFunction zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2); } @@ -4257,11 +4353,13 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, - BiFunction zipper, boolean delayError) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiFunction zipper, boolean delayError) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), delayError, bufferSize(), source1, source2); } @@ -4313,11 +4411,13 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, - BiFunction zipper, boolean delayError, int bufferSize) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull BiFunction zipper, boolean delayError, int bufferSize) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), delayError, bufferSize, source1, source2); } @@ -4371,12 +4471,15 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - Function3 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, + @NonNull Function3 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3); } @@ -4433,14 +4536,16 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, - Function4 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull Function4 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4); } @@ -4500,15 +4605,17 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, ObservableSource source5, - Function5 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, @NonNull ObservableSource source3, + @NonNull ObservableSource source4, @NonNull ObservableSource source5, + @NonNull Function5 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5); } @@ -4570,16 +4677,18 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, ObservableSource source5, ObservableSource source6, - Function6 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, @NonNull ObservableSource source3, + @NonNull ObservableSource source4, @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull Function6 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6); } @@ -4644,11 +4753,12 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, ObservableSource source5, ObservableSource source6, - ObservableSource source7, - Function7 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, @NonNull ObservableSource source3, + @NonNull ObservableSource source4, @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, + @NonNull Function7 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -4656,6 +4766,7 @@ public static Observable zip( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7); } @@ -4723,11 +4834,12 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, ObservableSource source5, ObservableSource source6, - ObservableSource source7, ObservableSource source8, - Function8 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, @NonNull ObservableSource source3, + @NonNull ObservableSource source4, @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, @NonNull ObservableSource source8, + @NonNull Function8 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -4736,6 +4848,7 @@ public static Observable zip( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7, source8); } @@ -4806,11 +4919,12 @@ public static Observable zip( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public static Observable zip( - ObservableSource source1, ObservableSource source2, ObservableSource source3, - ObservableSource source4, ObservableSource source5, ObservableSource source6, - ObservableSource source7, ObservableSource source8, ObservableSource source9, - Function9 zipper) { + @NonNull ObservableSource source1, @NonNull ObservableSource source2, @NonNull ObservableSource source3, + @NonNull ObservableSource source4, @NonNull ObservableSource source5, @NonNull ObservableSource source6, + @NonNull ObservableSource source7, @NonNull ObservableSource source8, @NonNull ObservableSource source9, + @NonNull Function9 zipper) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); @@ -4820,6 +4934,7 @@ public static Observable zip( Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), false, bufferSize(), source1, source2, source3, source4, source5, source6, source7, source8, source9); } @@ -4876,8 +4991,11 @@ public static Observable zip( @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) @SafeVarargs - public static Observable zipArray(Function zipper, - boolean delayError, int bufferSize, ObservableSource... sources) { + @NonNull + public static Observable zipArray( + @NonNull Function zipper, + boolean delayError, int bufferSize, + @NonNull ObservableSource... sources) { if (sources.length == 0) { return empty(); } @@ -4908,7 +5026,8 @@ public static Observable zipArray(Function all(Predicate predicate) { + @NonNull + public final Single all(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableAllSingle<>(this, predicate)); } @@ -4932,7 +5051,8 @@ public final Single all(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable ambWith(ObservableSource other) { + @NonNull + public final Observable ambWith(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return ambArray(this, other); } @@ -4959,7 +5079,8 @@ public final Observable ambWith(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single any(Predicate predicate) { + @NonNull + public final Single any(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableAnySingle<>(this, predicate)); } @@ -4981,6 +5102,7 @@ public final Single any(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final T blockingFirst() { BlockingFirstObserver observer = new BlockingFirstObserver<>(); subscribe(observer); @@ -5009,7 +5131,8 @@ public final T blockingFirst() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final T blockingFirst(T defaultItem) { + @NonNull + public final T blockingFirst(@NonNull T defaultItem) { BlockingFirstObserver observer = new BlockingFirstObserver<>(); subscribe(observer); T v = observer.blockingGet(); @@ -5046,7 +5169,8 @@ public final T blockingFirst(T defaultItem) { * @see #subscribe(Consumer) */ @SchedulerSupport(SchedulerSupport.NONE) - public final void blockingForEach(Consumer onNext) { + @NonNull + public final void blockingForEach(@NonNull Consumer onNext) { Iterator it = blockingIterable().iterator(); while (it.hasNext()) { try { @@ -5073,6 +5197,7 @@ public final void blockingForEach(Consumer onNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Iterable blockingIterable() { return blockingIterable(bufferSize()); } @@ -5092,6 +5217,7 @@ public final Iterable blockingIterable() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Iterable blockingIterable(int bufferSize) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return new BlockingObservableIterable<>(this, bufferSize); @@ -5118,6 +5244,7 @@ public final Iterable blockingIterable(int bufferSize) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final T blockingLast() { BlockingLastObserver observer = new BlockingLastObserver<>(); subscribe(observer); @@ -5150,7 +5277,8 @@ public final T blockingLast() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final T blockingLast(T defaultItem) { + @NonNull + public final T blockingLast(@NonNull T defaultItem) { BlockingLastObserver observer = new BlockingLastObserver<>(); subscribe(observer); T v = observer.blockingGet(); @@ -5178,6 +5306,7 @@ public final T blockingLast(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Iterable blockingLatest() { return new BlockingObservableLatest<>(this); } @@ -5201,7 +5330,8 @@ public final Iterable blockingLatest() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Iterable blockingMostRecent(T initialValue) { + @NonNull + public final Iterable blockingMostRecent(@NonNull T initialValue) { return new BlockingObservableMostRecent<>(this, initialValue); } @@ -5221,6 +5351,7 @@ public final Iterable blockingMostRecent(T initialValue) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Iterable blockingNext() { return new BlockingObservableNext<>(this); } @@ -5244,6 +5375,7 @@ public final Iterable blockingNext() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final T blockingSingle() { T v = singleElement().blockingGet(); if (v == null) { @@ -5275,7 +5407,8 @@ public final T blockingSingle() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final T blockingSingle(T defaultItem) { + @NonNull + public final T blockingSingle(@NonNull T defaultItem) { return single(defaultItem).blockingGet(); } @@ -5300,6 +5433,7 @@ public final T blockingSingle(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Future toFuture() { return subscribeWith(new FutureObserver()); } @@ -5350,7 +5484,7 @@ public final void blockingSubscribe() { * @see #blockingSubscribe(Consumer, Consumer, Action) */ @SchedulerSupport(SchedulerSupport.NONE) - public final void blockingSubscribe(Consumer onNext) { + public final void blockingSubscribe(@NonNull Consumer onNext) { ObservableBlockingSubscribe.subscribe(this, onNext, Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); } @@ -5372,7 +5506,7 @@ public final void blockingSubscribe(Consumer onNext) { * @see #blockingSubscribe(Consumer, Consumer, Action) */ @SchedulerSupport(SchedulerSupport.NONE) - public final void blockingSubscribe(Consumer onNext, Consumer onError) { + public final void blockingSubscribe(@NonNull Consumer onNext, @NonNull Consumer onError) { ObservableBlockingSubscribe.subscribe(this, onNext, onError, Functions.EMPTY_ACTION); } @@ -5394,7 +5528,7 @@ public final void blockingSubscribe(Consumer onNext, Consumer onNext, Consumer onError, Action onComplete) { + public final void blockingSubscribe(@NonNull Consumer onNext, @NonNull Consumer onError, @NonNull Action onComplete) { ObservableBlockingSubscribe.subscribe(this, onNext, onError, onComplete); } @@ -5415,7 +5549,7 @@ public final void blockingSubscribe(Consumer onNext, Consumer observer) { + public final void blockingSubscribe(@NonNull Observer observer) { ObservableBlockingSubscribe.subscribe(this, observer); } @@ -5440,7 +5574,8 @@ public final void blockingSubscribe(Observer observer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer(int count) { + @NonNull + public final Observable<@NonNull List> buffer(int count) { return buffer(count, count); } @@ -5469,7 +5604,8 @@ public final Observable> buffer(int count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer(int count, int skip) { + @NonNull + public final Observable<@NonNull List> buffer(int count, int skip) { return buffer(count, skip, ArrayListSupplier.asSupplier()); } @@ -5502,7 +5638,8 @@ public final Observable> buffer(int count, int skip) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(int count, int skip, Supplier bufferSupplier) { + @NonNull + public final > Observable buffer(int count, int skip, @NonNull Supplier bufferSupplier) { ObjectHelper.verifyPositive(count, "count"); ObjectHelper.verifyPositive(skip, "skip"); Objects.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -5534,7 +5671,8 @@ public final > Observable buffer(int count, i */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(int count, Supplier bufferSupplier) { + @NonNull + public final <@NonNull U extends Collection> Observable buffer(int count, @NonNull Supplier bufferSupplier) { return buffer(count, count, bufferSupplier); } @@ -5564,7 +5702,8 @@ public final > Observable buffer(int count, S */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> buffer(long timespan, long timeskip, TimeUnit unit) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, long timeskip, @NonNull TimeUnit unit) { return buffer(timespan, timeskip, unit, Schedulers.computation(), ArrayListSupplier.asSupplier()); } @@ -5597,7 +5736,8 @@ public final Observable> buffer(long timespan, long timeskip, TimeUnit u */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, long timeskip, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return buffer(timespan, timeskip, unit, scheduler, ArrayListSupplier.asSupplier()); } @@ -5634,7 +5774,8 @@ public final Observable> buffer(long timespan, long timeskip, TimeUnit u */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final > Observable buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Supplier bufferSupplier) { + @NonNull + public final <@NonNull U extends Collection> Observable buffer(long timespan, long timeskip, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Supplier bufferSupplier) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); Objects.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -5666,7 +5807,8 @@ public final > Observable buffer(long timespa */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> buffer(long timespan, TimeUnit unit) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, @NonNull TimeUnit unit) { return buffer(timespan, unit, Schedulers.computation(), Integer.MAX_VALUE); } @@ -5699,7 +5841,8 @@ public final Observable> buffer(long timespan, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> buffer(long timespan, TimeUnit unit, int count) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, @NonNull TimeUnit unit, int count) { return buffer(timespan, unit, Schedulers.computation(), count); } @@ -5734,7 +5877,8 @@ public final Observable> buffer(long timespan, TimeUnit unit, int count) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> buffer(long timespan, TimeUnit unit, Scheduler scheduler, int count) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, int count) { return buffer(timespan, unit, scheduler, count, ArrayListSupplier.asSupplier(), false); } @@ -5775,10 +5919,11 @@ public final Observable> buffer(long timespan, TimeUnit unit, Scheduler */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final > Observable buffer( - long timespan, TimeUnit unit, - Scheduler scheduler, int count, - Supplier bufferSupplier, + @NonNull + public final <@NonNull U extends Collection> Observable buffer( + long timespan, @NonNull TimeUnit unit, + @NonNull Scheduler scheduler, int count, + @NonNull Supplier bufferSupplier, boolean restartTimerOnMaxSize) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -5814,7 +5959,8 @@ public final > Observable buffer( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> buffer(long timespan, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable<@NonNull List> buffer(long timespan, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.asSupplier(), false); } @@ -5844,9 +5990,10 @@ public final Observable> buffer(long timespan, TimeUnit unit, Scheduler */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer( - ObservableSource openingIndicator, - Function> closingIndicator) { + @NonNull + public final Observable<@NonNull List> buffer( + @NonNull ObservableSource openingIndicator, + @NonNull Function> closingIndicator) { return buffer(openingIndicator, closingIndicator, ArrayListSupplier.asSupplier()); } @@ -5880,10 +6027,11 @@ public final Observable> buffer( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer( - ObservableSource openingIndicator, - Function> closingIndicator, - Supplier bufferSupplier) { + @NonNull + public final > Observable buffer( + @NonNull ObservableSource openingIndicator, + @NonNull Function> closingIndicator, + @NonNull Supplier bufferSupplier) { Objects.requireNonNull(openingIndicator, "openingIndicator is null"); Objects.requireNonNull(closingIndicator, "closingIndicator is null"); Objects.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -5916,7 +6064,8 @@ public final > Observable */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer(ObservableSource boundary) { + @NonNull + public final Observable<@NonNull List> buffer(@NonNull ObservableSource boundary) { return buffer(boundary, ArrayListSupplier.asSupplier()); } @@ -5948,7 +6097,8 @@ public final Observable> buffer(ObservableSource boundary) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer(ObservableSource boundary, final int initialCapacity) { + @NonNull + public final Observable<@NonNull List> buffer(@NonNull ObservableSource boundary, int initialCapacity) { ObjectHelper.verifyPositive(initialCapacity, "initialCapacity"); return buffer(boundary, Functions.createArrayList(initialCapacity)); } @@ -5983,7 +6133,8 @@ public final Observable> buffer(ObservableSource boundary, final */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(ObservableSource boundary, Supplier bufferSupplier) { + @NonNull + public final > Observable buffer(@NonNull ObservableSource boundary, @NonNull Supplier bufferSupplier) { Objects.requireNonNull(boundary, "boundary is null"); Objects.requireNonNull(bufferSupplier, "bufferSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableBufferExactBoundary<>(this, boundary, bufferSupplier)); @@ -6039,6 +6190,7 @@ public final > Observable buffer(Observabl */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable cache() { return cacheWithInitialCapacity(16); } @@ -6097,6 +6249,7 @@ public final Observable cache() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable cacheWithInitialCapacity(int initialCapacity) { ObjectHelper.verifyPositive(initialCapacity, "initialCapacity"); return RxJavaPlugins.onAssembly(new ObservableCache<>(this, initialCapacity)); @@ -6122,7 +6275,8 @@ public final Observable cacheWithInitialCapacity(int initialCapacity) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable cast(final Class clazz) { + @NonNull + public final Observable cast(@NonNull Class clazz) { Objects.requireNonNull(clazz, "clazz is null"); return map(Functions.castFunction(clazz)); } @@ -6155,7 +6309,8 @@ public final Observable cast(final Class clazz) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single collect(Supplier initialValueSupplier, BiConsumer collector) { + @NonNull + public final Single collect(@NonNull Supplier initialValueSupplier, @NonNull BiConsumer collector) { Objects.requireNonNull(initialValueSupplier, "initialValueSupplier is null"); Objects.requireNonNull(collector, "collector is null"); return RxJavaPlugins.onAssembly(new ObservableCollectSingle(this, initialValueSupplier, collector)); @@ -6189,7 +6344,8 @@ public final Single collect(Supplier initialValueSupplier, B */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single collectInto(final U initialValue, BiConsumer collector) { + @NonNull + public final Single collectInto(@NonNull U initialValue, @NonNull BiConsumer collector) { Objects.requireNonNull(initialValue, "initialValue is null"); return collect(Functions.justSupplier(initialValue), collector); } @@ -6216,7 +6372,8 @@ public final Single collectInto(final U initialValue, BiConsumer Observable compose(ObservableTransformer composer) { + @NonNull + public final Observable compose(@NonNull ObservableTransformer composer) { return wrap(((ObservableTransformer) Objects.requireNonNull(composer, "composer is null")).apply(this)); } @@ -6246,7 +6403,8 @@ public final Observable compose(ObservableTransformer Observable concatMap(Function> mapper) { + @NonNull + public final Observable concatMap(@NonNull Function> mapper) { return concatMap(mapper, 2); } @@ -6278,7 +6436,8 @@ public final Observable concatMap(Function Observable concatMap(Function> mapper, int prefetch) { + @NonNull + public final Observable concatMap(@NonNull Function> mapper, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); if (this instanceof ScalarSupplier) { @@ -6320,7 +6479,8 @@ public final Observable concatMap(Function Observable concatMap(Function> mapper, int prefetch, Scheduler scheduler) { + @NonNull + public final Observable concatMap(@NonNull Function> mapper, int prefetch, @NonNull Scheduler scheduler) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -6350,7 +6510,8 @@ public final Observable concatMap(Function Observable concatMapDelayError(Function> mapper) { + @NonNull + public final Observable concatMapDelayError(@NonNull Function> mapper) { return concatMapDelayError(mapper, true, bufferSize()); } @@ -6382,7 +6543,8 @@ public final Observable concatMapDelayError(Function Observable concatMapDelayError(Function> mapper, + @NonNull + public final Observable concatMapDelayError(@NonNull Function> mapper, boolean tillTheEnd, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); @@ -6424,8 +6586,9 @@ public final Observable concatMapDelayError(Function Observable concatMapDelayError(Function> mapper, - boolean tillTheEnd, int prefetch, Scheduler scheduler) { + @NonNull + public final Observable concatMapDelayError(@NonNull Function> mapper, + boolean tillTheEnd, int prefetch, @NonNull Scheduler scheduler) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -6453,7 +6616,8 @@ public final Observable concatMapDelayError(Function Observable concatMapEager(Function> mapper) { + @NonNull + public final Observable concatMapEager(@NonNull Function> mapper) { return concatMapEager(mapper, Integer.MAX_VALUE, bufferSize()); } @@ -6480,7 +6644,8 @@ public final Observable concatMapEager(Function Observable concatMapEager(Function> mapper, + @NonNull + public final Observable concatMapEager(@NonNull Function> mapper, int maxConcurrency, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); @@ -6512,7 +6677,8 @@ public final Observable concatMapEager(Function Observable concatMapEagerDelayError(Function> mapper, + @NonNull + public final Observable concatMapEagerDelayError(@NonNull Function> mapper, boolean tillTheEnd) { return concatMapEagerDelayError(mapper, tillTheEnd, Integer.MAX_VALUE, bufferSize()); } @@ -6545,7 +6711,8 @@ public final Observable concatMapEagerDelayError(Function Observable concatMapEagerDelayError(Function> mapper, + @NonNull + public final Observable concatMapEagerDelayError(@NonNull Function> mapper, boolean tillTheEnd, int maxConcurrency, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); @@ -6570,7 +6737,8 @@ public final Observable concatMapEagerDelayError(Function mapper) { + @NonNull + public final Completable concatMapCompletable(@NonNull Function mapper) { return concatMapCompletable(mapper, 2); } @@ -6595,7 +6763,8 @@ public final Completable concatMapCompletable(Function mapper, int capacityHint) { + @NonNull + public final Completable concatMapCompletable(@NonNull Function mapper, int capacityHint) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(capacityHint, "capacityHint"); return RxJavaPlugins.onAssembly(new ObservableConcatMapCompletable<>(this, mapper, ErrorMode.IMMEDIATE, capacityHint)); @@ -6621,7 +6790,8 @@ public final Completable concatMapCompletable(Function mapper) { + @NonNull + public final Completable concatMapCompletableDelayError(@NonNull Function mapper) { return concatMapCompletableDelayError(mapper, true, 2); } @@ -6651,7 +6821,8 @@ public final Completable concatMapCompletableDelayError(Function mapper, boolean tillTheEnd) { + @NonNull + public final Completable concatMapCompletableDelayError(@NonNull Function mapper, boolean tillTheEnd) { return concatMapCompletableDelayError(mapper, tillTheEnd, 2); } @@ -6685,7 +6856,8 @@ public final Completable concatMapCompletableDelayError(Function mapper, boolean tillTheEnd, int prefetch) { + @NonNull + public final Completable concatMapCompletableDelayError(@NonNull Function mapper, boolean tillTheEnd, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMapCompletable<>(this, mapper, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY, prefetch)); @@ -6713,7 +6885,8 @@ public final Completable concatMapCompletableDelayError(Function Observable concatMapIterable(final Function> mapper) { + @NonNull + public final Observable concatMapIterable(@NonNull Function> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableFlattenIterable<>(this, mapper)); } @@ -6742,7 +6915,8 @@ public final Observable concatMapIterable(final Function Observable concatMapIterable(final Function> mapper, int prefetch) { + @NonNull + public final Observable concatMapIterable(@NonNull Function> mapper, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return concatMap(ObservableInternalHelper.flatMapIntoIterable(mapper), prefetch); @@ -6770,7 +6944,8 @@ public final Observable concatMapIterable(final Function Observable concatMapMaybe(Function> mapper) { + @NonNull + public final Observable concatMapMaybe(@NonNull Function> mapper) { return concatMapMaybe(mapper, 2); } @@ -6800,7 +6975,8 @@ public final Observable concatMapMaybe(Function Observable concatMapMaybe(Function> mapper, int prefetch) { + @NonNull + public final Observable concatMapMaybe(@NonNull Function> mapper, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMapMaybe<>(this, mapper, ErrorMode.IMMEDIATE, prefetch)); @@ -6828,7 +7004,8 @@ public final Observable concatMapMaybe(Function Observable concatMapMaybeDelayError(Function> mapper) { + @NonNull + public final Observable concatMapMaybeDelayError(@NonNull Function> mapper) { return concatMapMaybeDelayError(mapper, true, 2); } @@ -6860,7 +7037,8 @@ public final Observable concatMapMaybeDelayError(Function Observable concatMapMaybeDelayError(Function> mapper, boolean tillTheEnd) { + @NonNull + public final Observable concatMapMaybeDelayError(@NonNull Function> mapper, boolean tillTheEnd) { return concatMapMaybeDelayError(mapper, tillTheEnd, 2); } @@ -6895,7 +7073,8 @@ public final Observable concatMapMaybeDelayError(Function Observable concatMapMaybeDelayError(Function> mapper, boolean tillTheEnd, int prefetch) { + @NonNull + public final Observable concatMapMaybeDelayError(@NonNull Function> mapper, boolean tillTheEnd, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMapMaybe<>(this, mapper, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY, prefetch)); @@ -6923,7 +7102,8 @@ public final Observable concatMapMaybeDelayError(Function Observable concatMapSingle(Function> mapper) { + @NonNull + public final Observable concatMapSingle(@NonNull Function> mapper) { return concatMapSingle(mapper, 2); } @@ -6953,7 +7133,8 @@ public final Observable concatMapSingle(Function Observable concatMapSingle(Function> mapper, int prefetch) { + @NonNull + public final Observable concatMapSingle(@NonNull Function> mapper, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMapSingle<>(this, mapper, ErrorMode.IMMEDIATE, prefetch)); @@ -6981,7 +7162,8 @@ public final Observable concatMapSingle(Function Observable concatMapSingleDelayError(Function> mapper) { + @NonNull + public final Observable concatMapSingleDelayError(@NonNull Function> mapper) { return concatMapSingleDelayError(mapper, true, 2); } @@ -7013,7 +7195,8 @@ public final Observable concatMapSingleDelayError(Function Observable concatMapSingleDelayError(Function> mapper, boolean tillTheEnd) { + @NonNull + public final Observable concatMapSingleDelayError(@NonNull Function> mapper, boolean tillTheEnd) { return concatMapSingleDelayError(mapper, tillTheEnd, 2); } @@ -7048,7 +7231,8 @@ public final Observable concatMapSingleDelayError(Function Observable concatMapSingleDelayError(Function> mapper, boolean tillTheEnd, int prefetch) { + @NonNull + public final Observable concatMapSingleDelayError(@NonNull Function> mapper, boolean tillTheEnd, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); return RxJavaPlugins.onAssembly(new ObservableConcatMapSingle<>(this, mapper, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY, prefetch)); @@ -7072,7 +7256,8 @@ public final Observable concatMapSingleDelayError(Function concatWith(ObservableSource other) { + @NonNull + public final Observable concatWith(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return concat(this, other); } @@ -7093,6 +7278,7 @@ public final Observable concatWith(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable concatWith(@NonNull SingleSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableConcatWithSingle<>(this, other)); @@ -7114,6 +7300,7 @@ public final Observable concatWith(@NonNull SingleSource other) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable concatWith(@NonNull MaybeSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableConcatWithMaybe<>(this, other)); @@ -7135,6 +7322,7 @@ public final Observable concatWith(@NonNull MaybeSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable concatWith(@NonNull CompletableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableConcatWithCompletable<>(this, other)); @@ -7158,7 +7346,8 @@ public final Observable concatWith(@NonNull CompletableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single contains(final Object element) { + @NonNull + public final Single contains(@NonNull Object element) { Objects.requireNonNull(element, "element is null"); return any(Functions.equalsWith(element)); } @@ -7179,6 +7368,7 @@ public final Single contains(final Object element) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single count() { return RxJavaPlugins.onAssembly(new ObservableCountSingle<>(this)); } @@ -7211,7 +7401,8 @@ public final Single count() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable debounce(Function> debounceSelector) { + @NonNull + public final Observable debounce(@NonNull Function> debounceSelector) { Objects.requireNonNull(debounceSelector, "debounceSelector is null"); return RxJavaPlugins.onAssembly(new ObservableDebounce<>(this, debounceSelector)); } @@ -7250,7 +7441,8 @@ public final Observable debounce(Function debounce(long timeout, TimeUnit unit) { + @NonNull + public final Observable debounce(long timeout, @NonNull TimeUnit unit) { return debounce(timeout, unit, Schedulers.computation()); } @@ -7290,7 +7482,8 @@ public final Observable debounce(long timeout, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable debounce(long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable debounce(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableDebounceTimed<>(this, timeout, unit, scheduler)); @@ -7314,7 +7507,8 @@ public final Observable debounce(long timeout, TimeUnit unit, Scheduler sched */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable defaultIfEmpty(T defaultItem) { + @NonNull + public final Observable defaultIfEmpty(@NonNull T defaultItem) { Objects.requireNonNull(defaultItem, "defaultItem is null"); return switchIfEmpty(just(defaultItem)); } @@ -7344,7 +7538,8 @@ public final Observable defaultIfEmpty(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable delay(final Function> itemDelay) { + @NonNull + public final Observable delay(@NonNull Function> itemDelay) { Objects.requireNonNull(itemDelay, "itemDelay is null"); return flatMap(ObservableInternalHelper.itemDelay(itemDelay)); } @@ -7368,7 +7563,8 @@ public final Observable delay(final Function delay(long delay, TimeUnit unit) { + @NonNull + public final Observable delay(long delay, @NonNull TimeUnit unit) { return delay(delay, unit, Schedulers.computation(), false); } @@ -7394,7 +7590,8 @@ public final Observable delay(long delay, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable delay(long delay, TimeUnit unit, boolean delayError) { + @NonNull + public final Observable delay(long delay, @NonNull TimeUnit unit, boolean delayError) { return delay(delay, unit, Schedulers.computation(), delayError); } @@ -7419,7 +7616,8 @@ public final Observable delay(long delay, TimeUnit unit, boolean delayError) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable delay(long delay, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable delay(long delay, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return delay(delay, unit, scheduler, false); } @@ -7447,7 +7645,8 @@ public final Observable delay(long delay, TimeUnit unit, Scheduler scheduler) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable delay(long delay, TimeUnit unit, Scheduler scheduler, boolean delayError) { + @NonNull + public final Observable delay(long delay, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -7484,8 +7683,9 @@ public final Observable delay(long delay, TimeUnit unit, Scheduler scheduler, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable delay(ObservableSource subscriptionDelay, - Function> itemDelay) { + @NonNull + public final Observable delay(@NonNull ObservableSource subscriptionDelay, + @NonNull Function> itemDelay) { return delaySubscription(subscriptionDelay).delay(itemDelay); } @@ -7508,7 +7708,8 @@ public final Observable delay(ObservableSource subscriptionDelay, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable delaySubscription(ObservableSource other) { + @NonNull + public final Observable delaySubscription(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableDelaySubscriptionOther<>(this, other)); } @@ -7531,7 +7732,8 @@ public final Observable delaySubscription(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable delaySubscription(long delay, TimeUnit unit) { + @NonNull + public final Observable delaySubscription(long delay, @NonNull TimeUnit unit) { return delaySubscription(delay, unit, Schedulers.computation()); } @@ -7557,7 +7759,8 @@ public final Observable delaySubscription(long delay, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable delaySubscription(long delay, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable delaySubscription(long delay, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return delaySubscription(timer(delay, unit, scheduler)); } @@ -7610,7 +7813,8 @@ public final Observable delaySubscription(long delay, TimeUnit unit, Schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable dematerialize(Function> selector) { + @NonNull + public final Observable dematerialize(@NonNull Function> selector) { Objects.requireNonNull(selector, "selector is null"); return RxJavaPlugins.onAssembly(new ObservableDematerialize<>(this, selector)); } @@ -7648,6 +7852,7 @@ public final Observable dematerialize(Function */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable distinct() { return distinct(Functions.identity(), Functions.createHashSet()); } @@ -7688,7 +7893,8 @@ public final Observable distinct() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable distinct(Function keySelector) { + @NonNull + public final Observable distinct(@NonNull Function keySelector) { return distinct(keySelector, Functions.createHashSet()); } @@ -7719,7 +7925,8 @@ public final Observable distinct(Function keySelector) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable distinct(Function keySelector, Supplier> collectionSupplier) { + @NonNull + public final Observable distinct(@NonNull Function keySelector, @NonNull Supplier> collectionSupplier) { Objects.requireNonNull(keySelector, "keySelector is null"); Objects.requireNonNull(collectionSupplier, "collectionSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableDistinct<>(this, keySelector, collectionSupplier)); @@ -7758,6 +7965,7 @@ public final Observable distinct(Function keySelector, Supp */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable distinctUntilChanged() { return distinctUntilChanged(Functions.identity()); } @@ -7800,7 +8008,8 @@ public final Observable distinctUntilChanged() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable distinctUntilChanged(Function keySelector) { + @NonNull + public final Observable distinctUntilChanged(@NonNull Function keySelector) { Objects.requireNonNull(keySelector, "keySelector is null"); return RxJavaPlugins.onAssembly(new ObservableDistinctUntilChanged<>(this, keySelector, ObjectHelper.equalsPredicate())); } @@ -7834,7 +8043,8 @@ public final Observable distinctUntilChanged(Function keySe */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable distinctUntilChanged(BiPredicate comparer) { + @NonNull + public final Observable distinctUntilChanged(@NonNull BiPredicate comparer) { Objects.requireNonNull(comparer, "comparer is null"); return RxJavaPlugins.onAssembly(new ObservableDistinctUntilChanged<>(this, Functions.identity(), comparer)); } @@ -7858,7 +8068,8 @@ public final Observable distinctUntilChanged(BiPredicate doAfterNext(Consumer onAfterNext) { + @NonNull + public final Observable doAfterNext(@NonNull Consumer onAfterNext) { Objects.requireNonNull(onAfterNext, "onAfterNext is null"); return RxJavaPlugins.onAssembly(new ObservableDoAfterNext<>(this, onAfterNext)); } @@ -7882,7 +8093,8 @@ public final Observable doAfterNext(Consumer onAfterNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doAfterTerminate(Action onFinally) { + @NonNull + public final Observable doAfterTerminate(@NonNull Action onFinally) { Objects.requireNonNull(onFinally, "onFinally is null"); return doOnEach(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, onFinally); } @@ -7909,7 +8121,8 @@ public final Observable doAfterTerminate(Action onFinally) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doFinally(Action onFinally) { + @NonNull + public final Observable doFinally(@NonNull Action onFinally) { Objects.requireNonNull(onFinally, "onFinally is null"); return RxJavaPlugins.onAssembly(new ObservableDoFinally<>(this, onFinally)); } @@ -7937,7 +8150,8 @@ public final Observable doFinally(Action onFinally) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnDispose(Action onDispose) { + @NonNull + public final Observable doOnDispose(@NonNull Action onDispose) { return doOnLifecycle(Functions.emptyConsumer(), onDispose); } @@ -7957,7 +8171,8 @@ public final Observable doOnDispose(Action onDispose) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnComplete(Action onComplete) { + @NonNull + public final Observable doOnComplete(@NonNull Action onComplete) { return doOnEach(Functions.emptyConsumer(), Functions.emptyConsumer(), onComplete, Functions.EMPTY_ACTION); } @@ -7976,7 +8191,8 @@ public final Observable doOnComplete(Action onComplete) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - private Observable doOnEach(Consumer onNext, Consumer onError, Action onComplete, Action onAfterTerminate) { + @NonNull + private Observable doOnEach(@NonNull Consumer onNext, @NonNull Consumer onError, @NonNull Action onComplete, @NonNull Action onAfterTerminate) { Objects.requireNonNull(onNext, "onNext is null"); Objects.requireNonNull(onError, "onError is null"); Objects.requireNonNull(onComplete, "onComplete is null"); @@ -8000,7 +8216,8 @@ private Observable doOnEach(Consumer onNext, Consumer doOnEach(final Consumer> onNotification) { + @NonNull + public final Observable doOnEach(@NonNull Consumer> onNotification) { Objects.requireNonNull(onNotification, "onNotification is null"); return doOnEach( Functions.notificationOnNext(onNotification), @@ -8032,7 +8249,8 @@ public final Observable doOnEach(final Consumer> onNo */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnEach(final Observer observer) { + @NonNull + public final Observable doOnEach(@NonNull Observer observer) { Objects.requireNonNull(observer, "observer is null"); return doOnEach( ObservableInternalHelper.observerOnNext(observer), @@ -8060,7 +8278,8 @@ public final Observable doOnEach(final Observer observer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnError(Consumer onError) { + @NonNull + public final Observable doOnError(@NonNull Consumer onError) { return doOnEach(Functions.emptyConsumer(), onError, Functions.EMPTY_ACTION, Functions.EMPTY_ACTION); } @@ -8083,7 +8302,8 @@ public final Observable doOnError(Consumer onError) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnLifecycle(final Consumer onSubscribe, final Action onDispose) { + @NonNull + public final Observable doOnLifecycle(@NonNull Consumer onSubscribe, @NonNull Action onDispose) { Objects.requireNonNull(onSubscribe, "onSubscribe is null"); Objects.requireNonNull(onDispose, "onDispose is null"); return RxJavaPlugins.onAssembly(new ObservableDoOnLifecycle<>(this, onSubscribe, onDispose)); @@ -8105,7 +8325,8 @@ public final Observable doOnLifecycle(final Consumer onSu */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnNext(Consumer onNext) { + @NonNull + public final Observable doOnNext(@NonNull Consumer onNext) { return doOnEach(onNext, Functions.emptyConsumer(), Functions.EMPTY_ACTION, Functions.EMPTY_ACTION); } @@ -8128,7 +8349,8 @@ public final Observable doOnNext(Consumer onNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnSubscribe(Consumer onSubscribe) { + @NonNull + public final Observable doOnSubscribe(@NonNull Consumer onSubscribe) { return doOnLifecycle(onSubscribe, Functions.EMPTY_ACTION); } @@ -8153,7 +8375,8 @@ public final Observable doOnSubscribe(Consumer onSubscrib */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable doOnTerminate(final Action onTerminate) { + @NonNull + public final Observable doOnTerminate(@NonNull Action onTerminate) { Objects.requireNonNull(onTerminate, "onTerminate is null"); return doOnEach(Functions.emptyConsumer(), Functions.actionConsumer(onTerminate), onTerminate, @@ -8180,6 +8403,7 @@ public final Observable doOnTerminate(final Action onTerminate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Maybe elementAt(long index) { if (index < 0) { throw new IndexOutOfBoundsException("index >= 0 required but it was " + index); @@ -8209,7 +8433,8 @@ public final Maybe elementAt(long index) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single elementAt(long index, T defaultItem) { + @NonNull + public final Single elementAt(long index, @NonNull T defaultItem) { if (index < 0) { throw new IndexOutOfBoundsException("index >= 0 required but it was " + index); } @@ -8237,6 +8462,7 @@ public final Single elementAt(long index, T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single elementAtOrError(long index) { if (index < 0) { throw new IndexOutOfBoundsException("index >= 0 required but it was " + index); @@ -8262,7 +8488,8 @@ public final Single elementAtOrError(long index) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable filter(Predicate predicate) { + @NonNull + public final Observable filter(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableFilter<>(this, predicate)); } @@ -8282,6 +8509,7 @@ public final Observable filter(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Maybe firstElement() { return elementAt(0L); } @@ -8303,7 +8531,8 @@ public final Maybe firstElement() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single first(T defaultItem) { + @NonNull + public final Single first(@NonNull T defaultItem) { return elementAt(0L, defaultItem); } @@ -8322,6 +8551,7 @@ public final Single first(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single firstOrError() { return elementAtOrError(0L); } @@ -8348,7 +8578,8 @@ public final Single firstOrError() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable flatMap(Function> mapper) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper) { return flatMap(mapper, false); } @@ -8377,7 +8608,8 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, boolean delayErrors) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, boolean delayErrors) { return flatMap(mapper, delayErrors, Integer.MAX_VALUE); } @@ -8410,7 +8642,8 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, boolean delayErrors, int maxConcurrency) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, boolean delayErrors, int maxConcurrency) { return flatMap(mapper, delayErrors, maxConcurrency, bufferSize()); } @@ -8445,7 +8678,8 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, + @NonNull + public final Observable flatMap(@NonNull Function> mapper, boolean delayErrors, int maxConcurrency, int bufferSize) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); @@ -8487,10 +8721,11 @@ public final Observable flatMap(Function Observable flatMap( - Function> onNextMapper, - Function> onErrorMapper, - Supplier> onCompleteSupplier) { + @NonNull Function> onNextMapper, + @NonNull Function> onErrorMapper, + @NonNull Supplier> onCompleteSupplier) { Objects.requireNonNull(onNextMapper, "onNextMapper is null"); Objects.requireNonNull(onErrorMapper, "onErrorMapper is null"); Objects.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null"); @@ -8527,10 +8762,11 @@ public final Observable flatMap( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable flatMap( - Function> onNextMapper, - Function> onErrorMapper, - Supplier> onCompleteSupplier, + @NonNull Function> onNextMapper, + @NonNull Function> onErrorMapper, + @NonNull Supplier> onCompleteSupplier, int maxConcurrency) { Objects.requireNonNull(onNextMapper, "onNextMapper is null"); Objects.requireNonNull(onErrorMapper, "onErrorMapper is null"); @@ -8564,7 +8800,8 @@ public final Observable flatMap( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable flatMap(Function> mapper, int maxConcurrency) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, int maxConcurrency) { return flatMap(mapper, false, maxConcurrency, bufferSize()); } @@ -8593,8 +8830,9 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, - BiFunction resultSelector) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, + @NonNull BiFunction resultSelector) { return flatMap(mapper, resultSelector, false, bufferSize(), bufferSize()); } @@ -8626,8 +8864,9 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, - BiFunction combiner, boolean delayErrors) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, + @NonNull BiFunction combiner, boolean delayErrors) { return flatMap(mapper, combiner, delayErrors, bufferSize(), bufferSize()); } @@ -8663,8 +8902,9 @@ public final Observable flatMap(Function Observable flatMap(Function> mapper, - BiFunction combiner, boolean delayErrors, int maxConcurrency) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, + @NonNull BiFunction combiner, boolean delayErrors, int maxConcurrency) { return flatMap(mapper, combiner, delayErrors, maxConcurrency, bufferSize()); } @@ -8702,8 +8942,9 @@ public final Observable flatMap(Function Observable flatMap(final Function> mapper, - final BiFunction combiner, boolean delayErrors, int maxConcurrency, int bufferSize) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, + @NonNull BiFunction combiner, boolean delayErrors, int maxConcurrency, int bufferSize) { Objects.requireNonNull(mapper, "mapper is null"); Objects.requireNonNull(combiner, "combiner is null"); return flatMap(ObservableInternalHelper.flatMapWithCombiner(mapper, combiner), delayErrors, maxConcurrency, bufferSize); @@ -8738,8 +8979,9 @@ public final Observable flatMap(final Function Observable flatMap(Function> mapper, - BiFunction combiner, int maxConcurrency) { + @NonNull + public final Observable flatMap(@NonNull Function> mapper, + @NonNull BiFunction combiner, int maxConcurrency) { return flatMap(mapper, combiner, false, maxConcurrency, bufferSize()); } @@ -8757,7 +8999,8 @@ public final Observable flatMap(Function mapper) { + @NonNull + public final Completable flatMapCompletable(@NonNull Function mapper) { return flatMapCompletable(mapper, false); } @@ -8777,7 +9020,8 @@ public final Completable flatMapCompletable(Function mapper, boolean delayErrors) { + @NonNull + public final Completable flatMapCompletable(@NonNull Function mapper, boolean delayErrors) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableFlatMapCompletableCompletable<>(this, mapper, delayErrors)); } @@ -8803,7 +9047,8 @@ public final Completable flatMapCompletable(Function Observable flatMapIterable(final Function> mapper) { + @NonNull + public final Observable flatMapIterable(@NonNull Function> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableFlattenIterable<>(this, mapper)); } @@ -8834,8 +9079,9 @@ public final Observable flatMapIterable(final Function Observable flatMapIterable(final Function> mapper, - BiFunction resultSelector) { + @NonNull + public final Observable flatMapIterable(@NonNull Function> mapper, + @NonNull BiFunction resultSelector) { Objects.requireNonNull(mapper, "mapper is null"); Objects.requireNonNull(resultSelector, "resultSelector is null"); return flatMap(ObservableInternalHelper.flatMapIntoIterable(mapper), resultSelector, false, bufferSize(), bufferSize()); @@ -8856,7 +9102,8 @@ public final Observable flatMapIterable(final Function Observable flatMapMaybe(Function> mapper) { + @NonNull + public final Observable flatMapMaybe(@NonNull Function> mapper) { return flatMapMaybe(mapper, false); } @@ -8878,7 +9125,8 @@ public final Observable flatMapMaybe(Function Observable flatMapMaybe(Function> mapper, boolean delayErrors) { + @NonNull + public final Observable flatMapMaybe(@NonNull Function> mapper, boolean delayErrors) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableFlatMapMaybe<>(this, mapper, delayErrors)); } @@ -8898,7 +9146,8 @@ public final Observable flatMapMaybe(Function Observable flatMapSingle(Function> mapper) { + @NonNull + public final Observable flatMapSingle(@NonNull Function> mapper) { return flatMapSingle(mapper, false); } @@ -8920,7 +9169,8 @@ public final Observable flatMapSingle(Function Observable flatMapSingle(Function> mapper, boolean delayErrors) { + @NonNull + public final Observable flatMapSingle(@NonNull Function> mapper, boolean delayErrors) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableFlatMapSingle<>(this, mapper, delayErrors)); } @@ -8946,7 +9196,8 @@ public final Observable flatMapSingle(Function onNext) { + @NonNull + public final Disposable forEach(@NonNull Consumer onNext) { return subscribe(onNext); } @@ -8974,7 +9225,8 @@ public final Disposable forEach(Consumer onNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Disposable forEachWhile(Predicate onNext) { + @NonNull + public final Disposable forEachWhile(@NonNull Predicate onNext) { return forEachWhile(onNext, Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); } @@ -8999,7 +9251,8 @@ public final Disposable forEachWhile(Predicate onNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Disposable forEachWhile(Predicate onNext, Consumer onError) { + @NonNull + public final Disposable forEachWhile(@NonNull Predicate onNext, @NonNull Consumer onError) { return forEachWhile(onNext, onError, Functions.EMPTY_ACTION); } @@ -9027,8 +9280,9 @@ public final Disposable forEachWhile(Predicate onNext, Consumer onNext, Consumer onError, - final Action onComplete) { + @NonNull + public final Disposable forEachWhile(@NonNull Predicate onNext, @NonNull Consumer onError, + @NonNull Action onComplete) { Objects.requireNonNull(onNext, "onNext is null"); Objects.requireNonNull(onError, "onError is null"); Objects.requireNonNull(onComplete, "onComplete is null"); @@ -9074,7 +9328,8 @@ public final Disposable forEachWhile(final Predicate onNext, Consumer @SuppressWarnings({ "unchecked", "rawtypes" }) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> groupBy(Function keySelector) { + @NonNull + public final Observable> groupBy(@NonNull Function keySelector) { return groupBy(keySelector, (Function)Functions.identity(), false, bufferSize()); } @@ -9117,7 +9372,8 @@ public final Observable> groupBy(Function Observable> groupBy(Function keySelector, boolean delayError) { + @NonNull + public final Observable> groupBy(@NonNull Function keySelector, boolean delayError) { return groupBy(keySelector, (Function)Functions.identity(), delayError, bufferSize()); } @@ -9160,7 +9416,8 @@ public final Observable> groupBy(Function Observable> groupBy(Function keySelector, + @NonNull + public final Observable> groupBy(@NonNull Function keySelector, Function valueSelector) { return groupBy(keySelector, valueSelector, false, bufferSize()); } @@ -9207,8 +9464,9 @@ public final Observable> groupBy(Function Observable> groupBy(Function keySelector, - Function valueSelector, boolean delayError) { + @NonNull + public final Observable> groupBy(@NonNull Function keySelector, + @NonNull Function valueSelector, boolean delayError) { return groupBy(keySelector, valueSelector, delayError, bufferSize()); } @@ -9256,8 +9514,9 @@ public final Observable> groupBy(Function Observable> groupBy(Function keySelector, - Function valueSelector, + @NonNull + public final Observable> groupBy(@NonNull Function keySelector, + @NonNull Function valueSelector, boolean delayError, int bufferSize) { Objects.requireNonNull(keySelector, "keySelector is null"); Objects.requireNonNull(valueSelector, "valueSelector is null"); @@ -9299,12 +9558,13 @@ public final Observable> groupBy(Function Observable groupJoin( - ObservableSource other, - Function> leftEnd, - Function> rightEnd, - BiFunction, ? extends R> resultSelector - ) { + @NonNull ObservableSource other, + @NonNull Function> leftEnd, + @NonNull Function> rightEnd, + @NonNull BiFunction, ? extends R> resultSelector + ) { Objects.requireNonNull(other, "other is null"); Objects.requireNonNull(leftEnd, "leftEnd is null"); Objects.requireNonNull(rightEnd, "rightEnd is null"); @@ -9330,6 +9590,7 @@ public final Observable groupJoin( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable hide() { return RxJavaPlugins.onAssembly(new ObservableHide<>(this)); } @@ -9348,6 +9609,7 @@ public final Observable hide() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Completable ignoreElements() { return RxJavaPlugins.onAssembly(new ObservableIgnoreElementsCompletable<>(this)); } @@ -9369,6 +9631,7 @@ public final Completable ignoreElements() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single isEmpty() { return all(Functions.alwaysFalse()); } @@ -9406,12 +9669,13 @@ public final Single isEmpty() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable join( - ObservableSource other, - Function> leftEnd, - Function> rightEnd, - BiFunction resultSelector - ) { + @NonNull ObservableSource other, + @NonNull Function> leftEnd, + @NonNull Function> rightEnd, + @NonNull BiFunction resultSelector + ) { Objects.requireNonNull(other, "other is null"); Objects.requireNonNull(leftEnd, "leftEnd is null"); Objects.requireNonNull(rightEnd, "rightEnd is null"); @@ -9436,6 +9700,7 @@ public final Observable join( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Maybe lastElement() { return RxJavaPlugins.onAssembly(new ObservableLastMaybe<>(this)); } @@ -9458,7 +9723,8 @@ public final Maybe lastElement() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single last(T defaultItem) { + @NonNull + public final Single last(@NonNull T defaultItem) { Objects.requireNonNull(defaultItem, "defaultItem is null"); return RxJavaPlugins.onAssembly(new ObservableLastSingle<>(this, defaultItem)); } @@ -9479,6 +9745,7 @@ public final Single last(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single lastOrError() { return RxJavaPlugins.onAssembly(new ObservableLastSingle<>(this, null)); } @@ -9627,7 +9894,8 @@ public final Single lastOrError() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable lift(ObservableOperator lifter) { + @NonNull + public final Observable lift(@NonNull ObservableOperator lifter) { Objects.requireNonNull(lifter, "lifter is null"); return RxJavaPlugins.onAssembly(new ObservableLift(this, lifter)); } @@ -9651,7 +9919,8 @@ public final Observable lift(ObservableOperator l */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable map(Function mapper) { + @NonNull + public final Observable map(@NonNull Function mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableMap(this, mapper)); } @@ -9673,6 +9942,7 @@ public final Observable map(Function mapper) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> materialize() { return RxJavaPlugins.onAssembly(new ObservableMaterialize<>(this)); } @@ -9696,7 +9966,8 @@ public final Observable> materialize() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable mergeWith(ObservableSource other) { + @NonNull + public final Observable mergeWith(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return merge(this, other); } @@ -9719,6 +9990,7 @@ public final Observable mergeWith(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable mergeWith(@NonNull SingleSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableMergeWithSingle<>(this, other)); @@ -9743,6 +10015,7 @@ public final Observable mergeWith(@NonNull SingleSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable mergeWith(@NonNull MaybeSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableMergeWithMaybe<>(this, other)); @@ -9764,6 +10037,7 @@ public final Observable mergeWith(@NonNull MaybeSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable mergeWith(@NonNull CompletableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableMergeWithCompletable<>(this, other)); @@ -9802,7 +10076,8 @@ public final Observable mergeWith(@NonNull CompletableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable observeOn(Scheduler scheduler) { + @NonNull + public final Observable observeOn(@NonNull Scheduler scheduler) { return observeOn(scheduler, false, bufferSize()); } @@ -9840,7 +10115,8 @@ public final Observable observeOn(Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable observeOn(Scheduler scheduler, boolean delayError) { + @NonNull + public final Observable observeOn(@NonNull Scheduler scheduler, boolean delayError) { return observeOn(scheduler, delayError, bufferSize()); } @@ -9879,7 +10155,8 @@ public final Observable observeOn(Scheduler scheduler, boolean delayError) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable observeOn(Scheduler scheduler, boolean delayError, int bufferSize) { + @NonNull + public final Observable observeOn(@NonNull Scheduler scheduler, boolean delayError, int bufferSize) { Objects.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return RxJavaPlugins.onAssembly(new ObservableObserveOn<>(this, scheduler, delayError, bufferSize)); @@ -9902,7 +10179,8 @@ public final Observable observeOn(Scheduler scheduler, boolean delayError, in */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable ofType(final Class clazz) { + @NonNull + public final Observable ofType(@NonNull Class clazz) { Objects.requireNonNull(clazz, "clazz is null"); return filter(Functions.isInstanceOf(clazz)).cast(clazz); } @@ -9938,7 +10216,8 @@ public final Observable ofType(final Class clazz) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable onErrorResumeNext(Function> resumeFunction) { + @NonNull + public final Observable onErrorResumeNext(@NonNull Function> resumeFunction) { Objects.requireNonNull(resumeFunction, "resumeFunction is null"); return RxJavaPlugins.onAssembly(new ObservableOnErrorNext<>(this, resumeFunction)); } @@ -9974,7 +10253,8 @@ public final Observable onErrorResumeNext(Function onErrorResumeWith(final ObservableSource next) { + @NonNull + public final Observable onErrorResumeWith(@NonNull ObservableSource next) { Objects.requireNonNull(next, "next is null"); return onErrorResumeNext(Functions.justFunction(next)); } @@ -10007,7 +10287,8 @@ public final Observable onErrorResumeWith(final ObservableSource */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable onErrorReturn(Function valueSupplier) { + @NonNull + public final Observable onErrorReturn(@NonNull Function valueSupplier) { Objects.requireNonNull(valueSupplier, "valueSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableOnErrorReturn<>(this, valueSupplier)); } @@ -10040,7 +10321,8 @@ public final Observable onErrorReturn(Function onErrorReturnItem(final T item) { + @NonNull + public final Observable onErrorReturnItem(@NonNull T item) { Objects.requireNonNull(item, "item is null"); return onErrorReturn(Functions.justFunction(item)); } @@ -10060,6 +10342,7 @@ public final Observable onErrorReturnItem(final T item) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable onTerminateDetach() { return RxJavaPlugins.onAssembly(new ObservableDetach<>(this)); } @@ -10081,6 +10364,7 @@ public final Observable onTerminateDetach() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final ConnectableObservable publish() { return RxJavaPlugins.onAssembly(new ObservablePublish<>(this)); } @@ -10106,7 +10390,8 @@ public final ConnectableObservable publish() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable publish(Function, ? extends ObservableSource> selector) { + @NonNull + public final Observable publish(@NonNull Function, ? extends ObservableSource> selector) { Objects.requireNonNull(selector, "selector is null"); return RxJavaPlugins.onAssembly(new ObservablePublishSelector<>(this, selector)); } @@ -10141,7 +10426,8 @@ public final Observable publish(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Maybe reduce(BiFunction reducer) { + @NonNull + public final Maybe reduce(@NonNull BiFunction reducer) { Objects.requireNonNull(reducer, "reducer is null"); return RxJavaPlugins.onAssembly(new ObservableReduceMaybe<>(this, reducer)); } @@ -10198,7 +10484,8 @@ public final Maybe reduce(BiFunction reducer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single reduce(R seed, BiFunction reducer) { + @NonNull + public final <@NonNull R> Single reduce(R seed, @NonNull BiFunction reducer) { Objects.requireNonNull(seed, "seed is null"); Objects.requireNonNull(reducer, "reducer is null"); return RxJavaPlugins.onAssembly(new ObservableReduceSeedSingle<>(this, seed, reducer)); @@ -10238,7 +10525,8 @@ public final Single reduce(R seed, BiFunction reducer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single reduceWith(Supplier seedSupplier, BiFunction reducer) { + @NonNull + public final <@NonNull R> Single reduceWith(@NonNull Supplier seedSupplier, @NonNull BiFunction reducer) { Objects.requireNonNull(seedSupplier, "seedSupplier is null"); Objects.requireNonNull(reducer, "reducer is null"); return RxJavaPlugins.onAssembly(new ObservableReduceWithSingle<>(this, seedSupplier, reducer)); @@ -10258,6 +10546,7 @@ public final Single reduceWith(Supplier seedSupplier, BiFunction repeat() { return repeat(Long.MAX_VALUE); } @@ -10283,6 +10572,7 @@ public final Observable repeat() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable repeat(long times) { if (times < 0) { throw new IllegalArgumentException("times >= 0 required but it was " + times); @@ -10314,7 +10604,8 @@ public final Observable repeat(long times) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable repeatUntil(BooleanSupplier stop) { + @NonNull + public final Observable repeatUntil(@NonNull BooleanSupplier stop) { Objects.requireNonNull(stop, "stop is null"); return RxJavaPlugins.onAssembly(new ObservableRepeatUntil<>(this, stop)); } @@ -10340,7 +10631,8 @@ public final Observable repeatUntil(BooleanSupplier stop) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable repeatWhen(final Function, ? extends ObservableSource> handler) { + @NonNull + public final Observable repeatWhen(@NonNull Function, ? extends ObservableSource> handler) { Objects.requireNonNull(handler, "handler is null"); return RxJavaPlugins.onAssembly(new ObservableRepeatWhen<>(this, handler)); } @@ -10363,6 +10655,7 @@ public final Observable repeatWhen(final Function, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final ConnectableObservable replay() { return ObservableReplay.createFrom(this); } @@ -10388,7 +10681,8 @@ public final ConnectableObservable replay() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable replay(Function, ? extends ObservableSource> selector) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector) { Objects.requireNonNull(selector, "selector is null"); return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this), selector); } @@ -10422,7 +10716,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable replay(Function, ? extends ObservableSource> selector, final int bufferSize) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, int bufferSize) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this, bufferSize, false), selector); @@ -10459,7 +10754,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable replay(Function, ? extends ObservableSource> selector, final int bufferSize, boolean eagerTruncate) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, int bufferSize, boolean eagerTruncate) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this, bufferSize, eagerTruncate), selector); @@ -10498,7 +10794,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable replay(Function, ? extends ObservableSource> selector, int bufferSize, long time, TimeUnit unit) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, int bufferSize, long time, @NonNull TimeUnit unit) { return replay(selector, bufferSize, time, unit, Schedulers.computation()); } @@ -10540,7 +10837,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable replay(Function, ? extends ObservableSource> selector, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, int bufferSize, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(unit, "unit is null"); @@ -10588,7 +10886,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable replay(Function, ? extends ObservableSource> selector, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler, boolean eagerTruncate) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, int bufferSize, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { Objects.requireNonNull(selector, "selector is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(unit, "unit is null"); @@ -10624,7 +10923,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable replay(Function, ? extends ObservableSource> selector, long time, TimeUnit unit) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, long time, @NonNull TimeUnit unit) { return replay(selector, time, unit, Schedulers.computation()); } @@ -10658,7 +10958,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable replay(Function, ? extends ObservableSource> selector, final long time, final TimeUnit unit, final Scheduler scheduler) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(selector, "selector is null"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -10697,7 +10998,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable replay(Function, ? extends ObservableSource> selector, final long time, final TimeUnit unit, final Scheduler scheduler, boolean eagerTruncate) { + @NonNull + public final Observable replay(@NonNull Function, ? extends ObservableSource> selector, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { Objects.requireNonNull(selector, "selector is null"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -10730,7 +11032,8 @@ public final Observable replay(Function, ? extends */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final ConnectableObservable replay(final int bufferSize) { + @NonNull + public final ConnectableObservable replay(int bufferSize) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return ObservableReplay.create(this, bufferSize, false); } @@ -10762,7 +11065,8 @@ public final ConnectableObservable replay(final int bufferSize) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final ConnectableObservable replay(final int bufferSize, boolean eagerTruncate) { + @NonNull + public final ConnectableObservable replay(int bufferSize, boolean eagerTruncate) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return ObservableReplay.create(this, bufferSize, eagerTruncate); } @@ -10798,7 +11102,8 @@ public final ConnectableObservable replay(final int bufferSize, boolean eager */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final ConnectableObservable replay(int bufferSize, long time, TimeUnit unit) { + @NonNull + public final ConnectableObservable replay(int bufferSize, long time, @NonNull TimeUnit unit) { return replay(bufferSize, time, unit, Schedulers.computation()); } @@ -10837,7 +11142,8 @@ public final ConnectableObservable replay(int bufferSize, long time, TimeUnit */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final ConnectableObservable replay(final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { + @NonNull + public final ConnectableObservable replay(int bufferSize, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -10881,7 +11187,8 @@ public final ConnectableObservable replay(final int bufferSize, final long ti */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final ConnectableObservable replay(final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler, boolean eagerTruncate) { + @NonNull + public final ConnectableObservable replay(int bufferSize, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -10910,7 +11217,8 @@ public final ConnectableObservable replay(final int bufferSize, final long ti */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final ConnectableObservable replay(long time, TimeUnit unit) { + @NonNull + public final ConnectableObservable replay(long time, @NonNull TimeUnit unit) { return replay(time, unit, Schedulers.computation()); } @@ -10942,7 +11250,8 @@ public final ConnectableObservable replay(long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final ConnectableObservable replay(final long time, final TimeUnit unit, final Scheduler scheduler) { + @NonNull + public final ConnectableObservable replay(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return ObservableReplay.create(this, time, unit, scheduler, false); @@ -10978,7 +11287,8 @@ public final ConnectableObservable replay(final long time, final TimeUnit uni */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final ConnectableObservable replay(final long time, final TimeUnit unit, final Scheduler scheduler, boolean eagerTruncate) { + @NonNull + public final ConnectableObservable replay(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return ObservableReplay.create(this, time, unit, scheduler, eagerTruncate); @@ -11007,6 +11317,7 @@ public final ConnectableObservable replay(final long time, final TimeUnit uni */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable retry() { return retry(Long.MAX_VALUE, Functions.alwaysTrue()); } @@ -11030,7 +11341,8 @@ public final Observable retry() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable retry(BiPredicate predicate) { + @NonNull + public final Observable retry(@NonNull BiPredicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableRetryBiPredicate<>(this, predicate)); @@ -11062,6 +11374,7 @@ public final Observable retry(BiPredicate */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable retry(long times) { return retry(times, Functions.alwaysTrue()); } @@ -11080,7 +11393,8 @@ public final Observable retry(long times) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable retry(long times, Predicate predicate) { + @NonNull + public final Observable retry(long times, @NonNull Predicate predicate) { if (times < 0) { throw new IllegalArgumentException("times >= 0 required but it was " + times); } @@ -11103,7 +11417,8 @@ public final Observable retry(long times, Predicate predic */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable retry(Predicate predicate) { + @NonNull + public final Observable retry(@NonNull Predicate predicate) { return retry(Long.MAX_VALUE, predicate); } @@ -11120,7 +11435,8 @@ public final Observable retry(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable retryUntil(final BooleanSupplier stop) { + @NonNull + public final Observable retryUntil(@NonNull BooleanSupplier stop) { Objects.requireNonNull(stop, "stop is null"); return retry(Long.MAX_VALUE, Functions.predicateReverseFor(stop)); } @@ -11200,8 +11516,9 @@ public final Observable retryUntil(final BooleanSupplier stop) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable retryWhen( - final Function, ? extends ObservableSource> handler) { + @NonNull Function, ? extends ObservableSource> handler) { Objects.requireNonNull(handler, "handler is null"); return RxJavaPlugins.onAssembly(new ObservableRetryWhen<>(this, handler)); } @@ -11219,7 +11536,8 @@ public final Observable retryWhen( * @throws NullPointerException if s is null */ @SchedulerSupport(SchedulerSupport.NONE) - public final void safeSubscribe(Observer observer) { + @NonNull + public final void safeSubscribe(@NonNull Observer observer) { Objects.requireNonNull(observer, "observer is null"); if (observer instanceof SafeObserver) { subscribe(observer); @@ -11249,7 +11567,8 @@ public final void safeSubscribe(Observer observer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable sample(long period, TimeUnit unit) { + @NonNull + public final Observable sample(long period, @NonNull TimeUnit unit) { return sample(period, unit, Schedulers.computation()); } @@ -11280,7 +11599,8 @@ public final Observable sample(long period, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable sample(long period, TimeUnit unit, boolean emitLast) { + @NonNull + public final Observable sample(long period, @NonNull TimeUnit unit, boolean emitLast) { return sample(period, unit, Schedulers.computation(), emitLast); } @@ -11307,7 +11627,8 @@ public final Observable sample(long period, TimeUnit unit, boolean emitLast) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable sample(long period, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable sample(long period, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableSampleTimed<>(this, period, unit, scheduler, false)); @@ -11343,7 +11664,8 @@ public final Observable sample(long period, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable sample(long period, TimeUnit unit, Scheduler scheduler, boolean emitLast) { + @NonNull + public final Observable sample(long period, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableSampleTimed<>(this, period, unit, scheduler, emitLast)); @@ -11369,7 +11691,8 @@ public final Observable sample(long period, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable sample(ObservableSource sampler) { + @NonNull + public final Observable sample(@NonNull ObservableSource sampler) { Objects.requireNonNull(sampler, "sampler is null"); return RxJavaPlugins.onAssembly(new ObservableSampleWithObservable<>(this, sampler, false)); } @@ -11401,7 +11724,8 @@ public final Observable sample(ObservableSource sampler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable sample(ObservableSource sampler, boolean emitLast) { + @NonNull + public final Observable sample(@NonNull ObservableSource sampler, boolean emitLast) { Objects.requireNonNull(sampler, "sampler is null"); return RxJavaPlugins.onAssembly(new ObservableSampleWithObservable<>(this, sampler, emitLast)); } @@ -11429,7 +11753,8 @@ public final Observable sample(ObservableSource sampler, boolean emitL */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable scan(BiFunction accumulator) { + @NonNull + public final Observable scan(@NonNull BiFunction accumulator) { Objects.requireNonNull(accumulator, "accumulator is null"); return RxJavaPlugins.onAssembly(new ObservableScan<>(this, accumulator)); } @@ -11478,7 +11803,8 @@ public final Observable scan(BiFunction accumulator) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable scan(final R initialValue, BiFunction accumulator) { + @NonNull + public final Observable scan(@NonNull R initialValue, @NonNull BiFunction accumulator) { Objects.requireNonNull(initialValue, "initialValue is null"); return scanWith(Functions.justSupplier(initialValue), accumulator); } @@ -11513,7 +11839,8 @@ public final Observable scan(final R initialValue, BiFunction Observable scanWith(Supplier seedSupplier, BiFunction accumulator) { + @NonNull + public final Observable scanWith(@NonNull Supplier seedSupplier, @NonNull BiFunction accumulator) { Objects.requireNonNull(seedSupplier, "seedSupplier is null"); Objects.requireNonNull(accumulator, "accumulator is null"); return RxJavaPlugins.onAssembly(new ObservableScanSeed<>(this, seedSupplier, accumulator)); @@ -11541,6 +11868,7 @@ public final Observable scanWith(Supplier seedSupplier, BiFunction serialize() { return RxJavaPlugins.onAssembly(new ObservableSerialized<>(this)); } @@ -11564,6 +11892,7 @@ public final Observable serialize() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable share() { return publish().refCount(); } @@ -11583,6 +11912,7 @@ public final Observable share() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Maybe singleElement() { return RxJavaPlugins.onAssembly(new ObservableSingleMaybe<>(this)); } @@ -11605,7 +11935,8 @@ public final Maybe singleElement() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single single(T defaultItem) { + @NonNull + public final Single single(@NonNull T defaultItem) { Objects.requireNonNull(defaultItem, "defaultItem is null"); return RxJavaPlugins.onAssembly(new ObservableSingleSingle<>(this, defaultItem)); } @@ -11627,6 +11958,7 @@ public final Single single(T defaultItem) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single singleOrError() { return RxJavaPlugins.onAssembly(new ObservableSingleSingle<>(this, null)); } @@ -11649,6 +11981,7 @@ public final Single singleOrError() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable skip(long count) { if (count <= 0) { return RxJavaPlugins.onAssembly(this); @@ -11677,7 +12010,8 @@ public final Observable skip(long count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable skip(long time, TimeUnit unit) { + @NonNull + public final Observable skip(long time, @NonNull TimeUnit unit) { return skipUntil(timer(time, unit)); } @@ -11703,7 +12037,8 @@ public final Observable skip(long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable skip(long time, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable skip(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return skipUntil(timer(time, unit, scheduler)); } @@ -11731,6 +12066,7 @@ public final Observable skip(long time, TimeUnit unit, Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable skipLast(int count) { if (count < 0) { throw new IndexOutOfBoundsException("count >= 0 required but it was " + count); @@ -11764,7 +12100,8 @@ public final Observable skipLast(int count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.TRAMPOLINE) - public final Observable skipLast(long time, TimeUnit unit) { + @NonNull + public final Observable skipLast(long time, @NonNull TimeUnit unit) { return skipLast(time, unit, Schedulers.trampoline(), false, bufferSize()); } @@ -11794,7 +12131,8 @@ public final Observable skipLast(long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.TRAMPOLINE) - public final Observable skipLast(long time, TimeUnit unit, boolean delayError) { + @NonNull + public final Observable skipLast(long time, @NonNull TimeUnit unit, boolean delayError) { return skipLast(time, unit, Schedulers.trampoline(), delayError, bufferSize()); } @@ -11822,7 +12160,8 @@ public final Observable skipLast(long time, TimeUnit unit, boolean delayError */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable skipLast(long time, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable skipLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return skipLast(time, unit, scheduler, false, bufferSize()); } @@ -11853,7 +12192,8 @@ public final Observable skipLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable skipLast(long time, TimeUnit unit, Scheduler scheduler, boolean delayError) { + @NonNull + public final Observable skipLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError) { return skipLast(time, unit, scheduler, delayError, bufferSize()); } @@ -11886,7 +12226,8 @@ public final Observable skipLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable skipLast(long time, TimeUnit unit, Scheduler scheduler, boolean delayError, int bufferSize) { + @NonNull + public final Observable skipLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -11915,7 +12256,8 @@ public final Observable skipLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable skipUntil(ObservableSource other) { + @NonNull + public final Observable skipUntil(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableSkipUntil<>(this, other)); } @@ -11938,7 +12280,8 @@ public final Observable skipUntil(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable skipWhile(Predicate predicate) { + @NonNull + public final Observable skipWhile(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableSkipWhile<>(this, predicate)); } @@ -11965,6 +12308,7 @@ public final Observable skipWhile(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable sorted() { return toList().toObservable().map(Functions.listSorter(Functions.naturalComparator())).flatMapIterable(Functions.>identity()); } @@ -11988,7 +12332,8 @@ public final Observable sorted() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable sorted(Comparator sortFunction) { + @NonNull + public final Observable sorted(@NonNull Comparator sortFunction) { Objects.requireNonNull(sortFunction, "sortFunction is null"); return toList().toObservable().map(Functions.listSorter(sortFunction)).flatMapIterable(Functions.>identity()); } @@ -12012,10 +12357,10 @@ public final Observable sorted(Comparator sortFunction) { * @see #startWithItem(Object) * @see #startWithArray(Object...) */ - @SuppressWarnings("unchecked") @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable startWithIterable(Iterable items) { + @NonNull + public final Observable startWithIterable(@NonNull Iterable items) { return concatArray(fromIterable(items), this); } @@ -12035,10 +12380,10 @@ public final Observable startWithIterable(Iterable items) { * emitted by the source ObservableSource * @see ReactiveX operators documentation: StartWith */ - @SuppressWarnings("unchecked") @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable startWith(ObservableSource other) { + @NonNull + public final Observable startWith(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return concatArray(other, this); } @@ -12062,10 +12407,10 @@ public final Observable startWith(ObservableSource other) { * @see #startWithIterable(Iterable) * @since 3.0.0 */ - @SuppressWarnings("unchecked") @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable startWithItem(T item) { + @NonNull + public final Observable startWithItem(@NonNull T item) { Objects.requireNonNull(item, "item is null"); return concatArray(just(item), this); } @@ -12088,10 +12433,11 @@ public final Observable startWithItem(T item) { * @see #startWithItem(Object) * @see #startWithIterable(Iterable) */ - @SuppressWarnings("unchecked") @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable startWithArray(T... items) { + @SafeVarargs + @NonNull + public final Observable startWithArray(@NonNull T... items) { Observable fromArray = fromArray(items); if (fromArray == empty()) { return RxJavaPlugins.onAssembly(this); @@ -12115,6 +12461,7 @@ public final Observable startWithArray(T... items) { * @see ReactiveX operators documentation: Subscribe */ @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Disposable subscribe() { return subscribe(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); } @@ -12140,7 +12487,8 @@ public final Disposable subscribe() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Disposable subscribe(Consumer onNext) { + @NonNull + public final Disposable subscribe(@NonNull Consumer onNext) { return subscribe(onNext, Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); } @@ -12166,7 +12514,8 @@ public final Disposable subscribe(Consumer onNext) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Disposable subscribe(Consumer onNext, Consumer onError) { + @NonNull + public final Disposable subscribe(@NonNull Consumer onNext, @NonNull Consumer onError) { return subscribe(onNext, onError, Functions.EMPTY_ACTION); } @@ -12196,8 +12545,9 @@ public final Disposable subscribe(Consumer onNext, Consumer onNext, Consumer onError, - Action onComplete) { + @NonNull + public final Disposable subscribe(@NonNull Consumer onNext, @NonNull Consumer onError, + @NonNull Action onComplete) { Objects.requireNonNull(onNext, "onNext is null"); Objects.requireNonNull(onError, "onError is null"); Objects.requireNonNull(onComplete, "onComplete is null"); @@ -12211,7 +12561,7 @@ public final Disposable subscribe(Consumer onNext, Consumer observer) { + public final void subscribe(@NonNull Observer observer) { Objects.requireNonNull(observer, "observer is null"); try { observer = RxJavaPlugins.onSubscribe(this, observer); @@ -12241,7 +12591,7 @@ public final void subscribe(Observer observer) { * applied by {@link #subscribe(Observer)} before this method gets called. * @param observer the incoming Observer, never null */ - protected abstract void subscribeActual(Observer observer); + protected abstract void subscribeActual(@NonNull Observer observer); /** * Subscribes a given Observer (subclass) to this Observable and returns the given @@ -12269,7 +12619,8 @@ public final void subscribe(Observer observer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > E subscribeWith(E observer) { + @NonNull + public final <@NonNull E extends Observer> E subscribeWith(E observer) { subscribe(observer); return observer; } @@ -12293,7 +12644,8 @@ public final > E subscribeWith(E observer) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable subscribeOn(Scheduler scheduler) { + @NonNull + public final Observable subscribeOn(@NonNull Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableSubscribeOn<>(this, scheduler)); } @@ -12316,7 +12668,8 @@ public final Observable subscribeOn(Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable switchIfEmpty(ObservableSource other) { + @NonNull + public final Observable switchIfEmpty(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableSwitchIfEmpty<>(this, other)); } @@ -12345,7 +12698,8 @@ public final Observable switchIfEmpty(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable switchMap(Function> mapper) { + @NonNull + public final Observable switchMap(@NonNull Function> mapper) { return switchMap(mapper, bufferSize()); } @@ -12375,7 +12729,8 @@ public final Observable switchMap(Function Observable switchMap(Function> mapper, int bufferSize) { + @NonNull + public final Observable switchMap(@NonNull Function> mapper, int bufferSize) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); if (this instanceof ScalarSupplier) { @@ -12425,6 +12780,7 @@ public final Observable switchMap(Function mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableSwitchMapCompletable<>(this, mapper, false)); @@ -12467,6 +12823,7 @@ public final Completable switchMapCompletable(@NonNull Function mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableSwitchMapCompletable<>(this, mapper, true)); @@ -12503,6 +12860,7 @@ public final Completable switchMapCompletableDelayError(@NonNull Function Observable switchMapMaybe(@NonNull Function> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableSwitchMapMaybe<>(this, mapper, false)); @@ -12529,6 +12887,7 @@ public final Observable switchMapMaybe(@NonNull Function Observable switchMapMaybeDelayError(@NonNull Function> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return RxJavaPlugins.onAssembly(new ObservableSwitchMapMaybe<>(this, mapper, true)); @@ -12623,7 +12982,8 @@ public final Observable switchMapSingleDelayError(@NonNull Function Observable switchMapDelayError(Function> mapper) { + @NonNull + public final Observable switchMapDelayError(@NonNull Function> mapper) { return switchMapDelayError(mapper, bufferSize()); } @@ -12655,7 +13015,8 @@ public final Observable switchMapDelayError(Function Observable switchMapDelayError(Function> mapper, int bufferSize) { + @NonNull + public final Observable switchMapDelayError(@NonNull Function> mapper, int bufferSize) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); if (this instanceof ScalarSupplier) { @@ -12691,6 +13052,7 @@ public final Observable switchMapDelayError(Function take(long count) { if (count < 0) { throw new IllegalArgumentException("count >= 0 required but it was " + count); @@ -12720,7 +13082,8 @@ public final Observable take(long count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable take(long time, TimeUnit unit) { + @NonNull + public final Observable take(long time, @NonNull TimeUnit unit) { return takeUntil(timer(time, unit)); } @@ -12749,7 +13112,8 @@ public final Observable take(long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable take(long time, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable take(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return takeUntil(timer(time, unit, scheduler)); } @@ -12773,6 +13137,7 @@ public final Observable take(long time, TimeUnit unit, Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable takeLast(int count) { if (count < 0) { throw new IndexOutOfBoundsException("count >= 0 required but it was " + count); @@ -12809,7 +13174,8 @@ public final Observable takeLast(int count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.TRAMPOLINE) - public final Observable takeLast(long count, long time, TimeUnit unit) { + @NonNull + public final Observable takeLast(long count, long time, @NonNull TimeUnit unit) { return takeLast(count, time, unit, Schedulers.trampoline(), false, bufferSize()); } @@ -12841,7 +13207,8 @@ public final Observable takeLast(long count, long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable takeLast(long count, long time, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable takeLast(long count, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return takeLast(count, time, unit, scheduler, false, bufferSize()); } @@ -12878,7 +13245,8 @@ public final Observable takeLast(long count, long time, TimeUnit unit, Schedu */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable takeLast(long count, long time, TimeUnit unit, Scheduler scheduler, boolean delayError, int bufferSize) { + @NonNull + public final Observable takeLast(long count, long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -12908,7 +13276,8 @@ public final Observable takeLast(long count, long time, TimeUnit unit, Schedu */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.TRAMPOLINE) - public final Observable takeLast(long time, TimeUnit unit) { + @NonNull + public final Observable takeLast(long time, @NonNull TimeUnit unit) { return takeLast(time, unit, Schedulers.trampoline(), false, bufferSize()); } @@ -12935,7 +13304,8 @@ public final Observable takeLast(long time, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.TRAMPOLINE) - public final Observable takeLast(long time, TimeUnit unit, boolean delayError) { + @NonNull + public final Observable takeLast(long time, @NonNull TimeUnit unit, boolean delayError) { return takeLast(time, unit, Schedulers.trampoline(), delayError, bufferSize()); } @@ -12963,7 +13333,8 @@ public final Observable takeLast(long time, TimeUnit unit, boolean delayError */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable takeLast(long time, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable takeLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return takeLast(time, unit, scheduler, false, bufferSize()); } @@ -12994,7 +13365,8 @@ public final Observable takeLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable takeLast(long time, TimeUnit unit, Scheduler scheduler, boolean delayError) { + @NonNull + public final Observable takeLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError) { return takeLast(time, unit, scheduler, delayError, bufferSize()); } @@ -13027,7 +13399,8 @@ public final Observable takeLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable takeLast(long time, TimeUnit unit, Scheduler scheduler, boolean delayError, int bufferSize) { + @NonNull + public final Observable takeLast(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize) { return takeLast(Long.MAX_VALUE, time, unit, scheduler, delayError, bufferSize); } @@ -13051,7 +13424,8 @@ public final Observable takeLast(long time, TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable takeUntil(ObservableSource other) { + @NonNull + public final Observable takeUntil(@NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return RxJavaPlugins.onAssembly(new ObservableTakeUntil<>(this, other)); } @@ -13080,7 +13454,8 @@ public final Observable takeUntil(ObservableSource other) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable takeUntil(Predicate stopPredicate) { + @NonNull + public final Observable takeUntil(@NonNull Predicate stopPredicate) { Objects.requireNonNull(stopPredicate, "stopPredicate is null"); return RxJavaPlugins.onAssembly(new ObservableTakeUntilPredicate<>(this, stopPredicate)); } @@ -13104,7 +13479,8 @@ public final Observable takeUntil(Predicate stopPredicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable takeWhile(Predicate predicate) { + @NonNull + public final Observable takeWhile(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate is null"); return RxJavaPlugins.onAssembly(new ObservableTakeWhile<>(this, predicate)); } @@ -13131,7 +13507,8 @@ public final Observable takeWhile(Predicate predicate) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable throttleFirst(long windowDuration, TimeUnit unit) { + @NonNull + public final Observable throttleFirst(long windowDuration, @NonNull TimeUnit unit) { return throttleFirst(windowDuration, unit, Schedulers.computation()); } @@ -13160,7 +13537,8 @@ public final Observable throttleFirst(long windowDuration, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable throttleFirst(long skipDuration, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable throttleFirst(long skipDuration, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableThrottleFirstTimed<>(this, skipDuration, unit, scheduler)); @@ -13190,7 +13568,8 @@ public final Observable throttleFirst(long skipDuration, TimeUnit unit, Sched */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable throttleLast(long intervalDuration, TimeUnit unit) { + @NonNull + public final Observable throttleLast(long intervalDuration, @NonNull TimeUnit unit) { return sample(intervalDuration, unit); } @@ -13221,7 +13600,8 @@ public final Observable throttleLast(long intervalDuration, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable throttleLast(long intervalDuration, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable throttleLast(long intervalDuration, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return sample(intervalDuration, unit, scheduler); } @@ -13252,7 +13632,8 @@ public final Observable throttleLast(long intervalDuration, TimeUnit unit, Sc */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable throttleLatest(long timeout, TimeUnit unit) { + @NonNull + public final Observable throttleLatest(long timeout, @NonNull TimeUnit unit) { return throttleLatest(timeout, unit, Schedulers.computation(), false); } @@ -13283,7 +13664,8 @@ public final Observable throttleLatest(long timeout, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable throttleLatest(long timeout, TimeUnit unit, boolean emitLast) { + @NonNull + public final Observable throttleLatest(long timeout, @NonNull TimeUnit unit, boolean emitLast) { return throttleLatest(timeout, unit, Schedulers.computation(), emitLast); } @@ -13315,7 +13697,8 @@ public final Observable throttleLatest(long timeout, TimeUnit unit, boolean e */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable throttleLatest(long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable throttleLatest(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return throttleLatest(timeout, unit, scheduler, false); } @@ -13347,7 +13730,8 @@ public final Observable throttleLatest(long timeout, TimeUnit unit, Scheduler */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable throttleLatest(long timeout, TimeUnit unit, Scheduler scheduler, boolean emitLast) { + @NonNull + public final Observable throttleLatest(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableThrottleLatest<>(this, timeout, unit, scheduler, emitLast)); @@ -13380,7 +13764,8 @@ public final Observable throttleLatest(long timeout, TimeUnit unit, Scheduler */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable throttleWithTimeout(long timeout, TimeUnit unit) { + @NonNull + public final Observable throttleWithTimeout(long timeout, @NonNull TimeUnit unit) { return debounce(timeout, unit); } @@ -13414,7 +13799,8 @@ public final Observable throttleWithTimeout(long timeout, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable throttleWithTimeout(long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable throttleWithTimeout(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return debounce(timeout, unit, scheduler); } @@ -13434,6 +13820,7 @@ public final Observable throttleWithTimeout(long timeout, TimeUnit unit, Sche */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> timeInterval() { return timeInterval(TimeUnit.MILLISECONDS, Schedulers.computation()); } @@ -13456,7 +13843,8 @@ public final Observable> timeInterval() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps. - public final Observable> timeInterval(Scheduler scheduler) { + @NonNull + public final Observable> timeInterval(@NonNull Scheduler scheduler) { return timeInterval(TimeUnit.MILLISECONDS, scheduler); } @@ -13477,7 +13865,8 @@ public final Observable> timeInterval(Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> timeInterval(TimeUnit unit) { + @NonNull + public final Observable> timeInterval(@NonNull TimeUnit unit) { return timeInterval(unit, Schedulers.computation()); } @@ -13500,7 +13889,8 @@ public final Observable> timeInterval(TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps. - public final Observable> timeInterval(TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable> timeInterval(@NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableTimeInterval<>(this, unit, scheduler)); @@ -13532,7 +13922,8 @@ public final Observable> timeInterval(TimeUnit unit, Scheduler schedule */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable timeout(Function> itemTimeoutIndicator) { + @NonNull + public final Observable timeout(@NonNull Function> itemTimeoutIndicator) { return timeout0(null, itemTimeoutIndicator, null); } @@ -13564,8 +13955,9 @@ public final Observable timeout(Function Observable timeout(Function> itemTimeoutIndicator, - ObservableSource other) { + @NonNull + public final Observable timeout(@NonNull Function> itemTimeoutIndicator, + @NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return timeout0(null, itemTimeoutIndicator, other); } @@ -13591,7 +13983,8 @@ public final Observable timeout(Function timeout(long timeout, TimeUnit timeUnit) { + @NonNull + public final Observable timeout(long timeout, @NonNull TimeUnit timeUnit) { return timeout0(timeout, timeUnit, null, Schedulers.computation()); } @@ -13618,7 +14011,8 @@ public final Observable timeout(long timeout, TimeUnit timeUnit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable timeout(long timeout, TimeUnit timeUnit, ObservableSource other) { + @NonNull + public final Observable timeout(long timeout, @NonNull TimeUnit timeUnit, @NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return timeout0(timeout, timeUnit, other, Schedulers.computation()); } @@ -13649,7 +14043,8 @@ public final Observable timeout(long timeout, TimeUnit timeUnit, ObservableSo */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable timeout(long timeout, TimeUnit timeUnit, Scheduler scheduler, ObservableSource other) { + @NonNull + public final Observable timeout(long timeout, @NonNull TimeUnit timeUnit, @NonNull Scheduler scheduler, @NonNull ObservableSource other) { Objects.requireNonNull(other, "other is null"); return timeout0(timeout, timeUnit, other, scheduler); } @@ -13678,7 +14073,8 @@ public final Observable timeout(long timeout, TimeUnit timeUnit, Scheduler sc */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable timeout(long timeout, TimeUnit timeUnit, Scheduler scheduler) { + @NonNull + public final Observable timeout(long timeout, @NonNull TimeUnit timeUnit, @NonNull Scheduler scheduler) { return timeout0(timeout, timeUnit, null, scheduler); } @@ -13711,8 +14107,9 @@ public final Observable timeout(long timeout, TimeUnit timeUnit, Scheduler sc */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable timeout(ObservableSource firstTimeoutIndicator, - Function> itemTimeoutIndicator) { + @NonNull + public final Observable timeout(@NonNull ObservableSource firstTimeoutIndicator, + @NonNull Function> itemTimeoutIndicator) { Objects.requireNonNull(firstTimeoutIndicator, "firstTimeoutIndicator is null"); return timeout0(firstTimeoutIndicator, itemTimeoutIndicator, null); } @@ -13751,26 +14148,30 @@ public final Observable timeout(ObservableSource firstTimeoutIndica */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable timeout( - ObservableSource firstTimeoutIndicator, - Function> itemTimeoutIndicator, - ObservableSource other) { + @NonNull ObservableSource firstTimeoutIndicator, + @NonNull Function> itemTimeoutIndicator, + @NonNull ObservableSource other) { Objects.requireNonNull(firstTimeoutIndicator, "firstTimeoutIndicator is null"); Objects.requireNonNull(other, "other is null"); return timeout0(firstTimeoutIndicator, itemTimeoutIndicator, other); } - private Observable timeout0(long timeout, TimeUnit timeUnit, ObservableSource other, - Scheduler scheduler) { + @NonNull + private Observable timeout0(long timeout, @NonNull TimeUnit timeUnit, + @Nullable ObservableSource other, + @NonNull Scheduler scheduler) { Objects.requireNonNull(timeUnit, "timeUnit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableTimeoutTimed<>(this, timeout, timeUnit, scheduler, other)); } + @NonNull private Observable timeout0( - ObservableSource firstTimeoutIndicator, - Function> itemTimeoutIndicator, - ObservableSource other) { + @NonNull ObservableSource firstTimeoutIndicator, + @NonNull Function> itemTimeoutIndicator, + @Nullable ObservableSource other) { Objects.requireNonNull(itemTimeoutIndicator, "itemTimeoutIndicator is null"); return RxJavaPlugins.onAssembly(new ObservableTimeout<>(this, firstTimeoutIndicator, itemTimeoutIndicator, other)); } @@ -13791,6 +14192,7 @@ private Observable timeout0( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> timestamp() { return timestamp(TimeUnit.MILLISECONDS, Schedulers.computation()); } @@ -13814,7 +14216,8 @@ public final Observable> timestamp() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps. - public final Observable> timestamp(Scheduler scheduler) { + @NonNull + public final Observable> timestamp(@NonNull Scheduler scheduler) { return timestamp(TimeUnit.MILLISECONDS, scheduler); } @@ -13835,7 +14238,8 @@ public final Observable> timestamp(Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> timestamp(TimeUnit unit) { + @NonNull + public final Observable> timestamp(@NonNull TimeUnit unit) { return timestamp(unit, Schedulers.computation()); } @@ -13859,7 +14263,8 @@ public final Observable> timestamp(TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) // Supplied scheduler is only used for creating timestamps. - public final Observable> timestamp(final TimeUnit unit, final Scheduler scheduler) { + @NonNull + public final Observable> timestamp(@NonNull TimeUnit unit, @NonNull Scheduler scheduler) { Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); return map(Functions.timestampWith(unit, scheduler)); @@ -13882,6 +14287,7 @@ public final Observable> timestamp(final TimeUnit unit, final Scheduler */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final R to(@NonNull ObservableConverter converter) { return Objects.requireNonNull(converter, "converter is null").apply(this); } @@ -13912,7 +14318,8 @@ public final R to(@NonNull ObservableConverter converter) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toList() { + @NonNull + public final Single<@NonNull List> toList() { return toList(16); } @@ -13944,7 +14351,8 @@ public final Single> toList() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toList(final int capacityHint) { + @NonNull + public final Single<@NonNull List> toList(int capacityHint) { ObjectHelper.verifyPositive(capacityHint, "capacityHint"); return RxJavaPlugins.onAssembly(new ObservableToListSingle>(this, capacityHint)); } @@ -13978,7 +14386,8 @@ public final Single> toList(final int capacityHint) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Single toList(Supplier collectionSupplier) { + @NonNull + public final <@NonNull U extends Collection> Single toList(@NonNull Supplier collectionSupplier) { Objects.requireNonNull(collectionSupplier, "collectionSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableToListSingle<>(this, collectionSupplier)); } @@ -14009,7 +14418,8 @@ public final > Single toList(Supplier coll */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toMap(final Function keySelector) { + @NonNull + public final Single<@NonNull Map> toMap(@NonNull Function keySelector) { Objects.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.asSupplier(), Functions.toMapKeySelector(keySelector)); } @@ -14043,9 +14453,10 @@ public final Single> toMap(final Function */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single> toMap( - final Function keySelector, - final Function valueSelector) { + @NonNull Function keySelector, + @NonNull Function valueSelector) { Objects.requireNonNull(keySelector, "keySelector is null"); Objects.requireNonNull(valueSelector, "valueSelector is null"); return collect(HashMapSupplier.asSupplier(), Functions.toMapKeyValueSelector(keySelector, valueSelector)); @@ -14079,10 +14490,11 @@ public final Single> toMap( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Single> toMap( - final Function keySelector, - final Function valueSelector, - Supplier> mapSupplier) { + @NonNull Function keySelector, + @NonNull Function valueSelector, + @NonNull Supplier> mapSupplier) { Objects.requireNonNull(keySelector, "keySelector is null"); Objects.requireNonNull(valueSelector, "valueSelector is null"); Objects.requireNonNull(mapSupplier, "mapSupplier is null"); @@ -14112,7 +14524,8 @@ public final Single> toMap( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single>> toMultimap(Function keySelector) { + @NonNull + public final Single<@NonNull Map>> toMultimap(@NonNull Function keySelector) { @SuppressWarnings({ "rawtypes", "unchecked" }) Function valueSelector = (Function)Functions.identity(); Supplier>> mapSupplier = HashMapSupplier.asSupplier(); @@ -14147,7 +14560,8 @@ public final Single>> toMultimap(Function Single>> toMultimap(Function keySelector, Function valueSelector) { + @NonNull + public final Single<@NonNull Map>> toMultimap(@NonNull Function keySelector, Function valueSelector) { Supplier>> mapSupplier = HashMapSupplier.asSupplier(); Function> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); @@ -14180,11 +14594,12 @@ public final Single>> toMultimap(Function Single>> toMultimap( - final Function keySelector, - final Function valueSelector, - final Supplier>> mapSupplier, - final Function> collectionFactory) { + @NonNull + public final Single<@NonNull Map>> toMultimap( + @NonNull Function keySelector, + @NonNull Function valueSelector, + @NonNull Supplier>> mapSupplier, + @NonNull Function> collectionFactory) { Objects.requireNonNull(keySelector, "keySelector is null"); Objects.requireNonNull(valueSelector, "valueSelector is null"); Objects.requireNonNull(mapSupplier, "mapSupplier is null"); @@ -14221,11 +14636,12 @@ public final Single>> toMultimap( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single>> toMultimap( - Function keySelector, - Function valueSelector, - Supplier>> mapSupplier - ) { + @NonNull + public final Single<@NonNull Map>> toMultimap( + @NonNull Function keySelector, + @NonNull Function valueSelector, + @NonNull Supplier>> mapSupplier + ) { return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.asFunction()); } @@ -14268,7 +14684,8 @@ public final Single>> toMultimap( @BackpressureSupport(BackpressureKind.SPECIAL) @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Flowable toFlowable(BackpressureStrategy strategy) { + @NonNull + public final Flowable toFlowable(@NonNull BackpressureStrategy strategy) { Flowable f = new FlowableFromObservable<>(this); switch (strategy) { @@ -14309,7 +14726,8 @@ public final Flowable toFlowable(BackpressureStrategy strategy) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toSortedList() { + @NonNull + public final Single<@NonNull List> toSortedList() { return toSortedList(Functions.naturalOrder()); } @@ -14336,7 +14754,8 @@ public final Single> toSortedList() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toSortedList(final Comparator comparator) { + @NonNull + public final Single<@NonNull List> toSortedList(@NonNull Comparator comparator) { Objects.requireNonNull(comparator, "comparator is null"); return toList().map(Functions.listSorter(comparator)); } @@ -14367,7 +14786,8 @@ public final Single> toSortedList(final Comparator comparator */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toSortedList(final Comparator comparator, int capacityHint) { + @NonNull + public final Single<@NonNull List> toSortedList(@NonNull Comparator comparator, int capacityHint) { Objects.requireNonNull(comparator, "comparator is null"); return toList(capacityHint).map(Functions.listSorter(comparator)); } @@ -14400,7 +14820,8 @@ public final Single> toSortedList(final Comparator comparator */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single> toSortedList(int capacityHint) { + @NonNull + public final Single<@NonNull List> toSortedList(int capacityHint) { return toSortedList(Functions.naturalOrder(), capacityHint); } @@ -14422,7 +14843,8 @@ public final Single> toSortedList(int capacityHint) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable unsubscribeOn(Scheduler scheduler) { + @NonNull + public final Observable unsubscribeOn(@NonNull Scheduler scheduler) { Objects.requireNonNull(scheduler, "scheduler is null"); return RxJavaPlugins.onAssembly(new ObservableUnsubscribeOn<>(this, scheduler)); } @@ -14448,6 +14870,7 @@ public final Observable unsubscribeOn(Scheduler scheduler) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> window(long count) { return window(count, count, bufferSize()); } @@ -14476,6 +14899,7 @@ public final Observable> window(long count) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> window(long count, long skip) { return window(count, skip, bufferSize()); } @@ -14506,6 +14930,7 @@ public final Observable> window(long count, long skip) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> window(long count, long skip, int bufferSize) { ObjectHelper.verifyPositive(count, "count"); ObjectHelper.verifyPositive(skip, "skip"); @@ -14542,7 +14967,8 @@ public final Observable> window(long count, long skip, int bufferS */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> window(long timespan, long timeskip, TimeUnit unit) { + @NonNull + public final Observable> window(long timespan, long timeskip, @NonNull TimeUnit unit) { return window(timespan, timeskip, unit, Schedulers.computation(), bufferSize()); } @@ -14577,7 +15003,8 @@ public final Observable> window(long timespan, long timeskip, Time */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> window(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable> window(long timespan, long timeskip, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return window(timespan, timeskip, unit, scheduler, bufferSize()); } @@ -14614,7 +15041,8 @@ public final Observable> window(long timespan, long timeskip, Time */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> window(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, int bufferSize) { + @NonNull + public final Observable> window(long timespan, long timeskip, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, int bufferSize) { ObjectHelper.verifyPositive(timespan, "timespan"); ObjectHelper.verifyPositive(timeskip, "timeskip"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -14651,7 +15079,8 @@ public final Observable> window(long timespan, long timeskip, Time */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> window(long timespan, TimeUnit unit) { + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit) { return window(timespan, unit, Schedulers.computation(), Long.MAX_VALUE, false); } @@ -14687,7 +15116,8 @@ public final Observable> window(long timespan, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> window(long timespan, TimeUnit unit, + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit, long count) { return window(timespan, unit, Schedulers.computation(), count, false); } @@ -14726,7 +15156,8 @@ public final Observable> window(long timespan, TimeUnit unit, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable> window(long timespan, TimeUnit unit, + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit, long count, boolean restart) { return window(timespan, unit, Schedulers.computation(), count, restart); } @@ -14761,8 +15192,9 @@ public final Observable> window(long timespan, TimeUnit unit, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> window(long timespan, TimeUnit unit, - Scheduler scheduler) { + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit, + @NonNull Scheduler scheduler) { return window(timespan, unit, scheduler, Long.MAX_VALUE, false); } @@ -14800,8 +15232,9 @@ public final Observable> window(long timespan, TimeUnit unit, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> window(long timespan, TimeUnit unit, - Scheduler scheduler, long count) { + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit, + @NonNull Scheduler scheduler, long count) { return window(timespan, unit, scheduler, count, false); } @@ -14841,8 +15274,9 @@ public final Observable> window(long timespan, TimeUnit unit, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable> window(long timespan, TimeUnit unit, - Scheduler scheduler, long count, boolean restart) { + @NonNull + public final Observable> window(long timespan, @NonNull TimeUnit unit, + @NonNull Scheduler scheduler, long count, boolean restart) { return window(timespan, unit, scheduler, count, restart, bufferSize()); } @@ -14884,8 +15318,9 @@ public final Observable> window(long timespan, TimeUnit unit, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) + @NonNull public final Observable> window( - long timespan, TimeUnit unit, Scheduler scheduler, + long timespan, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, long count, boolean restart, int bufferSize) { ObjectHelper.verifyPositive(bufferSize, "bufferSize"); Objects.requireNonNull(scheduler, "scheduler is null"); @@ -14921,7 +15356,8 @@ public final Observable> window( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> window(ObservableSource boundary) { + @NonNull + public final Observable> window(@NonNull ObservableSource boundary) { return window(boundary, bufferSize()); } @@ -14954,7 +15390,8 @@ public final Observable> window(ObservableSource boundary) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> window(ObservableSource boundary, int bufferSize) { + @NonNull + public final Observable> window(@NonNull ObservableSource boundary, int bufferSize) { Objects.requireNonNull(boundary, "boundary is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); return RxJavaPlugins.onAssembly(new ObservableWindowBoundary<>(this, boundary, bufferSize)); @@ -14990,9 +15427,10 @@ public final Observable> window(ObservableSource boundary, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> window( - ObservableSource openingIndicator, - Function> closingIndicator) { + @NonNull ObservableSource openingIndicator, + @NonNull Function> closingIndicator) { return window(openingIndicator, closingIndicator, bufferSize()); } @@ -15028,9 +15466,10 @@ public final Observable> window( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable> window( - ObservableSource openingIndicator, - Function> closingIndicator, int bufferSize) { + @NonNull ObservableSource openingIndicator, + @NonNull Function> closingIndicator, int bufferSize) { Objects.requireNonNull(openingIndicator, "openingIndicator is null"); Objects.requireNonNull(closingIndicator, "closingIndicator is null"); ObjectHelper.verifyPositive(bufferSize, "bufferSize"); @@ -15063,7 +15502,8 @@ public final Observable> window( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable withLatestFrom(ObservableSource other, BiFunction combiner) { + @NonNull + public final Observable withLatestFrom(@NonNull ObservableSource other, @NonNull BiFunction combiner) { Objects.requireNonNull(other, "other is null"); Objects.requireNonNull(combiner, "combiner is null"); @@ -15088,22 +15528,23 @@ public final Observable withLatestFrom(ObservableSource o * @param the first other source's value type * @param the second other source's value type * @param the result value type - * @param o1 the first other ObservableSource - * @param o2 the second other ObservableSource + * @param source1 the first other ObservableSource + * @param source2 the second other ObservableSource * @param combiner the function called with an array of values from each participating ObservableSource * @return the new ObservableSource instance * @since 2.0 */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable withLatestFrom( - ObservableSource o1, ObservableSource o2, - Function3 combiner) { - Objects.requireNonNull(o1, "o1 is null"); - Objects.requireNonNull(o2, "o2 is null"); + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull Function3 combiner) { + Objects.requireNonNull(source1, "source1 is null"); + Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); - return withLatestFrom(new ObservableSource[] { o1, o2 }, f); + return withLatestFrom(new ObservableSource[] { source1, source2 }, f); } /** @@ -15125,25 +15566,26 @@ public final Observable withLatestFrom( * @param the second other source's value type * @param the third other source's value type * @param the result value type - * @param o1 the first other ObservableSource - * @param o2 the second other ObservableSource - * @param o3 the third other ObservableSource + * @param source1 the first other ObservableSource + * @param source2 the second other ObservableSource + * @param source3 the third other ObservableSource * @param combiner the function called with an array of values from each participating ObservableSource * @return the new ObservableSource instance * @since 2.0 */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable withLatestFrom( - ObservableSource o1, ObservableSource o2, - ObservableSource o3, - Function4 combiner) { - Objects.requireNonNull(o1, "o1 is null"); - Objects.requireNonNull(o2, "o2 is null"); - Objects.requireNonNull(o3, "o3 is null"); + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, + @NonNull Function4 combiner) { + Objects.requireNonNull(source1, "source1 is null"); + Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); - return withLatestFrom(new ObservableSource[] { o1, o2, o3 }, f); + return withLatestFrom(new ObservableSource[] { source1, source2, source3 }, f); } /** @@ -15166,27 +15608,28 @@ public final Observable withLatestFrom( * @param the third other source's value type * @param the fourth other source's value type * @param the result value type - * @param o1 the first other ObservableSource - * @param o2 the second other ObservableSource - * @param o3 the third other ObservableSource - * @param o4 the fourth other ObservableSource + * @param source1 the first other ObservableSource + * @param source2 the second other ObservableSource + * @param source3 the third other ObservableSource + * @param source4 the fourth other ObservableSource * @param combiner the function called with an array of values from each participating ObservableSource * @return the new ObservableSource instance * @since 2.0 */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable withLatestFrom( - ObservableSource o1, ObservableSource o2, - ObservableSource o3, ObservableSource o4, - Function5 combiner) { - Objects.requireNonNull(o1, "o1 is null"); - Objects.requireNonNull(o2, "o2 is null"); - Objects.requireNonNull(o3, "o3 is null"); - Objects.requireNonNull(o4, "o4 is null"); + @NonNull ObservableSource source1, @NonNull ObservableSource source2, + @NonNull ObservableSource source3, @NonNull ObservableSource source4, + @NonNull Function5 combiner) { + Objects.requireNonNull(source1, "source1 is null"); + Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(combiner, "combiner is null"); Function f = Functions.toFunction(combiner); - return withLatestFrom(new ObservableSource[] { o1, o2, o3, o4 }, f); + return withLatestFrom(new ObservableSource[] { source1, source2, source3, source4 }, f); } /** @@ -15212,7 +15655,8 @@ public final Observable withLatestFrom( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable withLatestFrom(ObservableSource[] others, Function combiner) { + @NonNull + public final Observable withLatestFrom(@NonNull ObservableSource[] others, @NonNull Function combiner) { Objects.requireNonNull(others, "others is null"); Objects.requireNonNull(combiner, "combiner is null"); return RxJavaPlugins.onAssembly(new ObservableWithLatestFromMany<>(this, others, combiner)); @@ -15241,7 +15685,8 @@ public final Observable withLatestFrom(ObservableSource[] others, Func */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable withLatestFrom(Iterable> others, Function combiner) { + @NonNull + public final Observable withLatestFrom(@NonNull Iterable> others, @NonNull Function combiner) { Objects.requireNonNull(others, "others is null"); Objects.requireNonNull(combiner, "combiner is null"); return RxJavaPlugins.onAssembly(new ObservableWithLatestFromMany<>(this, others, combiner)); @@ -15275,7 +15720,8 @@ public final Observable withLatestFrom(Iterable Observable zipWith(Iterable other, BiFunction zipper) { + @NonNull + public final Observable zipWith(@NonNull Iterable other, @NonNull BiFunction zipper) { Objects.requireNonNull(other, "other is null"); Objects.requireNonNull(zipper, "zipper is null"); return RxJavaPlugins.onAssembly(new ObservableZipIterable(this, other, zipper)); @@ -15318,8 +15764,9 @@ public final Observable zipWith(Iterable other, BiFunction Observable zipWith(ObservableSource other, - BiFunction zipper) { + @NonNull + public final Observable zipWith(@NonNull ObservableSource other, + @NonNull BiFunction zipper) { Objects.requireNonNull(other, "other is null"); return zip(this, other, zipper); } @@ -15364,8 +15811,9 @@ public final Observable zipWith(ObservableSource other, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable zipWith(ObservableSource other, - BiFunction zipper, boolean delayError) { + @NonNull + public final Observable zipWith(@NonNull ObservableSource other, + @NonNull BiFunction zipper, boolean delayError) { return zip(this, other, zipper, delayError); } @@ -15411,8 +15859,9 @@ public final Observable zipWith(ObservableSource other, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable zipWith(ObservableSource other, - BiFunction zipper, boolean delayError, int bufferSize) { + @NonNull + public final Observable zipWith(@NonNull ObservableSource other, + @NonNull BiFunction zipper, boolean delayError, int bufferSize) { return zip(this, other, zipper, delayError, bufferSize); } @@ -15431,6 +15880,7 @@ public final Observable zipWith(ObservableSource other, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final TestObserver test() { // NoPMD TestObserver to = new TestObserver<>(); subscribe(to); @@ -15451,6 +15901,7 @@ public final TestObserver test() { // NoPMD */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final TestObserver test(boolean dispose) { // NoPMD TestObserver to = new TestObserver<>(); if (dispose) { diff --git a/src/main/java/io/reactivex/rxjava3/core/Single.java b/src/main/java/io/reactivex/rxjava3/core/Single.java index ce7ef85608..8bd0f1db4e 100644 --- a/src/main/java/io/reactivex/rxjava3/core/Single.java +++ b/src/main/java/io/reactivex/rxjava3/core/Single.java @@ -927,7 +927,7 @@ public static Single fromObservable(@NonNull ObservableSource Flowable merge(Iterable> sources) { + public static Flowable merge(@NonNull Iterable> sources) { return merge(Flowable.fromIterable(sources)); } @@ -1615,6 +1615,7 @@ public static Single zip( ) { Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2); } @@ -1655,6 +1656,7 @@ public static Single zip( Objects.requireNonNull(source1, "source1 is null"); Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3); } @@ -1699,6 +1701,7 @@ public static Single zip( Objects.requireNonNull(source2, "source2 is null"); Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4); } @@ -1748,6 +1751,7 @@ public static Single zip( Objects.requireNonNull(source3, "source3 is null"); Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5); } @@ -1801,6 +1805,7 @@ public static Single zip( Objects.requireNonNull(source4, "source4 is null"); Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6); } @@ -1859,6 +1864,7 @@ public static Single zip( Objects.requireNonNull(source5, "source5 is null"); Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7); } @@ -1921,6 +1927,7 @@ public static Single zip( Objects.requireNonNull(source6, "source6 is null"); Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7, source8); } @@ -1988,6 +1995,7 @@ public static Single zip( Objects.requireNonNull(source7, "source7 is null"); Objects.requireNonNull(source8, "source8 is null"); Objects.requireNonNull(source9, "source9 is null"); + Objects.requireNonNull(zipper, "zipper is null"); return zipArray(Functions.toFunction(zipper), source1, source2, source3, source4, source5, source6, source7, source8, source9); } diff --git a/src/main/java/io/reactivex/rxjava3/disposables/CompositeDisposable.java b/src/main/java/io/reactivex/rxjava3/disposables/CompositeDisposable.java index 3a75ac5f3e..eaf067c177 100644 --- a/src/main/java/io/reactivex/rxjava3/disposables/CompositeDisposable.java +++ b/src/main/java/io/reactivex/rxjava3/disposables/CompositeDisposable.java @@ -41,7 +41,7 @@ public CompositeDisposable() { */ public CompositeDisposable(@NonNull Disposable... disposables) { Objects.requireNonNull(disposables, "disposables is null"); - this.resources = new OpenHashSet(disposables.length + 1); + this.resources = new OpenHashSet<>(disposables.length + 1); for (Disposable d : disposables) { Objects.requireNonNull(d, "A Disposable in the disposables array is null"); this.resources.add(d); @@ -55,7 +55,7 @@ public CompositeDisposable(@NonNull Disposable... disposables) { */ public CompositeDisposable(@NonNull Iterable disposables) { Objects.requireNonNull(disposables, "disposables is null"); - this.resources = new OpenHashSet(); + this.resources = new OpenHashSet<>(); for (Disposable d : disposables) { Objects.requireNonNull(d, "A Disposable item in the disposables sequence is null"); this.resources.add(d); @@ -100,7 +100,7 @@ public boolean add(@NonNull Disposable disposable) { if (!disposed) { OpenHashSet set = resources; if (set == null) { - set = new OpenHashSet(); + set = new OpenHashSet<>(); resources = set; } set.add(disposable); @@ -126,7 +126,7 @@ public boolean addAll(@NonNull Disposable... disposables) { if (!disposed) { OpenHashSet set = resources; if (set == null) { - set = new OpenHashSet(disposables.length + 1); + set = new OpenHashSet<>(disposables.length + 1); resources = set; } for (Disposable d : disposables) { @@ -239,7 +239,7 @@ void dispose(OpenHashSet set) { } catch (Throwable ex) { Exceptions.throwIfFatal(ex); if (errors == null) { - errors = new ArrayList(); + errors = new ArrayList<>(); } errors.add(ex); } diff --git a/src/main/java/io/reactivex/rxjava3/disposables/SerialDisposable.java b/src/main/java/io/reactivex/rxjava3/disposables/SerialDisposable.java index d2c7ddee4b..1f408f8c94 100644 --- a/src/main/java/io/reactivex/rxjava3/disposables/SerialDisposable.java +++ b/src/main/java/io/reactivex/rxjava3/disposables/SerialDisposable.java @@ -30,7 +30,7 @@ public final class SerialDisposable implements Disposable { * Constructs an empty SerialDisposable. */ public SerialDisposable() { - this.resource = new AtomicReference(); + this.resource = new AtomicReference<>(); } /** @@ -38,7 +38,7 @@ public SerialDisposable() { * @param initialDisposable the initial Disposable instance to use, null allowed */ public SerialDisposable(@Nullable Disposable initialDisposable) { - this.resource = new AtomicReference(initialDisposable); + this.resource = new AtomicReference<>(initialDisposable); } /** diff --git a/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java b/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java index aa08128917..85b06bd313 100644 --- a/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java +++ b/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java @@ -62,8 +62,8 @@ public CompositeException(@NonNull Throwable... exceptions) { * @throws IllegalArgumentException if errors is empty. */ public CompositeException(@NonNull Iterable errors) { - Set deDupedExceptions = new LinkedHashSet(); - List localExceptions = new ArrayList(); + Set deDupedExceptions = new LinkedHashSet<>(); + List localExceptions = new ArrayList<>(); if (errors != null) { for (Throwable ex : errors) { if (ex instanceof CompositeException) { @@ -108,7 +108,7 @@ public synchronized Throwable getCause() { // NOPMD if (cause == null) { String separator = System.getProperty("line.separator"); if (exceptions.size() > 1) { - Map seenCauses = new IdentityHashMap(); + Map seenCauses = new IdentityHashMap<>(); StringBuilder aggregateMessage = new StringBuilder(); aggregateMessage.append("Multiple exceptions (").append(exceptions.size()).append(")").append(separator); diff --git a/src/main/java/io/reactivex/rxjava3/flowables/ConnectableFlowable.java b/src/main/java/io/reactivex/rxjava3/flowables/ConnectableFlowable.java index 6916d219bf..3c51f1c3bc 100644 --- a/src/main/java/io/reactivex/rxjava3/flowables/ConnectableFlowable.java +++ b/src/main/java/io/reactivex/rxjava3/flowables/ConnectableFlowable.java @@ -59,20 +59,30 @@ public abstract class ConnectableFlowable extends Flowable { /** * Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying * {@link Flowable} to its {@link Subscriber}s. + *
+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* * @param connection * the action that receives the connection subscription before the subscription to source happens * allowing the caller to synchronously disconnect a synchronous source * @see ReactiveX documentation: Connect */ + @SchedulerSupport(SchedulerSupport.NONE) public abstract void connect(@NonNull Consumer connection); /** * Resets this ConnectableFlowable into its fresh state if it has terminated. *

* Calling this method on a fresh or active {@code ConnectableFlowable} has no effect. + *

+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* @since 3.0.0 */ + @SchedulerSupport(SchedulerSupport.NONE) public abstract void reset(); /** @@ -80,10 +90,16 @@ public abstract class ConnectableFlowable extends Flowable { * {@link Flowable} to its {@link Subscriber}s. *

* To disconnect from a synchronous source, use the {@link #connect(io.reactivex.rxjava3.functions.Consumer)} method. + *

+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* * @return the subscription representing the connection * @see ReactiveX documentation: Connect */ + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) public final Disposable connect() { ConnectConsumer cc = new ConnectConsumer(); connect(cc); @@ -111,7 +127,7 @@ public final Disposable connect() { @SchedulerSupport(SchedulerSupport.NONE) @BackpressureSupport(BackpressureKind.PASS_THROUGH) public Flowable refCount() { - return RxJavaPlugins.onAssembly(new FlowableRefCount(this)); + return RxJavaPlugins.onAssembly(new FlowableRefCount<>(this)); } /** @@ -132,6 +148,7 @@ public Flowable refCount() { @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @NonNull public final Flowable refCount(int subscriberCount) { return refCount(subscriberCount, 0, TimeUnit.NANOSECONDS, Schedulers.trampoline()); } @@ -157,7 +174,8 @@ public final Flowable refCount(int subscriberCount) { @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) @BackpressureSupport(BackpressureKind.PASS_THROUGH) - public final Flowable refCount(long timeout, TimeUnit unit) { + @NonNull + public final Flowable refCount(long timeout, @NonNull TimeUnit unit) { return refCount(1, timeout, unit, Schedulers.computation()); } @@ -182,7 +200,8 @@ public final Flowable refCount(long timeout, TimeUnit unit) { @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) @BackpressureSupport(BackpressureKind.PASS_THROUGH) - public final Flowable refCount(long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Flowable refCount(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return refCount(1, timeout, unit, scheduler); } @@ -208,7 +227,8 @@ public final Flowable refCount(long timeout, TimeUnit unit, Scheduler schedul @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) @BackpressureSupport(BackpressureKind.PASS_THROUGH) - public final Flowable refCount(int subscriberCount, long timeout, TimeUnit unit) { + @NonNull + public final Flowable refCount(int subscriberCount, long timeout, @NonNull TimeUnit unit) { return refCount(subscriberCount, timeout, unit, Schedulers.computation()); } @@ -234,11 +254,12 @@ public final Flowable refCount(int subscriberCount, long timeout, TimeUnit un @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) @BackpressureSupport(BackpressureKind.PASS_THROUGH) - public final Flowable refCount(int subscriberCount, long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Flowable refCount(int subscriberCount, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { ObjectHelper.verifyPositive(subscriberCount, "subscriberCount"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); - return RxJavaPlugins.onAssembly(new FlowableRefCount(this, subscriberCount, timeout, unit, scheduler)); + return RxJavaPlugins.onAssembly(new FlowableRefCount<>(this, subscriberCount, timeout, unit, scheduler)); } /** @@ -256,6 +277,13 @@ public final Flowable refCount(int subscriberCount, long timeout, TimeUnit un * This overload does not allow disconnecting the connection established via * {@link #connect(Consumer)}. Use the {@link #autoConnect(int, Consumer)} overload * to gain access to the {@code Disposable} representing the only connection. + *
+ *
Backpressure:
+ *
The operator itself doesn't interfere with backpressure which is determined by + * the upstream {@code ConnectableFlowable}'s behavior.
+ *
Scheduler:
+ *
{@code autoConnect} does not operate by default on a particular {@link Scheduler}.
+ *
* * @return a Flowable that automatically connects to this ConnectableFlowable * when the first Subscriber subscribes @@ -263,6 +291,9 @@ public final Flowable refCount(int subscriberCount, long timeout, TimeUnit un * @see #autoConnect(int, Consumer) */ @NonNull + @CheckReturnValue + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public Flowable autoConnect() { return autoConnect(1); } @@ -281,6 +312,13 @@ public Flowable autoConnect() { * This overload does not allow disconnecting the connection established via * {@link #connect(Consumer)}. Use the {@link #autoConnect(int, Consumer)} overload * to gain access to the {@code Disposable} representing the only connection. + *
+ *
Backpressure:
+ *
The operator itself doesn't interfere with backpressure which is determined by + * the upstream {@code ConnectableFlowable}'s behavior.
+ *
Scheduler:
+ *
{@code autoConnect} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param numberOfSubscribers the number of subscribers to await before calling connect * on the ConnectableFlowable. A non-positive value indicates @@ -289,6 +327,9 @@ public Flowable autoConnect() { * when the specified number of Subscribers subscribe to it */ @NonNull + @CheckReturnValue + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public Flowable autoConnect(int numberOfSubscribers) { return autoConnect(numberOfSubscribers, Functions.emptyConsumer()); } @@ -305,6 +346,13 @@ public Flowable autoConnect(int numberOfSubscribers) { * terminates, the connection is never renewed, no matter how Subscribers come * and go. Use {@link #refCount()} to renew a connection or dispose an active * connection when all {@code Subscriber}s have cancelled their {@code Subscription}s. + *
+ *
Backpressure:
+ *
The operator itself doesn't interfere with backpressure which is determined by + * the upstream {@code ConnectableFlowable}'s behavior.
+ *
Scheduler:
+ *
{@code autoConnect} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param numberOfSubscribers the number of subscribers to await before calling connect * on the ConnectableFlowable. A non-positive value indicates @@ -316,11 +364,14 @@ public Flowable autoConnect(int numberOfSubscribers) { * specified callback with the Subscription associated with the established connection */ @NonNull + @CheckReturnValue + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public Flowable autoConnect(int numberOfSubscribers, @NonNull Consumer connection) { if (numberOfSubscribers <= 0) { this.connect(connection); return RxJavaPlugins.onAssembly(this); } - return RxJavaPlugins.onAssembly(new FlowableAutoConnect(this, numberOfSubscribers, connection)); + return RxJavaPlugins.onAssembly(new FlowableAutoConnect<>(this, numberOfSubscribers, connection)); } } diff --git a/src/main/java/io/reactivex/rxjava3/internal/functions/Functions.java b/src/main/java/io/reactivex/rxjava3/internal/functions/Functions.java index 2dcbbdea50..05d1997893 100644 --- a/src/main/java/io/reactivex/rxjava3/internal/functions/Functions.java +++ b/src/main/java/io/reactivex/rxjava3/internal/functions/Functions.java @@ -17,6 +17,7 @@ import org.reactivestreams.Subscription; +import io.reactivex.rxjava3.annotations.NonNull; import io.reactivex.rxjava3.core.*; import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException; import io.reactivex.rxjava3.functions.*; @@ -33,47 +34,47 @@ private Functions() { throw new IllegalStateException("No instances!"); } - public static Function toFunction(final BiFunction f) { - Objects.requireNonNull(f, "f is null"); + @NonNull + public static Function toFunction(@NonNull BiFunction f) { return new Array2Func(f); } - public static Function toFunction(final Function3 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull + public static Function toFunction(@NonNull Function3 f) { return new Array3Func(f); } - public static Function toFunction(final Function4 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull + public static Function toFunction(@NonNull Function4 f) { return new Array4Func(f); } - public static Function toFunction(final Function5 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull + public static Function toFunction(@NonNull Function5 f) { return new Array5Func(f); } + @NonNull public static Function toFunction( - final Function6 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull Function6 f) { return new Array6Func(f); } + @NonNull public static Function toFunction( - final Function7 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull Function7 f) { return new Array7Func(f); } + @NonNull public static Function toFunction( - final Function8 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull Function8 f) { return new Array8Func(f); } + @NonNull public static Function toFunction( - final Function9 f) { - Objects.requireNonNull(f, "f is null"); + @NonNull Function9 f) { return new Array9Func(f); } @@ -86,6 +87,7 @@ public static Function toFu * @return the identity function */ @SuppressWarnings("unchecked") + @NonNull public static Function identity() { return (Function)IDENTITY; } @@ -125,16 +127,19 @@ public static Consumer emptyConsumer() { static final Comparator NATURAL_COMPARATOR = new NaturalObjectComparator(); @SuppressWarnings("unchecked") + @NonNull public static Predicate alwaysTrue() { return (Predicate)ALWAYS_TRUE; } @SuppressWarnings("unchecked") + @NonNull public static Predicate alwaysFalse() { return (Predicate)ALWAYS_FALSE; } @SuppressWarnings("unchecked") + @NonNull public static Supplier nullSupplier() { return (Supplier)NULL_SUPPLIER; } @@ -145,6 +150,7 @@ public static Supplier nullSupplier() { * @return a natural order comparator which casts the parameters to Comparable */ @SuppressWarnings("unchecked") + @NonNull public static Comparator naturalOrder() { return (Comparator)NATURAL_COMPARATOR; } @@ -167,7 +173,8 @@ public void run() throws Exception { * @param future the future to call get() on, not null * @return the new Action instance */ - public static Action futureAction(Future future) { + @NonNull + public static Action futureAction(@NonNull Future future) { return new FutureAction(future); } @@ -200,7 +207,8 @@ public U get() throws Throwable { * @param value the value to return * @return the new Callable instance */ - public static Callable justCallable(T value) { + @NonNull + public static Callable justCallable(@NonNull T value) { return new JustValue(value); } @@ -210,7 +218,8 @@ public static Callable justCallable(T value) { * @param value the value to return * @return the new Callable instance */ - public static Supplier justSupplier(T value) { + @NonNull + public static Supplier justSupplier(@NonNull T value) { return new JustValue(value); } @@ -221,7 +230,8 @@ public static Supplier justSupplier(T value) { * @param value the value to return * @return the new Function instance */ - public static Function justFunction(U value) { + @NonNull + public static Function justFunction(@NonNull U value) { return new JustValue(value); } @@ -245,7 +255,8 @@ public U apply(T t) throws Exception { * @param target the target class * @return the new Function instance */ - public static Function castFunction(Class target) { + @NonNull + public static Function castFunction(@NonNull Class target) { return new CastToClass(target); } diff --git a/src/main/java/io/reactivex/rxjava3/observables/ConnectableObservable.java b/src/main/java/io/reactivex/rxjava3/observables/ConnectableObservable.java index 1a9b942011..192743187e 100644 --- a/src/main/java/io/reactivex/rxjava3/observables/ConnectableObservable.java +++ b/src/main/java/io/reactivex/rxjava3/observables/ConnectableObservable.java @@ -56,12 +56,17 @@ public abstract class ConnectableObservable extends Observable { /** * Instructs the {@code ConnectableObservable} to begin emitting the items from its underlying * {@link Observable} to its {@link Observer}s. + *
+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* * @param connection * the action that receives the connection subscription before the subscription to source happens * allowing the caller to synchronously disconnect a synchronous source * @see ReactiveX documentation: Connect */ + @SchedulerSupport(SchedulerSupport.NONE) public abstract void connect(@NonNull Consumer connection); /** @@ -69,8 +74,13 @@ public abstract class ConnectableObservable extends Observable { * or has been disposed. *

* Calling this method on a fresh or active {@code ConnectableObservable} has no effect. + *

+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* @since 3.0.0 */ + @SchedulerSupport(SchedulerSupport.NONE) public abstract void reset(); /** @@ -78,10 +88,16 @@ public abstract class ConnectableObservable extends Observable { * {@link Observable} to its {@link Observer}s. *

* To disconnect from a synchronous source, use the {@link #connect(Consumer)} method. + *

+ *
Scheduler:
+ *
The behavior is determined by the implementor of this abstract class.
+ *
* * @return the subscription representing the connection * @see ReactiveX documentation: Connect */ + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) public final Disposable connect() { ConnectConsumer cc = new ConnectConsumer(); connect(cc); @@ -105,7 +121,7 @@ public final Disposable connect() { @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public Observable refCount() { - return RxJavaPlugins.onAssembly(new ObservableRefCount(this)); + return RxJavaPlugins.onAssembly(new ObservableRefCount<>(this)); } /** @@ -122,6 +138,7 @@ public Observable refCount() { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) + @NonNull public final Observable refCount(int subscriberCount) { return refCount(subscriberCount, 0, TimeUnit.NANOSECONDS, Schedulers.trampoline()); } @@ -143,7 +160,8 @@ public final Observable refCount(int subscriberCount) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable refCount(long timeout, TimeUnit unit) { + @NonNull + public final Observable refCount(long timeout, @NonNull TimeUnit unit) { return refCount(1, timeout, unit, Schedulers.computation()); } @@ -164,7 +182,8 @@ public final Observable refCount(long timeout, TimeUnit unit) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable refCount(long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable refCount(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { return refCount(1, timeout, unit, scheduler); } @@ -186,7 +205,8 @@ public final Observable refCount(long timeout, TimeUnit unit, Scheduler sched */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) - public final Observable refCount(int subscriberCount, long timeout, TimeUnit unit) { + @NonNull + public final Observable refCount(int subscriberCount, long timeout, @NonNull TimeUnit unit) { return refCount(subscriberCount, timeout, unit, Schedulers.computation()); } @@ -208,11 +228,12 @@ public final Observable refCount(int subscriberCount, long timeout, TimeUnit */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final Observable refCount(int subscriberCount, long timeout, TimeUnit unit, Scheduler scheduler) { + @NonNull + public final Observable refCount(int subscriberCount, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { ObjectHelper.verifyPositive(subscriberCount, "subscriberCount"); Objects.requireNonNull(unit, "unit is null"); Objects.requireNonNull(scheduler, "scheduler is null"); - return RxJavaPlugins.onAssembly(new ObservableRefCount(this, subscriberCount, timeout, unit, scheduler)); + return RxJavaPlugins.onAssembly(new ObservableRefCount<>(this, subscriberCount, timeout, unit, scheduler)); } /** @@ -230,11 +251,17 @@ public final Observable refCount(int subscriberCount, long timeout, TimeUnit * This overload does not allow disconnecting the connection established via * {@link #connect(Consumer)}. Use the {@link #autoConnect(int, Consumer)} overload * to gain access to the {@code Disposable} representing the only connection. + *
+ *
Scheduler:
+ *
{@code autoConnect} overload does not operate on any particular {@link Scheduler}.
+ *
* * @return an Observable that automatically connects to this ConnectableObservable * when the first Observer subscribes */ @NonNull + @CheckReturnValue + @SchedulerSupport(SchedulerSupport.NONE) public Observable autoConnect() { return autoConnect(1); } @@ -254,6 +281,10 @@ public Observable autoConnect() { * This overload does not allow disconnecting the connection established via * {@link #connect(Consumer)}. Use the {@link #autoConnect(int, Consumer)} overload * to gain access to the {@code Disposable} representing the only connection. + *
+ *
Scheduler:
+ *
{@code autoConnect} overload does not operate on any particular {@link Scheduler}.
+ *
* * @param numberOfSubscribers the number of subscribers to await before calling connect * on the ConnectableObservable. A non-positive value indicates @@ -262,6 +293,8 @@ public Observable autoConnect() { * when the specified number of Subscribers subscribe to it */ @NonNull + @CheckReturnValue + @SchedulerSupport(SchedulerSupport.NONE) public Observable autoConnect(int numberOfSubscribers) { return autoConnect(numberOfSubscribers, Functions.emptyConsumer()); } @@ -278,6 +311,10 @@ public Observable autoConnect(int numberOfSubscribers) { * terminates, the connection is never renewed, no matter how Observers come * and go. Use {@link #refCount()} to renew a connection or dispose an active * connection when all {@code Observer}s have disposed their {@code Disposable}s. + *
+ *
Scheduler:
+ *
{@code autoConnect} overload does not operate on any particular {@link Scheduler}.
+ *
* * @param numberOfSubscribers the number of subscribers to await before calling connect * on the ConnectableObservable. A non-positive value indicates @@ -289,11 +326,13 @@ public Observable autoConnect(int numberOfSubscribers) { * specified callback with the Subscription associated with the established connection */ @NonNull + @CheckReturnValue + @SchedulerSupport(SchedulerSupport.NONE) public Observable autoConnect(int numberOfSubscribers, @NonNull Consumer connection) { if (numberOfSubscribers <= 0) { this.connect(connection); return RxJavaPlugins.onAssembly(this); } - return RxJavaPlugins.onAssembly(new ObservableAutoConnect(this, numberOfSubscribers, connection)); + return RxJavaPlugins.onAssembly(new ObservableAutoConnect<>(this, numberOfSubscribers, connection)); } } diff --git a/src/main/java/io/reactivex/rxjava3/parallel/ParallelFlowable.java b/src/main/java/io/reactivex/rxjava3/parallel/ParallelFlowable.java index afa2eddcf0..d4dff1cbb0 100644 --- a/src/main/java/io/reactivex/rxjava3/parallel/ParallelFlowable.java +++ b/src/main/java/io/reactivex/rxjava3/parallel/ParallelFlowable.java @@ -37,22 +37,31 @@ * @param the value type * @since 2.2 */ -public abstract class ParallelFlowable { +public abstract class ParallelFlowable<@NonNull T> { /** * Subscribes an array of Subscribers to this ParallelFlowable and triggers * the execution chain for all 'rails'. + *
+ *
Backpressure:
+ *
The backpressure behavior/expectation is determined by the supplied {@code Subscriber}.
+ *
Scheduler:
+ *
{@code subscribe} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param subscribers the subscribers array to run in parallel, the number * of items must be equal to the parallelism level of this ParallelFlowable * @see #parallelism() */ + @BackpressureSupport(BackpressureKind.SPECIAL) + @SchedulerSupport(SchedulerSupport.NONE) public abstract void subscribe(@NonNull Subscriber[] subscribers); /** * Returns the number of expected parallel Subscribers. * @return the number of expected parallel Subscribers */ + @CheckReturnValue public abstract int parallelism(); /** @@ -77,24 +86,46 @@ protected final boolean validate(@NonNull Subscriber[] subscribers) { /** * Take a Publisher and prepare to consume it on multiple 'rails' (number of CPUs) * in a round-robin fashion. + *
+ *
Backpressure:
+ *
The operator honors the backpressure of the parallel rails and + * requests {@link Flowable#bufferSize} amount from the upstream, followed + * by 75% of that amount requested after every 75% received.
+ *
Scheduler:
+ *
{@code from} does not operate by default on a particular {@link Scheduler}.
+ *
* @param the value type * @param source the source Publisher * @return the ParallelFlowable instance */ @CheckReturnValue + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.FULL) public static ParallelFlowable from(@NonNull Publisher source) { return from(source, Runtime.getRuntime().availableProcessors(), Flowable.bufferSize()); } /** * Take a Publisher and prepare to consume it on parallelism number of 'rails' in a round-robin fashion. + *
+ *
Backpressure:
+ *
The operator honors the backpressure of the parallel rails and + * requests {@link Flowable#bufferSize} amount from the upstream, followed + * by 75% of that amount requested after every 75% received.
+ *
Scheduler:
+ *
{@code from} does not operate by default on a particular {@link Scheduler}.
+ *
* @param the value type * @param source the source Publisher * @param parallelism the number of parallel rails * @return the new ParallelFlowable instance */ @CheckReturnValue - public static ParallelFlowable from(@NonNull Publisher source, int parallelism) { + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.FULL) + public static <@NonNull T> ParallelFlowable from(@NonNull Publisher source, int parallelism) { return from(source, parallelism, Flowable.bufferSize()); } @@ -102,6 +133,14 @@ public static ParallelFlowable from(@NonNull Publisher sourc * Take a Publisher and prepare to consume it on parallelism number of 'rails' , * possibly ordered and round-robin fashion and use custom prefetch amount and queue * for dealing with the source Publisher's values. + *
+ *
Backpressure:
+ *
The operator honors the backpressure of the parallel rails and + * requests the {@code prefetch} amount from the upstream, followed + * by 75% of that amount requested after every 75% received.
+ *
Scheduler:
+ *
{@code from} does not operate by default on a particular {@link Scheduler}.
+ *
* @param the value type * @param source the source Publisher * @param parallelism the number of parallel rails @@ -111,7 +150,9 @@ public static ParallelFlowable from(@NonNull Publisher sourc */ @CheckReturnValue @NonNull - public static ParallelFlowable from(@NonNull Publisher source, + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.FULL) + public static <@NonNull T> ParallelFlowable from(@NonNull Publisher source, int parallelism, int prefetch) { Objects.requireNonNull(source, "source"); ObjectHelper.verifyPositive(parallelism, "parallelism"); @@ -124,12 +165,21 @@ public static ParallelFlowable from(@NonNull Publisher sourc * Maps the source values on each 'rail' to another value. *

* Note that the same mapper function may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* @param the output value type * @param mapper the mapper function turning Ts into Us. * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.PASS_THROUGH) public final ParallelFlowable map(@NonNull Function mapper) { Objects.requireNonNull(mapper, "mapper"); return RxJavaPlugins.onAssembly(new ParallelMap(this, mapper)); @@ -140,6 +190,13 @@ public final ParallelFlowable map(@NonNull Function * Note that the same mapper function may be called from multiple threads concurrently. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param the output value type * @param mapper the mapper function turning Ts into Us. @@ -150,6 +207,8 @@ public final ParallelFlowable map(@NonNull Function ParallelFlowable map(@NonNull Function mapper, @NonNull ParallelFailureHandling errorHandler) { Objects.requireNonNull(mapper, "mapper"); Objects.requireNonNull(errorHandler, "errorHandler is null"); @@ -161,6 +220,13 @@ public final ParallelFlowable map(@NonNull Function * Note that the same mapper function may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param the output value type * @param mapper the mapper function turning Ts into Us. @@ -172,6 +238,8 @@ public final ParallelFlowable map(@NonNull Function ParallelFlowable map(@NonNull Function mapper, @NonNull BiFunction errorHandler) { Objects.requireNonNull(mapper, "mapper"); Objects.requireNonNull(errorHandler, "errorHandler is null"); @@ -182,13 +250,23 @@ public final ParallelFlowable map(@NonNull Function * Note that the same predicate may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code filter} does not operate by default on a particular {@link Scheduler}.
+ *
* @param predicate the function returning true to keep a value or false to drop a value * @return the new ParallelFlowable instance */ @CheckReturnValue + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.PASS_THROUGH) public final ParallelFlowable filter(@NonNull Predicate predicate) { Objects.requireNonNull(predicate, "predicate"); - return RxJavaPlugins.onAssembly(new ParallelFilter(this, predicate)); + return RxJavaPlugins.onAssembly(new ParallelFilter<>(this, predicate)); } /** @@ -196,6 +274,13 @@ public final ParallelFlowable filter(@NonNull Predicate predicate) * handles errors based on the given {@link ParallelFailureHandling} enumeration value. *

* Note that the same predicate may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code filter} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param predicate the function returning true to keep a value or false to drop a value * @param errorHandler the enumeration that defines how to handle errors thrown @@ -204,10 +289,13 @@ public final ParallelFlowable filter(@NonNull Predicate predicate) * @since 2.2 */ @CheckReturnValue + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.PASS_THROUGH) public final ParallelFlowable filter(@NonNull Predicate predicate, @NonNull ParallelFailureHandling errorHandler) { Objects.requireNonNull(predicate, "predicate"); Objects.requireNonNull(errorHandler, "errorHandler is null"); - return RxJavaPlugins.onAssembly(new ParallelFilterTry(this, predicate, errorHandler)); + return RxJavaPlugins.onAssembly(new ParallelFilterTry<>(this, predicate, errorHandler)); } /** @@ -215,6 +303,13 @@ public final ParallelFlowable filter(@NonNull Predicate predicate, * handles errors based on the returned value by the handler function. *

* Note that the same predicate may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param predicate the function returning true to keep a value or false to drop a value * @param errorHandler the function called with the current repeat count and @@ -224,10 +319,13 @@ public final ParallelFlowable filter(@NonNull Predicate predicate, * @since 2.2 */ @CheckReturnValue + @NonNull + @SchedulerSupport(SchedulerSupport.NONE) + @BackpressureSupport(BackpressureKind.PASS_THROUGH) public final ParallelFlowable filter(@NonNull Predicate predicate, @NonNull BiFunction errorHandler) { Objects.requireNonNull(predicate, "predicate"); Objects.requireNonNull(errorHandler, "errorHandler is null"); - return RxJavaPlugins.onAssembly(new ParallelFilterTry(this, predicate, errorHandler)); + return RxJavaPlugins.onAssembly(new ParallelFilterTry<>(this, predicate, errorHandler)); } /** @@ -245,12 +343,23 @@ public final ParallelFlowable filter(@NonNull Predicate predicate, *

* This operator doesn't require the Scheduler to be trampolining as it * does its own built-in trampolining logic. + *

+ *
Backpressure:
+ *
The operator honors the backpressure of the parallel rails and + * requests {@link Flowable#bufferSize} amount from the upstream, followed + * by 75% of that amount requested after every 75% received.
+ *
Scheduler:
+ *
{@code runOn} drains the upstream rails on the specified {@link Scheduler}'s + * {@link io.reactivex.rxjava3.core.Scheduler.Worker Worker}s.
+ *
* * @param scheduler the scheduler to use * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.CUSTOM) public final ParallelFlowable runOn(@NonNull Scheduler scheduler) { return runOn(scheduler, Flowable.bufferSize()); } @@ -270,6 +379,15 @@ public final ParallelFlowable runOn(@NonNull Scheduler scheduler) { *

* This operator doesn't require the Scheduler to be trampolining as it * does its own built-in trampolining logic. + *

+ *
Backpressure:
+ *
The operator honors the backpressure of the parallel rails and + * requests the {@code prefetch} amount from the upstream, followed + * by 75% of that amount requested after every 75% received.
+ *
Scheduler:
+ *
{@code runOn} drains the upstream rails on the specified {@link Scheduler}'s + * {@link io.reactivex.rxjava3.core.Scheduler.Worker Worker}s.
+ *
* * @param scheduler the scheduler to use * that rail's worker has run out of work. @@ -278,10 +396,12 @@ public final ParallelFlowable runOn(@NonNull Scheduler scheduler) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.CUSTOM) public final ParallelFlowable runOn(@NonNull Scheduler scheduler, int prefetch) { Objects.requireNonNull(scheduler, "scheduler"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelRunOn(this, scheduler, prefetch)); + return RxJavaPlugins.onAssembly(new ParallelRunOn<>(this, scheduler, prefetch)); } /** @@ -289,14 +409,23 @@ public final ParallelFlowable runOn(@NonNull Scheduler scheduler, int prefetc * sequential value. *

* Note that the same reducer function may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream and consumes + * the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code reduce} does not operate by default on a particular {@link Scheduler}.
+ *
* @param reducer the function to reduce two values into one. * @return the new Flowable instance emitting the reduced value or empty if the ParallelFlowable was empty */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final Flowable reduce(@NonNull BiFunction reducer) { Objects.requireNonNull(reducer, "reducer"); - return RxJavaPlugins.onAssembly(new ParallelReduceFull(this, reducer)); + return RxJavaPlugins.onAssembly(new ParallelReduceFull<>(this, reducer)); } /** @@ -304,6 +433,13 @@ public final Flowable reduce(@NonNull BiFunction reducer) { * a reducer function that is initialized on each rail from an initialSupplier value. *

* Note that the same mapper function may be called from multiple threads concurrently. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and consumes + * the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code reduce} does not operate by default on a particular {@link Scheduler}.
+ *
* @param the reduced output type * @param initialSupplier the supplier for the initial value * @param reducer the function to reduce a previous output of reduce (or the initial value supplied) @@ -312,10 +448,12 @@ public final Flowable reduce(@NonNull BiFunction reducer) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable reduce(@NonNull Supplier initialSupplier, @NonNull BiFunction reducer) { Objects.requireNonNull(initialSupplier, "initialSupplier"); Objects.requireNonNull(reducer, "reducer"); - return RxJavaPlugins.onAssembly(new ParallelReduce(this, initialSupplier, reducer)); + return RxJavaPlugins.onAssembly(new ParallelReduce<>(this, initialSupplier, reducer)); } /** @@ -327,7 +465,9 @@ public final ParallelFlowable reduce(@NonNull Supplier initialSupplier * *
*
Backpressure:
- *
The operator honors backpressure.
+ *
The operator honors backpressure from the downstream and + * requests {@link Flowable#bufferSize()} amount from each rail, then + * requests from each rail 75% of this amount after 75% received.
*
Scheduler:
*
{@code sequential} does not operate by default on a particular {@link Scheduler}.
*
@@ -338,6 +478,7 @@ public final ParallelFlowable reduce(@NonNull Supplier initialSupplier @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) @CheckReturnValue + @NonNull public final Flowable sequential() { return sequential(Flowable.bufferSize()); } @@ -349,7 +490,9 @@ public final Flowable sequential() { * *
*
Backpressure:
- *
The operator honors backpressure.
+ *
The operator honors backpressure from the downstream and + * requests the {@code prefetch} amount from each rail, then + * requests from each rail 75% of this amount after 75% received.
*
Scheduler:
*
{@code sequential} does not operate by default on a particular {@link Scheduler}.
*
@@ -364,7 +507,7 @@ public final Flowable sequential() { @NonNull public final Flowable sequential(int prefetch) { ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelJoin(this, prefetch, false)); + return RxJavaPlugins.onAssembly(new ParallelJoin<>(this, prefetch, false)); } /** @@ -376,7 +519,9 @@ public final Flowable sequential(int prefetch) { * *
*
Backpressure:
- *
The operator honors backpressure.
+ *
The operator honors backpressure from the downstream and + * requests {@link Flowable#bufferSize()} amount from each rail, then + * requests from each rail 75% of this amount after 75% received.
*
Scheduler:
*
{@code sequentialDelayError} does not operate by default on a particular {@link Scheduler}.
*
@@ -401,7 +546,9 @@ public final Flowable sequentialDelayError() { * *
*
Backpressure:
- *
The operator honors backpressure.
+ *
The operator honors backpressure from the downstream and + * requests the {@code prefetch} amount from each rail, then + * requests from each rail 75% of this amount after 75% received.
*
Scheduler:
*
{@code sequentialDelayError} does not operate by default on a particular {@link Scheduler}.
*
@@ -418,7 +565,7 @@ public final Flowable sequentialDelayError() { @NonNull public final Flowable sequentialDelayError(int prefetch) { ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelJoin(this, prefetch, true)); + return RxJavaPlugins.onAssembly(new ParallelJoin<>(this, prefetch, true)); } /** @@ -426,12 +573,21 @@ public final Flowable sequentialDelayError(int prefetch) { * picks the smallest next value from the rails. *

* This operator requires a finite source ParallelFlowable. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream and + * consumes the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code sorted} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param comparator the comparator to use * @return the new Flowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final Flowable sorted(@NonNull Comparator comparator) { return sorted(comparator, 16); } @@ -441,6 +597,13 @@ public final Flowable sorted(@NonNull Comparator comparator) { * picks the smallest next value from the rails. *

* This operator requires a finite source ParallelFlowable. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream and + * consumes the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code sorted} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param comparator the comparator to use * @param capacityHint the expected number of total elements @@ -448,6 +611,8 @@ public final Flowable sorted(@NonNull Comparator comparator) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final Flowable sorted(@NonNull Comparator comparator, int capacityHint) { Objects.requireNonNull(comparator, "comparator is null"); ObjectHelper.verifyPositive(capacityHint, "capacityHint"); @@ -455,19 +620,28 @@ public final Flowable sorted(@NonNull Comparator comparator, int c ParallelFlowable> railReduced = reduce(Functions.createArrayList(ch), ListAddBiConsumer.instance()); ParallelFlowable> railSorted = railReduced.map(new SorterFunction(comparator)); - return RxJavaPlugins.onAssembly(new ParallelSortedJoin(railSorted, comparator)); + return RxJavaPlugins.onAssembly(new ParallelSortedJoin<>(railSorted, comparator)); } /** * Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher. *

* This operator requires a finite source ParallelFlowable. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream and + * consumes the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code toSortedList} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param comparator the comparator to compare elements * @return the new Flowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final Flowable> toSortedList(@NonNull Comparator comparator) { return toSortedList(comparator, 16); } @@ -475,6 +649,13 @@ public final Flowable> toSortedList(@NonNull Comparator compa * Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher. *

* This operator requires a finite source ParallelFlowable. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream and + * consumes the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code toSortedList} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param comparator the comparator to compare elements * @param capacityHint the expected number of total elements @@ -482,7 +663,9 @@ public final Flowable> toSortedList(@NonNull Comparator compa */ @CheckReturnValue @NonNull - public final Flowable> toSortedList(@NonNull Comparator comparator, int capacityHint) { + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) + public final Flowable<@NonNull List> toSortedList(@NonNull Comparator comparator, int capacityHint) { Objects.requireNonNull(comparator, "comparator is null"); ObjectHelper.verifyPositive(capacityHint, "capacityHint"); @@ -497,15 +680,24 @@ public final Flowable> toSortedList(@NonNull Comparator compa /** * Call the specified consumer with the current element passing through any 'rail'. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onNext the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnNext(@NonNull Consumer onNext) { Objects.requireNonNull(onNext, "onNext is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, onNext, Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -520,6 +712,13 @@ public final ParallelFlowable doOnNext(@NonNull Consumer onNext) { /** * Call the specified consumer with the current element passing through any 'rail' and * handles errors based on the given {@link ParallelFailureHandling} enumeration value. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param onNext the callback * @param errorHandler the enumeration that defines how to handle errors thrown @@ -529,15 +728,24 @@ public final ParallelFlowable doOnNext(@NonNull Consumer onNext) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnNext(@NonNull Consumer onNext, @NonNull ParallelFailureHandling errorHandler) { Objects.requireNonNull(onNext, "onNext is null"); Objects.requireNonNull(errorHandler, "errorHandler is null"); - return RxJavaPlugins.onAssembly(new ParallelDoOnNextTry(this, onNext, errorHandler)); + return RxJavaPlugins.onAssembly(new ParallelDoOnNextTry<>(this, onNext, errorHandler)); } /** * Call the specified consumer with the current element passing through any 'rail' and * handles errors based on the returned value by the handler function. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.0.8 - experimental * @param onNext the callback * @param errorHandler the function called with the current repeat count and @@ -548,24 +756,35 @@ public final ParallelFlowable doOnNext(@NonNull Consumer onNext, @ */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnNext(@NonNull Consumer onNext, @NonNull BiFunction errorHandler) { Objects.requireNonNull(onNext, "onNext is null"); Objects.requireNonNull(errorHandler, "errorHandler is null"); - return RxJavaPlugins.onAssembly(new ParallelDoOnNextTry(this, onNext, errorHandler)); + return RxJavaPlugins.onAssembly(new ParallelDoOnNextTry<>(this, onNext, errorHandler)); } /** * Call the specified consumer with the current element passing through any 'rail' * after it has been delivered to downstream within the rail. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onAfterNext the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doAfterNext(@NonNull Consumer onAfterNext) { Objects.requireNonNull(onAfterNext, "onAfterNext is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), onAfterNext, Functions.emptyConsumer(), @@ -579,15 +798,24 @@ public final ParallelFlowable doAfterNext(@NonNull Consumer onAfte /** * Call the specified consumer with the exception passing through any 'rail'. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onError the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnError(@NonNull Consumer onError) { Objects.requireNonNull(onError, "onError is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), onError, @@ -601,15 +829,24 @@ public final ParallelFlowable doOnError(@NonNull Consumer onError) /** * Run the specified Action when a 'rail' completes. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onComplete the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnComplete(@NonNull Action onComplete) { Objects.requireNonNull(onComplete, "onComplete is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -623,15 +860,24 @@ public final ParallelFlowable doOnComplete(@NonNull Action onComplete) { /** * Run the specified Action when a 'rail' completes or signals an error. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onAfterTerminate the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doAfterTerminated(@NonNull Action onAfterTerminate) { Objects.requireNonNull(onAfterTerminate, "onAfterTerminate is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -645,15 +891,24 @@ public final ParallelFlowable doAfterTerminated(@NonNull Action onAfterTermin /** * Call the specified callback when a 'rail' receives a Subscription from its upstream. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onSubscribe the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnSubscribe(@NonNull Consumer onSubscribe) { Objects.requireNonNull(onSubscribe, "onSubscribe is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -667,15 +922,24 @@ public final ParallelFlowable doOnSubscribe(@NonNull Consumer + *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ * * * @param onRequest the callback * @return the new ParallelFlowable instance */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable doOnRequest(@NonNull LongConsumer onRequest) { Objects.requireNonNull(onRequest, "onRequest is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -689,15 +953,24 @@ public final ParallelFlowable doOnRequest(@NonNull LongConsumer onRequest) { /** * Run the specified Action when a 'rail' receives a cancellation. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param onCancel the callback * @return the new ParallelFlowable instance */ + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) @CheckReturnValue @NonNull public final ParallelFlowable doOnCancel(@NonNull Action onCancel) { Objects.requireNonNull(onCancel, "onCancel is null"); - return RxJavaPlugins.onAssembly(new ParallelPeek(this, + return RxJavaPlugins.onAssembly(new ParallelPeek<>(this, Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -712,6 +985,13 @@ public final ParallelFlowable doOnCancel(@NonNull Action onCancel) { /** * Collect the elements in each rail into a collection supplied via a collectionSupplier * and collected into with a collector action, emitting the collection at the end. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * consumes the upstream rails in an unbounded manner (requesting {@link Long#MAX_VALUE}).
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the collection type * @param collectionSupplier the supplier of the collection in each rail @@ -720,6 +1000,8 @@ public final ParallelFlowable doOnCancel(@NonNull Action onCancel) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable collect(@NonNull Supplier collectionSupplier, @NonNull BiConsumer collector) { Objects.requireNonNull(collectionSupplier, "collectionSupplier is null"); Objects.requireNonNull(collector, "collector is null"); @@ -729,6 +1011,13 @@ public final ParallelFlowable collect(@NonNull Supplier coll /** * Wraps multiple Publishers into a ParallelFlowable which runs them * in parallel and unordered. + *
+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by the upstream and downstream rail behaviors.
+ *
Scheduler:
+ *
{@code map} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the value type * @param publishers the array of publishers @@ -736,17 +1025,27 @@ public final ParallelFlowable collect(@NonNull Supplier coll */ @CheckReturnValue @NonNull - public static ParallelFlowable fromArray(@NonNull Publisher... publishers) { + @SafeVarargs + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) + public static <@NonNull T> ParallelFlowable fromArray(@NonNull Publisher... publishers) { if (publishers.length == 0) { throw new IllegalArgumentException("Zero publishers not supported"); } - return RxJavaPlugins.onAssembly(new ParallelFromArray(publishers)); + return RxJavaPlugins.onAssembly(new ParallelFromArray<>(publishers)); } /** * Calls the specified converter function during assembly time and returns its resulting value. *

* This allows fluent conversion to any other type. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by how the converter function composes over the upstream source.
+ *
Scheduler:
+ *
{@code to} does not operate by default on a particular {@link Scheduler}.
+ *
*

History: 2.1.7 - experimental * @param the resulting object type * @param converter the function that receives the current ParallelFlowable instance and returns a value @@ -756,13 +1055,22 @@ public static ParallelFlowable fromArray(@NonNull Publisher... publish */ @CheckReturnValue @NonNull - public final R to(@NonNull ParallelFlowableConverter converter) { + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) + public final <@NonNull R> R to(@NonNull ParallelFlowableConverter converter) { return Objects.requireNonNull(converter, "converter is null").apply(this); } /** * Allows composing operators, in assembly time, on top of this ParallelFlowable * and returns another ParallelFlowable with composed features. + *

+ *
Backpressure:
+ *
The operator is a pass-through for backpressure and the behavior + * is determined by how the converter function composes over the upstream source.
+ *
Scheduler:
+ *
{@code compose} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the output value type * @param composer the composer function from ParallelFlowable (this) to another ParallelFlowable @@ -770,6 +1078,8 @@ public final R to(@NonNull ParallelFlowableConverter converter) { */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.PASS_THROUGH) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable compose(@NonNull ParallelTransformer composer) { return RxJavaPlugins.onAssembly(Objects.requireNonNull(composer, "composer is null").apply(this)); } @@ -778,6 +1088,16 @@ public final ParallelFlowable compose(@NonNull ParallelTransformer * Generates and flattens Publishers on each 'rail'. *

* Errors are not delayed and uses unbounded concurrency along with default inner prefetch. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests {@link Flowable#bufferSize()} amount from each rail upfront + * and keeps requesting as many items per rail as many inner sources on + * that rail completed. The inner sources are requested {@link Flowable#bufferSize()} + * amount upfront, then 75% of this amount requested after 75% received. + *
Scheduler:
+ *
{@code flatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -785,14 +1105,27 @@ public final ParallelFlowable compose(@NonNull ParallelTransformer */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable flatMap(@NonNull Function> mapper) { - return flatMap(mapper, false, Integer.MAX_VALUE, Flowable.bufferSize()); + return flatMap(mapper, false, Flowable.bufferSize(), Flowable.bufferSize()); } /** * Generates and flattens Publishers on each 'rail', optionally delaying errors. *

* It uses unbounded concurrency along with default inner prefetch. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests {@link Flowable#bufferSize()} amount from each rail upfront + * and keeps requesting as many items per rail as many inner sources on + * that rail completed. The inner sources are requested {@link Flowable#bufferSize()} + * amount upfront, then 75% of this amount requested after 75% received. + *
+ *
Scheduler:
+ *
{@code flatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -801,9 +1134,11 @@ public final ParallelFlowable flatMap(@NonNull Function ParallelFlowable flatMap( @NonNull Function> mapper, boolean delayError) { - return flatMap(mapper, delayError, Integer.MAX_VALUE, Flowable.bufferSize()); + return flatMap(mapper, delayError, Flowable.bufferSize(), Flowable.bufferSize()); } /** @@ -811,6 +1146,17 @@ public final ParallelFlowable flatMap( * and having a total number of simultaneous subscriptions to the inner Publishers. *

* It uses a default inner prefetch. + *

+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests {@code maxConcurrency} amount from each rail upfront + * and keeps requesting as many items per rail as many inner sources on + * that rail completed. The inner sources are requested {@link Flowable#bufferSize()} + * amount upfront, then 75% of this amount requested after 75% received. + *
+ *
Scheduler:
+ *
{@code flatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -820,6 +1166,8 @@ public final ParallelFlowable flatMap( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable flatMap( @NonNull Function> mapper, boolean delayError, int maxConcurrency) { return flatMap(mapper, delayError, maxConcurrency, Flowable.bufferSize()); @@ -829,6 +1177,17 @@ public final ParallelFlowable flatMap( * Generates and flattens Publishers on each 'rail', optionally delaying errors, * having a total number of simultaneous subscriptions to the inner Publishers * and using the given prefetch amount for the inner Publishers. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests {@code maxConcurrency} amount from each rail upfront + * and keeps requesting as many items per rail as many inner sources on + * that rail completed. The inner sources are requested the {@code prefetch} + * amount upfront, then 75% of this amount requested after 75% received. + *
+ *
Scheduler:
+ *
{@code flatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -839,18 +1198,29 @@ public final ParallelFlowable flatMap( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable flatMap( @NonNull Function> mapper, boolean delayError, int maxConcurrency, int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelFlatMap(this, mapper, delayError, maxConcurrency, prefetch)); + return RxJavaPlugins.onAssembly(new ParallelFlatMap<>(this, mapper, delayError, maxConcurrency, prefetch)); } /** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and generating 2 publishers upfront. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests 2 from each rail upfront and keeps requesting 1 when the inner source complete. + * Requests for the inner sources are determined by the downstream rails' + * backpressure behavior.
+ *
Scheduler:
+ *
{@code concatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -859,6 +1229,8 @@ public final ParallelFlowable flatMap( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable concatMap( @NonNull Function> mapper) { return concatMap(mapper, 2); @@ -867,6 +1239,16 @@ public final ParallelFlowable concatMap( /** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and using the given prefetch amount for generating Publishers upfront. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests the {@code prefetch} amount from each rail upfront and keeps + * requesting 75% of this amount after 75% received and the inner sources completed. + * Requests for the inner sources are determined by the downstream rails' + * backpressure behavior.
+ *
Scheduler:
+ *
{@code concatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -876,17 +1258,28 @@ public final ParallelFlowable concatMap( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable concatMap( @NonNull Function> mapper, - int prefetch) { + int prefetch) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelConcatMap(this, mapper, prefetch, ErrorMode.IMMEDIATE)); + return RxJavaPlugins.onAssembly(new ParallelConcatMap<>(this, mapper, prefetch, ErrorMode.IMMEDIATE)); } /** * Generates and concatenates Publishers on each 'rail', optionally delaying errors * and generating 2 publishers upfront. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests 2 from each rail upfront and keeps requesting 1 when the inner source complete. + * Requests for the inner sources are determined by the downstream rails' + * backpressure behavior.
+ *
Scheduler:
+ *
{@code concatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -897,6 +1290,8 @@ public final ParallelFlowable concatMap( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable concatMapDelayError( @NonNull Function> mapper, boolean tillTheEnd) { @@ -906,6 +1301,16 @@ public final ParallelFlowable concatMapDelayError( /** * Generates and concatenates Publishers on each 'rail', optionally delaying errors * and using the given prefetch amount for generating Publishers upfront. + *
+ *
Backpressure:
+ *
The operator honors backpressure from the downstream rails and + * requests the {@code prefetch} amount from each rail upfront and keeps + * requesting 75% of this amount after 75% received and the inner sources completed. + * Requests for the inner sources are determined by the downstream rails' + * backpressure behavior.
+ *
Scheduler:
+ *
{@code concatMap} does not operate by default on a particular {@link Scheduler}.
+ *
* * @param the result type * @param mapper the function to map each rail's value into a Publisher @@ -916,12 +1321,14 @@ public final ParallelFlowable concatMapDelayError( */ @CheckReturnValue @NonNull + @BackpressureSupport(BackpressureKind.FULL) + @SchedulerSupport(SchedulerSupport.NONE) public final ParallelFlowable concatMapDelayError( @NonNull Function> mapper, int prefetch, boolean tillTheEnd) { Objects.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - return RxJavaPlugins.onAssembly(new ParallelConcatMap( + return RxJavaPlugins.onAssembly(new ParallelConcatMap<>( this, mapper, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY)); } } diff --git a/src/main/java/io/reactivex/rxjava3/processors/AsyncProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/AsyncProcessor.java index 9491773080..3461c146d6 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/AsyncProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/AsyncProcessor.java @@ -137,7 +137,7 @@ public final class AsyncProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static AsyncProcessor create() { - return new AsyncProcessor(); + return new AsyncProcessor<>(); } /** @@ -146,7 +146,7 @@ public static AsyncProcessor create() { */ @SuppressWarnings("unchecked") AsyncProcessor() { - this.subscribers = new AtomicReference[]>(EMPTY); + this.subscribers = new AtomicReference<>(EMPTY); } @Override @@ -203,29 +203,33 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasSubscribers() { return subscribers.get().length != 0; } @Override + @CheckReturnValue public boolean hasThrowable() { return subscribers.get() == TERMINATED && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return subscribers.get() == TERMINATED && error == null; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { return subscribers.get() == TERMINATED ? error : null; } @Override protected void subscribeActual(Subscriber s) { - AsyncSubscription as = new AsyncSubscription(s, this); + AsyncSubscription as = new AsyncSubscription<>(s, this); s.onSubscribe(as); if (add(as)) { if (as.isCancelled()) { @@ -316,6 +320,7 @@ void remove(AsyncSubscription ps) { *

The method is thread-safe. * @return true if this processor has any value */ + @CheckReturnValue public boolean hasValue() { return subscribers.get() == TERMINATED && value != null; } @@ -326,6 +331,7 @@ public boolean hasValue() { * @return a single value this processor currently has or null if no such value exists */ @Nullable + @CheckReturnValue public T getValue() { return subscribers.get() == TERMINATED ? value : null; } diff --git a/src/main/java/io/reactivex/rxjava3/processors/BehaviorProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/BehaviorProcessor.java index 4b85ff5ab0..ab4c517e65 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/BehaviorProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/BehaviorProcessor.java @@ -191,7 +191,7 @@ public final class BehaviorProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static BehaviorProcessor create() { - return new BehaviorProcessor(); + return new BehaviorProcessor<>(); } /** @@ -207,9 +207,9 @@ public static BehaviorProcessor create() { */ @CheckReturnValue @NonNull - public static BehaviorProcessor createDefault(T defaultValue) { + public static <@NonNull T> BehaviorProcessor createDefault(T defaultValue) { Objects.requireNonNull(defaultValue, "defaultValue is null"); - return new BehaviorProcessor(defaultValue); + return new BehaviorProcessor<>(defaultValue); } /** @@ -218,12 +218,12 @@ public static BehaviorProcessor createDefault(T defaultValue) { */ @SuppressWarnings("unchecked") BehaviorProcessor() { - this.value = new AtomicReference(); + this.value = new AtomicReference<>(); this.lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); - this.subscribers = new AtomicReference[]>(EMPTY); - this.terminalEvent = new AtomicReference(); + this.subscribers = new AtomicReference<>(EMPTY); + this.terminalEvent = new AtomicReference<>(); } /** @@ -239,7 +239,7 @@ public static BehaviorProcessor createDefault(T defaultValue) { @Override protected void subscribeActual(Subscriber s) { - BehaviorSubscription bs = new BehaviorSubscription(s, this); + BehaviorSubscription bs = new BehaviorSubscription<>(s, this); s.onSubscribe(bs); if (add(bs)) { if (bs.cancelled) { @@ -318,6 +318,7 @@ public void onComplete() { * @return true if the item was emitted to all Subscribers * @since 2.2 */ + @CheckReturnValue public boolean offer(T t) { if (t == null) { onError(ExceptionHelper.createNullPointerException("offer called with a null value.")); @@ -340,16 +341,19 @@ public boolean offer(T t) { } @Override + @CheckReturnValue public boolean hasSubscribers() { return subscribers.get().length != 0; } + @CheckReturnValue /* test support*/ int subscriberCount() { return subscribers.get().length; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { Object o = value.get(); if (NotificationLite.isError(o)) { @@ -364,6 +368,7 @@ public Throwable getThrowable() { * @return a single value the BehaviorProcessor currently has or null if no such value exists */ @Nullable + @CheckReturnValue public T getValue() { Object o = value.get(); if (NotificationLite.isComplete(o) || NotificationLite.isError(o)) { @@ -373,12 +378,14 @@ public T getValue() { } @Override + @CheckReturnValue public boolean hasComplete() { Object o = value.get(); return NotificationLite.isComplete(o); } @Override + @CheckReturnValue public boolean hasThrowable() { Object o = value.get(); return NotificationLite.isError(o); @@ -389,6 +396,7 @@ public boolean hasThrowable() { *

The method is thread-safe. * @return true if the BehaviorProcessor has any value */ + @CheckReturnValue public boolean hasValue() { Object o = value.get(); return o != null && !NotificationLite.isComplete(o) && !NotificationLite.isError(o); @@ -554,7 +562,7 @@ void emitNext(Object value, long stateIndex) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(value); diff --git a/src/main/java/io/reactivex/rxjava3/processors/FlowableProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/FlowableProcessor.java index abe5e2ad08..80db65e652 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/FlowableProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/FlowableProcessor.java @@ -33,6 +33,7 @@ public abstract class FlowableProcessor extends Flowable implements Proces *

The method is thread-safe. * @return true if the FlowableProcessor has subscribers */ + @CheckReturnValue public abstract boolean hasSubscribers(); /** @@ -42,6 +43,7 @@ public abstract class FlowableProcessor extends Flowable implements Proces * @see #getThrowable() * @see #hasComplete() */ + @CheckReturnValue public abstract boolean hasThrowable(); /** @@ -50,6 +52,7 @@ public abstract class FlowableProcessor extends Flowable implements Proces * @return true if the FlowableProcessor has reached a terminal state through a complete event * @see #hasThrowable() */ + @CheckReturnValue public abstract boolean hasComplete(); /** @@ -60,6 +63,7 @@ public abstract class FlowableProcessor extends Flowable implements Proces * hasn't terminated yet */ @Nullable + @CheckReturnValue public abstract Throwable getThrowable(); /** @@ -74,6 +78,6 @@ public final FlowableProcessor toSerialized() { if (this instanceof SerializedProcessor) { return this; } - return new SerializedProcessor(this); + return new SerializedProcessor<>(this); } } diff --git a/src/main/java/io/reactivex/rxjava3/processors/MulticastProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/MulticastProcessor.java index 50497473ac..d258ba1718 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/MulticastProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/MulticastProcessor.java @@ -170,7 +170,7 @@ public final class MulticastProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static MulticastProcessor create() { - return new MulticastProcessor(bufferSize(), false); + return new MulticastProcessor<>(bufferSize(), false); } /** @@ -184,7 +184,7 @@ public static MulticastProcessor create() { @CheckReturnValue @NonNull public static MulticastProcessor create(boolean refCount) { - return new MulticastProcessor(bufferSize(), refCount); + return new MulticastProcessor<>(bufferSize(), refCount); } /** @@ -196,7 +196,7 @@ public static MulticastProcessor create(boolean refCount) { @CheckReturnValue @NonNull public static MulticastProcessor create(int bufferSize) { - return new MulticastProcessor(bufferSize, false); + return new MulticastProcessor<>(bufferSize, false); } /** @@ -211,7 +211,7 @@ public static MulticastProcessor create(int bufferSize) { @CheckReturnValue @NonNull public static MulticastProcessor create(int bufferSize, boolean refCount) { - return new MulticastProcessor(bufferSize, refCount); + return new MulticastProcessor<>(bufferSize, refCount); } /** @@ -227,8 +227,8 @@ public static MulticastProcessor create(int bufferSize, boolean refCount) this.bufferSize = bufferSize; this.limit = bufferSize - (bufferSize >> 2); this.wip = new AtomicInteger(); - this.subscribers = new AtomicReference[]>(EMPTY); - this.upstream = new AtomicReference(); + this.subscribers = new AtomicReference<>(EMPTY); + this.upstream = new AtomicReference<>(); this.refcount = refCount; this.once = new AtomicBoolean(); } @@ -241,7 +241,7 @@ public static MulticastProcessor create(int bufferSize, boolean refCount) */ public void start() { if (SubscriptionHelper.setOnce(upstream, EmptySubscription.INSTANCE)) { - queue = new SpscArrayQueue(bufferSize); + queue = new SpscArrayQueue<>(bufferSize); } } @@ -253,7 +253,7 @@ public void start() { */ public void startUnbounded() { if (SubscriptionHelper.setOnce(upstream, EmptySubscription.INSTANCE)) { - queue = new SpscLinkedArrayQueue(bufferSize); + queue = new SpscLinkedArrayQueue<>(bufferSize); } } @@ -281,7 +281,7 @@ public void onSubscribe(Subscription s) { } } - queue = new SpscArrayQueue(bufferSize); + queue = new SpscArrayQueue<>(bufferSize); s.request(bufferSize); } @@ -309,6 +309,7 @@ public void onNext(T t) { * @param t the item to offer, not null * @return true if successful, false if the queue is full */ + @CheckReturnValue public boolean offer(T t) { if (once.get()) { return false; @@ -344,28 +345,32 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasSubscribers() { return subscribers.get().length != 0; } @Override + @CheckReturnValue public boolean hasThrowable() { return once.get() && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return once.get() && error == null; } @Override + @CheckReturnValue public Throwable getThrowable() { return once.get() ? error : null; } @Override protected void subscribeActual(Subscriber s) { - MulticastSubscription ms = new MulticastSubscription(s, this); + MulticastSubscription ms = new MulticastSubscription<>(s, this); s.onSubscribe(ms); if (add(ms)) { if (ms.get() == Long.MIN_VALUE) { diff --git a/src/main/java/io/reactivex/rxjava3/processors/PublishProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/PublishProcessor.java index 4dc9bc9371..36bc4eff34 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/PublishProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/PublishProcessor.java @@ -128,7 +128,7 @@ public final class PublishProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static PublishProcessor create() { - return new PublishProcessor(); + return new PublishProcessor<>(); } /** @@ -137,12 +137,12 @@ public static PublishProcessor create() { */ @SuppressWarnings("unchecked") PublishProcessor() { - subscribers = new AtomicReference[]>(EMPTY); + subscribers = new AtomicReference<>(EMPTY); } @Override protected void subscribeActual(Subscriber t) { - PublishSubscription ps = new PublishSubscription(t, this); + PublishSubscription ps = new PublishSubscription<>(t, this); t.onSubscribe(ps); if (add(ps)) { // if cancellation happened while a successful add, the remove() didn't work @@ -283,6 +283,7 @@ public void onComplete() { * @return true if the item was emitted to all Subscribers * @since 2.2 */ + @CheckReturnValue public boolean offer(T t) { if (t == null) { onError(ExceptionHelper.createNullPointerException("offer called with a null value.")); @@ -303,12 +304,14 @@ public boolean offer(T t) { } @Override + @CheckReturnValue public boolean hasSubscribers() { return subscribers.get().length != 0; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { if (subscribers.get() == TERMINATED) { return error; @@ -317,11 +320,13 @@ public Throwable getThrowable() { } @Override + @CheckReturnValue public boolean hasThrowable() { return subscribers.get() == TERMINATED && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return subscribers.get() == TERMINATED && error == null; } diff --git a/src/main/java/io/reactivex/rxjava3/processors/ReplayProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/ReplayProcessor.java index 04de41a77f..9b722057b9 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/ReplayProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/ReplayProcessor.java @@ -173,7 +173,7 @@ public final class ReplayProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static ReplayProcessor create() { - return new ReplayProcessor(new UnboundedReplayBuffer(16)); + return new ReplayProcessor<>(new UnboundedReplayBuffer(16)); } /** @@ -194,7 +194,7 @@ public static ReplayProcessor create() { @CheckReturnValue @NonNull public static ReplayProcessor create(int capacityHint) { - return new ReplayProcessor(new UnboundedReplayBuffer(capacityHint)); + return new ReplayProcessor<>(new UnboundedReplayBuffer(capacityHint)); } /** @@ -220,7 +220,7 @@ public static ReplayProcessor create(int capacityHint) { @CheckReturnValue @NonNull public static ReplayProcessor createWithSize(int maxSize) { - return new ReplayProcessor(new SizeBoundReplayBuffer(maxSize)); + return new ReplayProcessor<>(new SizeBoundReplayBuffer(maxSize)); } /** @@ -236,8 +236,9 @@ public static ReplayProcessor createWithSize(int maxSize) { * the type of items observed and emitted by this type of processor * @return the created processor */ + @CheckReturnValue /* test */ static ReplayProcessor createUnbounded() { - return new ReplayProcessor(new SizeBoundReplayBuffer(Integer.MAX_VALUE)); + return new ReplayProcessor<>(new SizeBoundReplayBuffer(Integer.MAX_VALUE)); } /** @@ -274,8 +275,8 @@ public static ReplayProcessor createWithSize(int maxSize) { */ @CheckReturnValue @NonNull - public static ReplayProcessor createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) { - return new ReplayProcessor(new SizeAndTimeBoundReplayBuffer(Integer.MAX_VALUE, maxAge, unit, scheduler)); + public static ReplayProcessor createWithTime(long maxAge, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { + return new ReplayProcessor<>(new SizeAndTimeBoundReplayBuffer(Integer.MAX_VALUE, maxAge, unit, scheduler)); } /** @@ -314,8 +315,8 @@ public static ReplayProcessor createWithTime(long maxAge, TimeUnit unit, */ @CheckReturnValue @NonNull - public static ReplayProcessor createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) { - return new ReplayProcessor(new SizeAndTimeBoundReplayBuffer(maxSize, maxAge, unit, scheduler)); + public static ReplayProcessor createWithTimeAndSize(long maxAge, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, int maxSize) { + return new ReplayProcessor<>(new SizeAndTimeBoundReplayBuffer(maxSize, maxAge, unit, scheduler)); } /** @@ -325,12 +326,12 @@ public static ReplayProcessor createWithTimeAndSize(long maxAge, TimeUnit @SuppressWarnings("unchecked") ReplayProcessor(ReplayBuffer buffer) { this.buffer = buffer; - this.subscribers = new AtomicReference[]>(EMPTY); + this.subscribers = new AtomicReference<>(EMPTY); } @Override protected void subscribeActual(Subscriber s) { - ReplaySubscription rs = new ReplaySubscription(s, this); + ReplaySubscription rs = new ReplaySubscription<>(s, this); s.onSubscribe(rs); if (add(rs)) { @@ -404,16 +405,19 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasSubscribers() { return subscribers.get().length != 0; } + @CheckReturnValue /* test */ int subscriberCount() { return subscribers.get().length; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { ReplayBuffer b = buffer; if (b.isDone()) { @@ -445,6 +449,7 @@ public void cleanupBuffer() { *

The method is thread-safe. * @return the latest value this processor currently has or null if no such value exists */ + @CheckReturnValue public T getValue() { return buffer.getValue(); } @@ -454,6 +459,7 @@ public T getValue() { *

The method is thread-safe. * @return the array containing the snapshot of all values of this processor */ + @CheckReturnValue public Object[] getValues() { @SuppressWarnings("unchecked") T[] a = (T[])EMPTY_ARRAY; @@ -473,17 +479,20 @@ public Object[] getValues() { * @param array the target array to copy values into if it fits * @return the given array if the values fit into it or a new array containing all values */ + @CheckReturnValue public T[] getValues(T[] array) { return buffer.getValues(array); } @Override + @CheckReturnValue public boolean hasComplete() { ReplayBuffer b = buffer; return b.isDone() && b.getError() == null; } @Override + @CheckReturnValue public boolean hasThrowable() { ReplayBuffer b = buffer; return b.isDone() && b.getError() != null; @@ -494,10 +503,12 @@ public boolean hasThrowable() { *

The method is thread-safe. * @return true if the processor has any value */ + @CheckReturnValue public boolean hasValue() { return buffer.size() != 0; // NOPMD } + @CheckReturnValue /* test*/ int size() { return buffer.size(); } @@ -634,7 +645,7 @@ static final class UnboundedReplayBuffer volatile int size; UnboundedReplayBuffer(int capacityHint) { - this.buffer = new ArrayList(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); + this.buffer = new ArrayList<>(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); } @Override @@ -835,7 +846,7 @@ static final class SizeBoundReplayBuffer SizeBoundReplayBuffer(int maxSize) { this.maxSize = ObjectHelper.verifyPositive(maxSize, "maxSize"); - Node h = new Node(null); + Node h = new Node<>(null); this.tail = h; this.head = h; } @@ -850,7 +861,7 @@ void trim() { @Override public void next(T value) { - Node n = new Node(value); + Node n = new Node<>(value); Node t = tail; tail = n; @@ -876,7 +887,7 @@ public void complete() { @Override public void trimHead() { if (head.value != null) { - Node n = new Node(null); + Node n = new Node<>(null); n.lazySet(head.get()); head = n; } @@ -1054,7 +1065,7 @@ static final class SizeAndTimeBoundReplayBuffer this.maxAge = ObjectHelper.verifyPositive(maxAge, "maxAge"); this.unit = Objects.requireNonNull(unit, "unit is null"); this.scheduler = Objects.requireNonNull(scheduler, "scheduler is null"); - TimedNode h = new TimedNode(null, 0L); + TimedNode h = new TimedNode<>(null, 0L); this.tail = h; this.head = h; } @@ -1100,7 +1111,7 @@ void trimFinal() { TimedNode next = h.get(); if (next == null) { if (h.value != null) { - head = new TimedNode(null, 0L); + head = new TimedNode<>(null, 0L); } else { head = h; } @@ -1109,7 +1120,7 @@ void trimFinal() { if (next.time > limit) { if (h.value != null) { - TimedNode n = new TimedNode(null, 0L); + TimedNode n = new TimedNode<>(null, 0L); n.lazySet(h.get()); head = n; } else { @@ -1125,7 +1136,7 @@ void trimFinal() { @Override public void trimHead() { if (head.value != null) { - TimedNode n = new TimedNode(null, 0L); + TimedNode n = new TimedNode<>(null, 0L); n.lazySet(head.get()); head = n; } @@ -1133,7 +1144,7 @@ public void trimHead() { @Override public void next(T value) { - TimedNode n = new TimedNode(value, scheduler.now(unit)); + TimedNode n = new TimedNode<>(value, scheduler.now(unit)); TimedNode t = tail; tail = n; diff --git a/src/main/java/io/reactivex/rxjava3/processors/SerializedProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/SerializedProcessor.java index 6096398618..e7740b6523 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/SerializedProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/SerializedProcessor.java @@ -59,7 +59,7 @@ public void onSubscribe(Subscription s) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.subscription(s)); @@ -92,7 +92,7 @@ public void onNext(T t) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.next(t)); @@ -119,7 +119,7 @@ public void onError(Throwable t) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.setFirst(NotificationLite.error(t)); @@ -149,7 +149,7 @@ public void onComplete() { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.complete()); diff --git a/src/main/java/io/reactivex/rxjava3/processors/UnicastProcessor.java b/src/main/java/io/reactivex/rxjava3/processors/UnicastProcessor.java index ee93a5ac9c..eab7da4f05 100644 --- a/src/main/java/io/reactivex/rxjava3/processors/UnicastProcessor.java +++ b/src/main/java/io/reactivex/rxjava3/processors/UnicastProcessor.java @@ -19,7 +19,7 @@ import org.reactivestreams.*; import io.reactivex.rxjava3.annotations.*; -import io.reactivex.rxjava3.internal.functions.ObjectHelper; +import io.reactivex.rxjava3.internal.functions.*; import io.reactivex.rxjava3.internal.fuseable.QueueSubscription; import io.reactivex.rxjava3.internal.queue.SpscLinkedArrayQueue; import io.reactivex.rxjava3.internal.subscriptions.*; @@ -179,7 +179,7 @@ public final class UnicastProcessor extends FlowableProcessor { @CheckReturnValue @NonNull public static UnicastProcessor create() { - return new UnicastProcessor(bufferSize()); + return create(bufferSize(), Functions.EMPTY_RUNNABLE, true); } /** @@ -191,7 +191,7 @@ public static UnicastProcessor create() { @CheckReturnValue @NonNull public static UnicastProcessor create(int capacityHint) { - return new UnicastProcessor(capacityHint); + return create(capacityHint, Functions.EMPTY_RUNNABLE, true); } /** @@ -205,67 +205,47 @@ public static UnicastProcessor create(int capacityHint) { @CheckReturnValue @NonNull public static UnicastProcessor create(boolean delayError) { - return new UnicastProcessor(bufferSize(), null, delayError); + return create(bufferSize(), Functions.EMPTY_RUNNABLE, delayError); } /** * Creates an UnicastProcessor with the given internal buffer capacity hint and a callback for - * the case when the single Subscriber cancels its subscription. + * the case when the single Subscriber cancels its subscription or the + * processor is terminated. * *

The callback, if not null, is called exactly once and * non-overlapped with any active replay. * * @param the value type * @param capacityHint the hint to size the internal unbounded buffer - * @param onCancelled the non null callback + * @param onTerminate the non null callback * @return an UnicastProcessor instance */ @CheckReturnValue @NonNull - public static UnicastProcessor create(int capacityHint, Runnable onCancelled) { - Objects.requireNonNull(onCancelled, "onTerminate"); - return new UnicastProcessor(capacityHint, onCancelled); + public static UnicastProcessor create(int capacityHint, @NonNull Runnable onTerminate) { + return create(capacityHint, onTerminate, true); } /** * Creates an UnicastProcessor with the given internal buffer capacity hint, delay error flag and a callback for - * the case when the single Subscriber cancels its subscription. + * the case when the single Subscriber cancels its subscription or + * the processor is terminated. * *

The callback, if not null, is called exactly once and * non-overlapped with any active replay. *

History: 2.0.8 - experimental * @param the value type * @param capacityHint the hint to size the internal unbounded buffer - * @param onCancelled the non null callback + * @param onTerminate the non null callback * @param delayError deliver pending onNext events before onError * @return an UnicastProcessor instance * @since 2.2 */ @CheckReturnValue @NonNull - public static UnicastProcessor create(int capacityHint, Runnable onCancelled, boolean delayError) { - Objects.requireNonNull(onCancelled, "onTerminate"); - return new UnicastProcessor(capacityHint, onCancelled, delayError); - } - - /** - * Creates an UnicastProcessor with the given capacity hint. - * @param capacityHint the capacity hint for the internal, unbounded queue - * @since 2.0 - */ - UnicastProcessor(int capacityHint) { - this(capacityHint, null, true); - } - - /** - * Creates an UnicastProcessor with the given capacity hint and callback - * for when the Processor is terminated normally or its single Subscriber cancels. - * @param capacityHint the capacity hint for the internal, unbounded queue - * @param onTerminate the callback to run when the Processor is terminated or cancelled, null not allowed - * @since 2.0 - */ - UnicastProcessor(int capacityHint, Runnable onTerminate) { - this(capacityHint, onTerminate, true); + public static UnicastProcessor create(int capacityHint, @NonNull Runnable onTerminate, boolean delayError) { + return new UnicastProcessor<>(capacityHint, onTerminate, delayError); } /** @@ -278,10 +258,10 @@ public static UnicastProcessor create(int capacityHint, Runnable onCancel * @since 2.2 */ UnicastProcessor(int capacityHint, Runnable onTerminate, boolean delayError) { - this.queue = new SpscLinkedArrayQueue(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); - this.onTerminate = new AtomicReference(onTerminate); + this.queue = new SpscLinkedArrayQueue<>(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); + this.onTerminate = new AtomicReference<>(Objects.requireNonNull(onTerminate, "onTerminate")); this.delayError = delayError; - this.downstream = new AtomicReference>(); + this.downstream = new AtomicReference<>(); this.once = new AtomicBoolean(); this.wip = new UnicastQueueSubscription(); this.requested = new AtomicLong(); @@ -559,12 +539,14 @@ public void cancel() { } @Override + @CheckReturnValue public boolean hasSubscribers() { return downstream.get() != null; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { if (done) { return error; @@ -573,11 +555,13 @@ public Throwable getThrowable() { } @Override + @CheckReturnValue public boolean hasComplete() { return done && error == null; } @Override + @CheckReturnValue public boolean hasThrowable() { return done && error != null; } diff --git a/src/main/java/io/reactivex/rxjava3/schedulers/TestScheduler.java b/src/main/java/io/reactivex/rxjava3/schedulers/TestScheduler.java index d9247acee2..3e05665283 100644 --- a/src/main/java/io/reactivex/rxjava3/schedulers/TestScheduler.java +++ b/src/main/java/io/reactivex/rxjava3/schedulers/TestScheduler.java @@ -28,7 +28,7 @@ */ public final class TestScheduler extends Scheduler { /** The ordered queue for the runnable tasks. */ - final Queue queue = new PriorityBlockingQueue(11); + final Queue queue = new PriorityBlockingQueue<>(11); /** The per-scheduler global order counter. */ long counter; // Storing time in nanoseconds internally. diff --git a/src/main/java/io/reactivex/rxjava3/subjects/AsyncSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/AsyncSubject.java index 174c98c4f5..cfeafcd4a8 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/AsyncSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/AsyncSubject.java @@ -129,7 +129,7 @@ public final class AsyncSubject extends Subject { @CheckReturnValue @NonNull public static AsyncSubject create() { - return new AsyncSubject(); + return new AsyncSubject<>(); } /** @@ -138,7 +138,7 @@ public static AsyncSubject create() { */ @SuppressWarnings("unchecked") AsyncSubject() { - this.subscribers = new AtomicReference[]>(EMPTY); + this.subscribers = new AtomicReference<>(EMPTY); } @Override @@ -192,28 +192,32 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasObservers() { return subscribers.get().length != 0; } @Override + @CheckReturnValue public boolean hasThrowable() { return subscribers.get() == TERMINATED && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return subscribers.get() == TERMINATED && error == null; } @Override + @CheckReturnValue public Throwable getThrowable() { return subscribers.get() == TERMINATED ? error : null; } @Override protected void subscribeActual(Observer observer) { - AsyncDisposable as = new AsyncDisposable(observer, this); + AsyncDisposable as = new AsyncDisposable<>(observer, this); observer.onSubscribe(as); if (add(as)) { if (as.isDisposed()) { @@ -304,6 +308,7 @@ void remove(AsyncDisposable ps) { *

The method is thread-safe. * @return true if the subject has any value */ + @CheckReturnValue public boolean hasValue() { return subscribers.get() == TERMINATED && value != null; } @@ -314,6 +319,7 @@ public boolean hasValue() { * @return a single value the Subject currently has or null if no such value exists */ @Nullable + @CheckReturnValue public T getValue() { return subscribers.get() == TERMINATED ? value : null; } diff --git a/src/main/java/io/reactivex/rxjava3/subjects/BehaviorSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/BehaviorSubject.java index b3b212eea4..d7f5516e7d 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/BehaviorSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/BehaviorSubject.java @@ -176,7 +176,7 @@ public final class BehaviorSubject extends Subject { @CheckReturnValue @NonNull public static BehaviorSubject create() { - return new BehaviorSubject(); + return new BehaviorSubject<>(); } /** @@ -192,8 +192,8 @@ public static BehaviorSubject create() { */ @CheckReturnValue @NonNull - public static BehaviorSubject createDefault(T defaultValue) { - return new BehaviorSubject(defaultValue); + public static <@NonNull T> BehaviorSubject createDefault(T defaultValue) { + return new BehaviorSubject<>(defaultValue); } /** @@ -205,9 +205,9 @@ public static BehaviorSubject createDefault(T defaultValue) { this.lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); - this.subscribers = new AtomicReference[]>(EMPTY); - this.value = new AtomicReference(); - this.terminalEvent = new AtomicReference(); + this.subscribers = new AtomicReference<>(EMPTY); + this.value = new AtomicReference<>(); + this.terminalEvent = new AtomicReference<>(); } /** @@ -223,7 +223,7 @@ public static BehaviorSubject createDefault(T defaultValue) { @Override protected void subscribeActual(Observer observer) { - BehaviorDisposable bs = new BehaviorDisposable(observer, this); + BehaviorDisposable bs = new BehaviorDisposable<>(observer, this); observer.onSubscribe(bs); if (add(bs)) { if (bs.cancelled) { @@ -287,16 +287,19 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasObservers() { return subscribers.get().length != 0; } + @CheckReturnValue /* test support*/ int subscriberCount() { return subscribers.get().length; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { Object o = value.get(); if (NotificationLite.isError(o)) { @@ -311,6 +314,7 @@ public Throwable getThrowable() { * @return a single value the Subject currently has or null if no such value exists */ @Nullable + @CheckReturnValue public T getValue() { Object o = value.get(); if (NotificationLite.isComplete(o) || NotificationLite.isError(o)) { @@ -320,12 +324,14 @@ public T getValue() { } @Override + @CheckReturnValue public boolean hasComplete() { Object o = value.get(); return NotificationLite.isComplete(o); } @Override + @CheckReturnValue public boolean hasThrowable() { Object o = value.get(); return NotificationLite.isError(o); @@ -336,6 +342,7 @@ public boolean hasThrowable() { *

The method is thread-safe. * @return true if the subject has any value */ + @CheckReturnValue public boolean hasValue() { Object o = value.get(); return o != null && !NotificationLite.isComplete(o) && !NotificationLite.isError(o); @@ -493,7 +500,7 @@ void emitNext(Object value, long stateIndex) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(value); diff --git a/src/main/java/io/reactivex/rxjava3/subjects/CompletableSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/CompletableSubject.java index bbb4b24b0c..9753d276a1 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/CompletableSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/CompletableSubject.java @@ -107,7 +107,7 @@ public static CompletableSubject create() { CompletableSubject() { once = new AtomicBoolean(); - observers = new AtomicReference(EMPTY); + observers = new AtomicReference<>(EMPTY); } @Override diff --git a/src/main/java/io/reactivex/rxjava3/subjects/MaybeSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/MaybeSubject.java index a2f62524f0..f06d8c1aae 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/MaybeSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/MaybeSubject.java @@ -131,13 +131,13 @@ public final class MaybeSubject extends Maybe implements MaybeObserver @CheckReturnValue @NonNull public static MaybeSubject create() { - return new MaybeSubject(); + return new MaybeSubject<>(); } @SuppressWarnings("unchecked") MaybeSubject() { once = new AtomicBoolean(); - observers = new AtomicReference[]>(EMPTY); + observers = new AtomicReference<>(EMPTY); } @Override @@ -185,7 +185,7 @@ public void onComplete() { @Override protected void subscribeActual(MaybeObserver observer) { - MaybeDisposable md = new MaybeDisposable(observer, this); + MaybeDisposable md = new MaybeDisposable<>(observer, this); observer.onSubscribe(md); if (add(md)) { if (md.isDisposed()) { diff --git a/src/main/java/io/reactivex/rxjava3/subjects/PublishSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/PublishSubject.java index a81d6062fd..2c3a847832 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/PublishSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/PublishSubject.java @@ -115,7 +115,7 @@ public final class PublishSubject extends Subject { @CheckReturnValue @NonNull public static PublishSubject create() { - return new PublishSubject(); + return new PublishSubject<>(); } /** @@ -124,12 +124,12 @@ public static PublishSubject create() { */ @SuppressWarnings("unchecked") PublishSubject() { - subscribers = new AtomicReference[]>(EMPTY); + subscribers = new AtomicReference<>(EMPTY); } @Override protected void subscribeActual(Observer t) { - PublishDisposable ps = new PublishDisposable(t, this); + PublishDisposable ps = new PublishDisposable<>(t, this); t.onSubscribe(ps); if (add(ps)) { // if cancellation happened while a successful add, the remove() didn't work @@ -254,12 +254,14 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasObservers() { return subscribers.get().length != 0; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { if (subscribers.get() == TERMINATED) { return error; @@ -268,11 +270,13 @@ public Throwable getThrowable() { } @Override + @CheckReturnValue public boolean hasThrowable() { return subscribers.get() == TERMINATED && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return subscribers.get() == TERMINATED && error == null; } diff --git a/src/main/java/io/reactivex/rxjava3/subjects/ReplaySubject.java b/src/main/java/io/reactivex/rxjava3/subjects/ReplaySubject.java index aad2092429..9bb3d93b99 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/ReplaySubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/ReplaySubject.java @@ -160,7 +160,7 @@ public final class ReplaySubject extends Subject { @CheckReturnValue @NonNull public static ReplaySubject create() { - return new ReplaySubject(new UnboundedReplayBuffer(16)); + return new ReplaySubject<>(new UnboundedReplayBuffer(16)); } /** @@ -181,7 +181,7 @@ public static ReplaySubject create() { @CheckReturnValue @NonNull public static ReplaySubject create(int capacityHint) { - return new ReplaySubject(new UnboundedReplayBuffer(capacityHint)); + return new ReplaySubject<>(new UnboundedReplayBuffer(capacityHint)); } /** @@ -207,7 +207,7 @@ public static ReplaySubject create(int capacityHint) { @CheckReturnValue @NonNull public static ReplaySubject createWithSize(int maxSize) { - return new ReplaySubject(new SizeBoundReplayBuffer(maxSize)); + return new ReplaySubject<>(new SizeBoundReplayBuffer(maxSize)); } /** @@ -224,7 +224,7 @@ public static ReplaySubject createWithSize(int maxSize) { * @return the created subject */ /* test */ static ReplaySubject createUnbounded() { - return new ReplaySubject(new SizeBoundReplayBuffer(Integer.MAX_VALUE)); + return new ReplaySubject<>(new SizeBoundReplayBuffer(Integer.MAX_VALUE)); } /** @@ -261,8 +261,8 @@ public static ReplaySubject createWithSize(int maxSize) { */ @CheckReturnValue @NonNull - public static ReplaySubject createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) { - return new ReplaySubject(new SizeAndTimeBoundReplayBuffer(Integer.MAX_VALUE, maxAge, unit, scheduler)); + public static ReplaySubject createWithTime(long maxAge, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) { + return new ReplaySubject<>(new SizeAndTimeBoundReplayBuffer(Integer.MAX_VALUE, maxAge, unit, scheduler)); } /** @@ -301,8 +301,8 @@ public static ReplaySubject createWithTime(long maxAge, TimeUnit unit, Sc */ @CheckReturnValue @NonNull - public static ReplaySubject createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) { - return new ReplaySubject(new SizeAndTimeBoundReplayBuffer(maxSize, maxAge, unit, scheduler)); + public static ReplaySubject createWithTimeAndSize(long maxAge, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, int maxSize) { + return new ReplaySubject<>(new SizeAndTimeBoundReplayBuffer(maxSize, maxAge, unit, scheduler)); } /** @@ -312,12 +312,12 @@ public static ReplaySubject createWithTimeAndSize(long maxAge, TimeUnit u @SuppressWarnings("unchecked") ReplaySubject(ReplayBuffer buffer) { this.buffer = buffer; - this.observers = new AtomicReference[]>(EMPTY); + this.observers = new AtomicReference<>(EMPTY); } @Override protected void subscribeActual(Observer observer) { - ReplayDisposable rs = new ReplayDisposable(observer, this); + ReplayDisposable rs = new ReplayDisposable<>(observer, this); observer.onSubscribe(rs); if (!rs.cancelled) { @@ -392,16 +392,19 @@ public void onComplete() { } @Override + @CheckReturnValue public boolean hasObservers() { return observers.get().length != 0; } + @CheckReturnValue /* test */ int observerCount() { return observers.get().length; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { Object o = buffer.get(); if (NotificationLite.isError(o)) { @@ -416,6 +419,7 @@ public Throwable getThrowable() { * @return a single value the Subject currently has or null if no such value exists */ @Nullable + @CheckReturnValue public T getValue() { return buffer.getValue(); } @@ -446,6 +450,7 @@ public void cleanupBuffer() { *

The method is thread-safe. * @return the array containing the snapshot of all values of the Subject */ + @CheckReturnValue public Object[] getValues() { @SuppressWarnings("unchecked") T[] a = (T[])EMPTY_ARRAY; @@ -465,17 +470,20 @@ public Object[] getValues() { * @param array the target array to copy values into if it fits * @return the given array if the values fit into it or a new array containing all values */ + @CheckReturnValue public T[] getValues(T[] array) { return buffer.getValues(array); } @Override + @CheckReturnValue public boolean hasComplete() { Object o = buffer.get(); return NotificationLite.isComplete(o); } @Override + @CheckReturnValue public boolean hasThrowable() { Object o = buffer.get(); return NotificationLite.isError(o); @@ -486,10 +494,12 @@ public boolean hasThrowable() { *

The method is thread-safe. * @return true if the subject has any value */ + @CheckReturnValue public boolean hasValue() { return buffer.size() != 0; // NOPMD } + @CheckReturnValue /* test*/ int size() { return buffer.size(); } @@ -636,7 +646,7 @@ static final class UnboundedReplayBuffer volatile int size; UnboundedReplayBuffer(int capacityHint) { - this.buffer = new ArrayList(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); + this.buffer = new ArrayList<>(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); } @Override @@ -839,7 +849,7 @@ static final class SizeBoundReplayBuffer SizeBoundReplayBuffer(int maxSize) { this.maxSize = ObjectHelper.verifyPositive(maxSize, "maxSize"); - Node h = new Node(null); + Node h = new Node<>(null); this.tail = h; this.head = h; } @@ -854,7 +864,7 @@ void trim() { @Override public void add(T value) { - Node n = new Node(value); + Node n = new Node<>(value); Node t = tail; tail = n; @@ -866,7 +876,7 @@ public void add(T value) { @Override public void addFinal(Object notificationLite) { - Node n = new Node(notificationLite); + Node n = new Node<>(notificationLite); Node t = tail; tail = n; @@ -885,7 +895,7 @@ public void addFinal(Object notificationLite) { public void trimHead() { Node h = head; if (h.value != null) { - Node n = new Node(null); + Node n = new Node<>(null); n.lazySet(h.get()); head = n; } @@ -1055,7 +1065,7 @@ static final class SizeAndTimeBoundReplayBuffer this.maxAge = ObjectHelper.verifyPositive(maxAge, "maxAge"); this.unit = Objects.requireNonNull(unit, "unit is null"); this.scheduler = Objects.requireNonNull(scheduler, "scheduler is null"); - TimedNode h = new TimedNode(null, 0L); + TimedNode h = new TimedNode<>(null, 0L); this.tail = h; this.head = h; } @@ -1101,7 +1111,7 @@ void trimFinal() { TimedNode next = h.get(); if (next.get() == null) { if (h.value != null) { - TimedNode lasth = new TimedNode(null, 0L); + TimedNode lasth = new TimedNode<>(null, 0L); lasth.lazySet(h.get()); head = lasth; } else { @@ -1112,7 +1122,7 @@ void trimFinal() { if (next.time > limit) { if (h.value != null) { - TimedNode lasth = new TimedNode(null, 0L); + TimedNode lasth = new TimedNode<>(null, 0L); lasth.lazySet(h.get()); head = lasth; } else { @@ -1127,7 +1137,7 @@ void trimFinal() { @Override public void add(T value) { - TimedNode n = new TimedNode(value, scheduler.now(unit)); + TimedNode n = new TimedNode<>(value, scheduler.now(unit)); TimedNode t = tail; tail = n; @@ -1139,7 +1149,7 @@ public void add(T value) { @Override public void addFinal(Object notificationLite) { - TimedNode n = new TimedNode(notificationLite, Long.MAX_VALUE); + TimedNode n = new TimedNode<>(notificationLite, Long.MAX_VALUE); TimedNode t = tail; tail = n; @@ -1158,7 +1168,7 @@ public void addFinal(Object notificationLite) { public void trimHead() { TimedNode h = head; if (h.value != null) { - TimedNode n = new TimedNode(null, 0); + TimedNode n = new TimedNode<>(null, 0); n.lazySet(h.get()); head = n; } diff --git a/src/main/java/io/reactivex/rxjava3/subjects/SerializedSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/SerializedSubject.java index d70cf2f15c..137cefc895 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/SerializedSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/SerializedSubject.java @@ -60,7 +60,7 @@ public void onSubscribe(Disposable d) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.disposable(d)); @@ -93,7 +93,7 @@ public void onNext(T t) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.next(t)); @@ -120,7 +120,7 @@ public void onError(Throwable t) { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.setFirst(NotificationLite.error(t)); @@ -150,7 +150,7 @@ public void onComplete() { if (emitting) { AppendOnlyLinkedArrayList q = queue; if (q == null) { - q = new AppendOnlyLinkedArrayList(4); + q = new AppendOnlyLinkedArrayList<>(4); queue = q; } q.add(NotificationLite.complete()); diff --git a/src/main/java/io/reactivex/rxjava3/subjects/SingleSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/SingleSubject.java index fdd1c806f6..6f8f8b6f35 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/SingleSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/SingleSubject.java @@ -115,13 +115,13 @@ public final class SingleSubject extends Single implements SingleObserver< @CheckReturnValue @NonNull public static SingleSubject create() { - return new SingleSubject(); + return new SingleSubject<>(); } @SuppressWarnings("unchecked") SingleSubject() { once = new AtomicBoolean(); - observers = new AtomicReference[]>(EMPTY); + observers = new AtomicReference<>(EMPTY); } @Override @@ -159,7 +159,7 @@ public void onError(@NonNull Throwable e) { @Override protected void subscribeActual(@NonNull SingleObserver observer) { - SingleDisposable md = new SingleDisposable(observer, this); + SingleDisposable md = new SingleDisposable<>(observer, this); observer.onSubscribe(md); if (add(md)) { if (md.isDisposed()) { diff --git a/src/main/java/io/reactivex/rxjava3/subjects/Subject.java b/src/main/java/io/reactivex/rxjava3/subjects/Subject.java index 6a3b6462be..35d26d49b5 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/Subject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/Subject.java @@ -32,6 +32,7 @@ public abstract class Subject extends Observable implements Observer { *

The method is thread-safe. * @return true if the subject has any Observers */ + @CheckReturnValue public abstract boolean hasObservers(); /** @@ -41,6 +42,7 @@ public abstract class Subject extends Observable implements Observer { * @see #getThrowable() * @see #hasComplete() */ + @CheckReturnValue public abstract boolean hasThrowable(); /** @@ -49,6 +51,7 @@ public abstract class Subject extends Observable implements Observer { * @return true if the subject has reached a terminal state through a complete event * @see #hasThrowable() */ + @CheckReturnValue public abstract boolean hasComplete(); /** @@ -59,6 +62,7 @@ public abstract class Subject extends Observable implements Observer { * hasn't terminated yet */ @Nullable + @CheckReturnValue public abstract Throwable getThrowable(); /** @@ -68,10 +72,11 @@ public abstract class Subject extends Observable implements Observer { * @return the wrapped and serialized subject */ @NonNull + @CheckReturnValue public final Subject toSerialized() { if (this instanceof SerializedSubject) { return this; } - return new SerializedSubject(this); + return new SerializedSubject<>(this); } } diff --git a/src/main/java/io/reactivex/rxjava3/subjects/UnicastSubject.java b/src/main/java/io/reactivex/rxjava3/subjects/UnicastSubject.java index c522343aed..8f495a9ca5 100644 --- a/src/main/java/io/reactivex/rxjava3/subjects/UnicastSubject.java +++ b/src/main/java/io/reactivex/rxjava3/subjects/UnicastSubject.java @@ -20,7 +20,7 @@ import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.internal.disposables.EmptyDisposable; -import io.reactivex.rxjava3.internal.functions.ObjectHelper; +import io.reactivex.rxjava3.internal.functions.*; import io.reactivex.rxjava3.internal.fuseable.SimpleQueue; import io.reactivex.rxjava3.internal.observers.BasicIntQueueDisposable; import io.reactivex.rxjava3.internal.queue.SpscLinkedArrayQueue; @@ -180,7 +180,7 @@ public final class UnicastSubject extends Subject { @CheckReturnValue @NonNull public static UnicastSubject create() { - return new UnicastSubject(bufferSize(), true); + return create(bufferSize(), Functions.EMPTY_RUNNABLE, true); } /** @@ -192,12 +192,13 @@ public static UnicastSubject create() { @CheckReturnValue @NonNull public static UnicastSubject create(int capacityHint) { - return new UnicastSubject(capacityHint, true); + return create(capacityHint, Functions.EMPTY_RUNNABLE, true); } /** * Creates an UnicastSubject with the given internal buffer capacity hint and a callback for - * the case when the single Subscriber cancels its subscription. + * the case when the single Subscriber cancels its subscription + * or the subject is terminated. * *

The callback, if not null, is called exactly once and * non-overlapped with any active replay. @@ -209,13 +210,14 @@ public static UnicastSubject create(int capacityHint) { */ @CheckReturnValue @NonNull - public static UnicastSubject create(int capacityHint, Runnable onTerminate) { - return new UnicastSubject(capacityHint, onTerminate, true); + public static UnicastSubject create(int capacityHint, @NonNull Runnable onTerminate) { + return create(capacityHint, onTerminate, true); } /** * Creates an UnicastSubject with the given internal buffer capacity hint, delay error flag and - * a callback for the case when the single Subscriber cancels its subscription. + * a callback for the case when the single Observer disposes its {@link Disposable} + * or the subject is terminated. * *

The callback, if not null, is called exactly once and * non-overlapped with any active replay. @@ -229,8 +231,8 @@ public static UnicastSubject create(int capacityHint, Runnable onTerminat */ @CheckReturnValue @NonNull - public static UnicastSubject create(int capacityHint, Runnable onTerminate, boolean delayError) { - return new UnicastSubject(capacityHint, onTerminate, delayError); + public static UnicastSubject create(int capacityHint, @NonNull Runnable onTerminate, boolean delayError) { + return new UnicastSubject<>(capacityHint, onTerminate, delayError); } /** @@ -247,35 +249,7 @@ public static UnicastSubject create(int capacityHint, Runnable onTerminat @CheckReturnValue @NonNull public static UnicastSubject create(boolean delayError) { - return new UnicastSubject(bufferSize(), delayError); - } - - /** - * Creates an UnicastSubject with the given capacity hint and delay error flag. - *

History: 2.0.8 - experimental - * @param capacityHint the capacity hint for the internal, unbounded queue - * @param delayError deliver pending onNext events before onError - * @since 2.2 - */ - UnicastSubject(int capacityHint, boolean delayError) { - this.queue = new SpscLinkedArrayQueue(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); - this.onTerminate = new AtomicReference(); - this.delayError = delayError; - this.downstream = new AtomicReference>(); - this.once = new AtomicBoolean(); - this.wip = new UnicastQueueDisposable(); - } - - /** - * Creates an UnicastSubject with the given capacity hint and callback - * for when the Subject is terminated normally or its single Subscriber cancels. - * @param capacityHint the capacity hint for the internal, unbounded queue - * @param onTerminate the callback to run when the Subject is terminated or cancelled, null not allowed - * @since 2.0 - * - * */ - UnicastSubject(int capacityHint, Runnable onTerminate) { - this(capacityHint, onTerminate, true); + return create(bufferSize(), Functions.EMPTY_RUNNABLE, delayError); } /** @@ -288,10 +262,10 @@ public static UnicastSubject create(boolean delayError) { * @since 2.2 */ UnicastSubject(int capacityHint, Runnable onTerminate, boolean delayError) { - this.queue = new SpscLinkedArrayQueue(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); - this.onTerminate = new AtomicReference(Objects.requireNonNull(onTerminate, "onTerminate")); + this.queue = new SpscLinkedArrayQueue<>(ObjectHelper.verifyPositive(capacityHint, "capacityHint")); + this.onTerminate = new AtomicReference<>(Objects.requireNonNull(onTerminate, "onTerminate")); this.delayError = delayError; - this.downstream = new AtomicReference>(); + this.downstream = new AtomicReference<>(); this.once = new AtomicBoolean(); this.wip = new UnicastQueueDisposable(); } @@ -494,12 +468,14 @@ void drain() { } @Override + @CheckReturnValue public boolean hasObservers() { return downstream.get() != null; } @Override @Nullable + @CheckReturnValue public Throwable getThrowable() { if (done) { return error; @@ -508,11 +484,13 @@ public Throwable getThrowable() { } @Override + @CheckReturnValue public boolean hasThrowable() { return done && error != null; } @Override + @CheckReturnValue public boolean hasComplete() { return done && error == null; } diff --git a/src/test/java/io/reactivex/rxjava3/core/ConverterTest.java b/src/test/java/io/reactivex/rxjava3/core/ConverterTest.java index 7a39c85cfd..68006e3c64 100644 --- a/src/test/java/io/reactivex/rxjava3/core/ConverterTest.java +++ b/src/test/java/io/reactivex/rxjava3/core/ConverterTest.java @@ -175,7 +175,17 @@ public void compositeTest() { .assertValue(1); } + /** + * Two argument type. + * @param the input type + * @param the output type + */ interface A { } + + /** + * One argument type. + * @param the type + */ interface B { } private static ObservableConverter, B> testObservableConverterCreator() { diff --git a/src/test/java/io/reactivex/rxjava3/core/TransformerTest.java b/src/test/java/io/reactivex/rxjava3/core/TransformerTest.java index 8f9f102a04..20725c80fa 100644 --- a/src/test/java/io/reactivex/rxjava3/core/TransformerTest.java +++ b/src/test/java/io/reactivex/rxjava3/core/TransformerTest.java @@ -18,6 +18,7 @@ import org.junit.Test; import org.reactivestreams.Publisher; +import io.reactivex.rxjava3.core.ConverterTest.*; import io.reactivex.rxjava3.exceptions.TestException; public class TransformerTest extends RxJavaTest { @@ -127,9 +128,6 @@ public void flowableGenericsSignatureTest() { Flowable.just(a).compose(TransformerTest.testFlowableTransformerCreator()); } - interface A { } - interface B { } - private static ObservableTransformer, B> testObservableTransformerCreator() { return new ObservableTransformer, B>() { @Override diff --git a/src/test/java/io/reactivex/rxjava3/flowable/FlowableConversionTest.java b/src/test/java/io/reactivex/rxjava3/flowable/FlowableConversionTest.java index c5b75a9b39..a579a82ae7 100644 --- a/src/test/java/io/reactivex/rxjava3/flowable/FlowableConversionTest.java +++ b/src/test/java/io/reactivex/rxjava3/flowable/FlowableConversionTest.java @@ -59,7 +59,7 @@ public CylonDetectorObservable lift(FlowableOperator(operator)); } - public O x(Function, O> operator) { + public O x(Function, O> operator) { try { return operator.apply(onSubscribe); } catch (Throwable ex) { diff --git a/src/test/java/io/reactivex/rxjava3/internal/functions/FunctionsTest.java b/src/test/java/io/reactivex/rxjava3/internal/functions/FunctionsTest.java index 98488bcd49..72e188fe99 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/functions/FunctionsTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/functions/FunctionsTest.java @@ -173,62 +173,6 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, }).apply(new Object[20]); } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void biFunctionFail() throws Exception { - BiFunction biFunction = null; - Functions.toFunction(biFunction); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function3Fail() throws Exception { - Function3 function3 = null; - Functions.toFunction(function3); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function4Fail() throws Exception { - Function4 function4 = null; - Functions.toFunction(function4); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function5Fail() throws Exception { - Function5 function5 = null; - Functions.toFunction(function5); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function6Fail() throws Exception { - Function6 function6 = null; - Functions.toFunction(function6); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function7Fail() throws Exception { - Function7 function7 = null; - Functions.toFunction(function7); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function8Fail() throws Exception { - Function8 function8 = null; - Functions.toFunction(function8); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test(expected = NullPointerException.class) - public void function9Fail() throws Exception { - Function9 function9 = null; - Functions.toFunction(function9); - } - @Test public void identityFunctionToString() { assertEquals("IdentityFunction", Functions.identity().toString()); diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCombineLatestTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCombineLatestTest.java index c8e041b951..6829c99986 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCombineLatestTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCombineLatestTest.java @@ -1046,7 +1046,7 @@ public void combineLatestNArguments() throws Exception { if (j < i) { assertEquals("source" + (j + 1) + " is null", ex.getCause().getMessage()); } else { - assertEquals("f is null", ex.getCause().getMessage()); + assertEquals("combiner is null", ex.getCause().getMessage()); } } } diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableRetryTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableRetryTest.java index 4de1cfb8b0..607801bd19 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableRetryTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableRetryTest.java @@ -73,7 +73,7 @@ public Flowable apply(Flowable attempts) { .map(new Function() { @Override public Tuple apply(Throwable n) { - return new Tuple(new Long(1), n); + return new Tuple(1L, n); }}) .scan(new BiFunction() { @Override diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableZipTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableZipTest.java index e4b41c8bea..614dc28aaa 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableZipTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableZipTest.java @@ -1297,7 +1297,7 @@ public void zipNArguments() throws Exception { if (j < i) { assertEquals("source" + (j + 1) + " is null", ex.getCause().getMessage()); } else { - assertEquals("f is null", ex.getCause().getMessage()); + assertEquals("zipper is null", ex.getCause().getMessage()); } } } diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatMapEagerTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatMapEagerTest.java index 6a88930b75..ab4ba0273f 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatMapEagerTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatMapEagerTest.java @@ -893,7 +893,6 @@ public void arrayDelayErrorMaxConcurrency() { PublishSubject ps2 = PublishSubject.create(); PublishSubject ps3 = PublishSubject.create(); - @SuppressWarnings("unchecked") TestObserver to = Observable.concatArrayEagerDelayError(2, 2, ps1, ps2, ps3) .test(); @@ -929,7 +928,6 @@ public void arrayDelayErrorMaxConcurrencyErrorDelayed() { PublishSubject ps2 = PublishSubject.create(); PublishSubject ps3 = PublishSubject.create(); - @SuppressWarnings("unchecked") TestObserver to = Observable.concatArrayEagerDelayError(2, 2, ps1, ps2, ps3) .test(); diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatTest.java index 05df845a44..b1c42a1175 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableConcatTest.java @@ -780,7 +780,6 @@ public void concat4() { .assertResult(1, 2, 3, 4); } - @SuppressWarnings("unchecked") @Test public void concatArrayDelayError() { Observable.concatArrayDelayError(Observable.just(1), Observable.just(2), @@ -789,7 +788,6 @@ public void concatArrayDelayError() { .assertResult(1, 2, 3, 4); } - @SuppressWarnings("unchecked") @Test public void concatArrayDelayErrorWithError() { Observable.concatArrayDelayError(Observable.just(1), Observable.just(2), @@ -886,13 +884,11 @@ public Iterable apply(Integer v) throws Exception { .assertResult(1, 2, 3, 4, 5, 1, 2, 3, 4, 5); } - @SuppressWarnings("unchecked") @Test public void emptyArray() { assertSame(Observable.empty(), Observable.concatArrayDelayError()); } - @SuppressWarnings("unchecked") @Test public void singleElementArray() { assertSame(Observable.never(), Observable.concatArrayDelayError(Observable.never())); @@ -923,13 +919,11 @@ public ObservableSource apply(Object v) throws Exception { } - @SuppressWarnings("unchecked") @Test public void concatArrayEmpty() { assertSame(Observable.empty(), Observable.concatArray()); } - @SuppressWarnings("unchecked") @Test public void concatArraySingleElement() { assertSame(Observable.never(), Observable.concatArray(Observable.never())); @@ -960,7 +954,6 @@ public ObservableSource apply(Object v) throws Exception { } - @SuppressWarnings("unchecked") @Test public void noSubsequentSubscription() { final int[] calls = { 0 }; @@ -981,7 +974,6 @@ public void subscribe(ObservableEmitter s) throws Exception { assertEquals(1, calls[0]); } - @SuppressWarnings("unchecked") @Test public void noSubsequentSubscriptionDelayError() { final int[] calls = { 0 }; @@ -1071,7 +1063,6 @@ public void onComplete() { } @Test - @SuppressWarnings("unchecked") public void concatReportsDisposedOnCompleteDelayError() { final Disposable[] disposable = { null }; @@ -1128,7 +1119,6 @@ public void onComplete() { } @Test - @SuppressWarnings("unchecked") public void concatReportsDisposedOnErrorDelayError() { final Disposable[] disposable = { null }; @@ -1156,7 +1146,6 @@ public void onComplete() { assertTrue(disposable[0].isDisposed()); } - @SuppressWarnings("unchecked") @Test public void noCancelPreviousArray() { final AtomicInteger counter = new AtomicInteger(); diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeDelayErrorTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeDelayErrorTest.java index c4d24a69c7..fefce52867 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeDelayErrorTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeDelayErrorTest.java @@ -506,7 +506,6 @@ public void mergeIterableDelayError() { .assertResult(1, 2); } - @SuppressWarnings("unchecked") @Test public void mergeArrayDelayError() { Observable.mergeArrayDelayError(Observable.just(1), Observable.just(2)) diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeTest.java index 92d30f8a85..d5b9a45a6f 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableMergeTest.java @@ -1065,7 +1065,6 @@ public void onNext(Integer t) { } } - @SuppressWarnings("unchecked") @Test public void mergeArray2() { Observable.mergeArray(Observable.just(1), Observable.just(2)) diff --git a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableRetryTest.java b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableRetryTest.java index 381ee0a790..94009c5b86 100644 --- a/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableRetryTest.java +++ b/src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableRetryTest.java @@ -74,7 +74,7 @@ public Observable apply(Observable attempts) { .map(new Function() { @Override public Tuple apply(Throwable n) { - return new Tuple(new Long(1), n); + return new Tuple(1L, n); }}) .scan(new BiFunction() { @Override diff --git a/src/test/java/io/reactivex/rxjava3/maybe/MaybeTest.java b/src/test/java/io/reactivex/rxjava3/maybe/MaybeTest.java index d222f92392..b5a03ede3b 100644 --- a/src/test/java/io/reactivex/rxjava3/maybe/MaybeTest.java +++ b/src/test/java/io/reactivex/rxjava3/maybe/MaybeTest.java @@ -2662,7 +2662,7 @@ public void mergeDelayError4() { @Test public void sequenceEqual() { - Maybe.sequenceEqual(Maybe.just(1), Maybe.just(new Integer(1))).test().assertResult(true); + Maybe.sequenceEqual(Maybe.just(1_000_000), Maybe.just(Integer.valueOf(1_000_000))).test().assertResult(true); Maybe.sequenceEqual(Maybe.just(1), Maybe.just(2)).test().assertResult(false); diff --git a/src/test/java/io/reactivex/rxjava3/observable/ObservableNullTests.java b/src/test/java/io/reactivex/rxjava3/observable/ObservableNullTests.java index 074057a8d3..0fa7c22711 100644 --- a/src/test/java/io/reactivex/rxjava3/observable/ObservableNullTests.java +++ b/src/test/java/io/reactivex/rxjava3/observable/ObservableNullTests.java @@ -202,7 +202,6 @@ public void concatArrayNull() { Observable.concatArray((Observable[])null); } - @SuppressWarnings("unchecked") @Test(expected = NullPointerException.class) public void concatArrayOneIsNull() { Observable.concatArray(just1, null).blockingLast(); @@ -521,7 +520,6 @@ public void mergeArrayNull() { Observable.mergeArray(128, 128, (Observable[])null); } - @SuppressWarnings("unchecked") @Test(expected = NullPointerException.class) public void mergeArrayOneIsNull() { Observable.mergeArray(128, 128, just1, null).blockingLast(); @@ -552,7 +550,6 @@ public void mergeDelayErrorArrayNull() { Observable.mergeArrayDelayError(128, 128, (Observable[])null); } - @SuppressWarnings("unchecked") @Test(expected = NullPointerException.class) public void mergeDelayErrorArrayOneIsNull() { Observable.mergeArrayDelayError(128, 128, just1, null).blockingLast(); diff --git a/src/test/java/io/reactivex/rxjava3/parallel/ParallelFlowableTest.java b/src/test/java/io/reactivex/rxjava3/parallel/ParallelFlowableTest.java index 93ffe8de7d..1d1f97163f 100644 --- a/src/test/java/io/reactivex/rxjava3/parallel/ParallelFlowableTest.java +++ b/src/test/java/io/reactivex/rxjava3/parallel/ParallelFlowableTest.java @@ -306,7 +306,6 @@ public Iterable apply(List v) throws Exception { TestHelper.assertValueSet(ts, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); } - @SuppressWarnings("unchecked") @Test public void from() { TestSubscriberEx ts = new TestSubscriberEx<>(); diff --git a/src/test/java/io/reactivex/rxjava3/parallel/ParallelReduceFullTest.java b/src/test/java/io/reactivex/rxjava3/parallel/ParallelReduceFullTest.java index 56595583bb..25d72af909 100644 --- a/src/test/java/io/reactivex/rxjava3/parallel/ParallelReduceFullTest.java +++ b/src/test/java/io/reactivex/rxjava3/parallel/ParallelReduceFullTest.java @@ -73,7 +73,6 @@ public Integer apply(Integer a, Integer b) throws Exception { } } - @SuppressWarnings("unchecked") @Test public void error2() { List errors = TestHelper.trackPluginErrors(); diff --git a/src/test/java/io/reactivex/rxjava3/parallel/ParallelSortedJoinTest.java b/src/test/java/io/reactivex/rxjava3/parallel/ParallelSortedJoinTest.java index d2cc8aaec0..e7b5cda9b0 100644 --- a/src/test/java/io/reactivex/rxjava3/parallel/ParallelSortedJoinTest.java +++ b/src/test/java/io/reactivex/rxjava3/parallel/ParallelSortedJoinTest.java @@ -82,7 +82,6 @@ public void error3() { } } - @SuppressWarnings("unchecked") @Test public void error2() { List errors = TestHelper.trackPluginErrors(); diff --git a/src/test/java/io/reactivex/rxjava3/subjects/UnicastSubjectTest.java b/src/test/java/io/reactivex/rxjava3/subjects/UnicastSubjectTest.java index 9c9301176c..17e4cb0a72 100644 --- a/src/test/java/io/reactivex/rxjava3/subjects/UnicastSubjectTest.java +++ b/src/test/java/io/reactivex/rxjava3/subjects/UnicastSubjectTest.java @@ -368,7 +368,7 @@ public void dispose() { public void run() { calls[0]++; } - }); + }, true); TestHelper.checkDisposed(us); diff --git a/src/test/java/io/reactivex/rxjava3/testsupport/TestHelper.java b/src/test/java/io/reactivex/rxjava3/testsupport/TestHelper.java index 9bfb21668e..eabbb6f96d 100644 --- a/src/test/java/io/reactivex/rxjava3/testsupport/TestHelper.java +++ b/src/test/java/io/reactivex/rxjava3/testsupport/TestHelper.java @@ -3257,10 +3257,23 @@ public static TestObserverEx assertValueSet(TestObserverEx to, T... va * @throws Exception on error */ public static File findSource(String baseClassName) throws Exception { + return findSource(baseClassName, "io.reactivex.rxjava3.core"); + } + + /** + * Given a base reactive type name, try to find its source in the current runtime + * path and return a file to it or null if not found. + * @param baseClassName the class name such as {@code Maybe} + * @param parentPackage the parent package such as {@code io.reactivex.rxjava3.core} + * @return the File pointing to the source + * @throws Exception on error + */ + public static File findSource(String baseClassName, String parentPackage) throws Exception { URL u = TestHelper.class.getResource(TestHelper.class.getSimpleName() + ".class"); String path = new File(u.toURI()).toString().replace('\\', '/'); + parentPackage = parentPackage.replace(".", "/"); // System.out.println(path); int i = path.toLowerCase().indexOf("/rxjava"); @@ -3272,16 +3285,18 @@ public static File findSource(String baseClassName) throws Exception { // find end of any potential postfix to /RxJava int j = path.indexOf("/", i + 6); - String p = path.substring(0, j + 1) + "src/main/java/io/reactivex/rxjava3/core/" + baseClassName + ".java"; + String basePackage = path.substring(0, j + 1) + "src/main/java"; + + String p = basePackage + "/" + parentPackage + "/" + baseClassName + ".java"; File f = new File(p); - if (!f.canRead()) { - System.out.println("Can't read " + p); - return null; + if (f.canRead()) { + return f; } - return f; + System.out.println("Can't read " + p); + return null; } /** diff --git a/src/test/java/io/reactivex/rxjava3/validators/BaseTypeAnnotations.java b/src/test/java/io/reactivex/rxjava3/validators/BaseTypeAnnotations.java index 36457ffd86..504232be2e 100644 --- a/src/test/java/io/reactivex/rxjava3/validators/BaseTypeAnnotations.java +++ b/src/test/java/io/reactivex/rxjava3/validators/BaseTypeAnnotations.java @@ -22,6 +22,11 @@ import io.reactivex.rxjava3.annotations.*; import io.reactivex.rxjava3.core.*; +import io.reactivex.rxjava3.flowables.ConnectableFlowable; +import io.reactivex.rxjava3.observables.ConnectableObservable; +import io.reactivex.rxjava3.parallel.ParallelFlowable; +import io.reactivex.rxjava3.processors.*; +import io.reactivex.rxjava3.subjects.*; /** * Verifies several properties. @@ -38,16 +43,14 @@ static void checkCheckReturnValueSupport(Class clazz) { StringBuilder b = new StringBuilder(); for (Method m : clazz.getMethods()) { - if (m.getName().equals("bufferSize")) { - continue; - } if (m.getDeclaringClass() == clazz) { boolean isSubscribeMethod = "subscribe".equals(m.getName()) && m.getParameterTypes().length == 0; + boolean isConnectMethod = "connect".equals(m.getName()) && m.getParameterTypes().length == 0; boolean isAnnotationPresent = m.isAnnotationPresent(CheckReturnValue.class); - if (isSubscribeMethod) { + if (isSubscribeMethod || isConnectMethod) { if (isAnnotationPresent) { - b.append("subscribe() method has @CheckReturnValue: ").append(m).append("\r\n"); + b.append(m.getName()).append(" method has @CheckReturnValue: ").append(m).append("\r\n"); } continue; } @@ -83,7 +86,8 @@ static void checkSchedulerSupport(Class clazz) { StringBuilder b = new StringBuilder(); for (Method m : clazz.getMethods()) { - if (m.getName().equals("bufferSize")) { + if (m.getName().equals("bufferSize") + || m.getName().equals("parallelism")) { continue; } if (m.getDeclaringClass() == clazz) { @@ -130,18 +134,24 @@ static void checkBackpressureSupport(Class clazz) { StringBuilder b = new StringBuilder(); for (Method m : clazz.getMethods()) { - if (m.getName().equals("bufferSize")) { + if (m.getName().equals("bufferSize") + || m.getName().equals("parallelism")) { continue; } if (m.getDeclaringClass() == clazz) { - if (clazz == Flowable.class) { + if (clazz == Flowable.class || clazz == ParallelFlowable.class) { if (!m.isAnnotationPresent(BackpressureSupport.class)) { - b.append("No @BackpressureSupport annotation (being Flowable): ").append(m).append("\r\n"); + b.append("No @BackpressureSupport annotation (being ") + .append(clazz.getSimpleName()) + .append("): ").append(m).append("\r\n"); } } else { - if (m.getReturnType() == Flowable.class) { + if (m.getReturnType() == Flowable.class + || m.getReturnType() == ParallelFlowable.class) { if (!m.isAnnotationPresent(BackpressureSupport.class)) { - b.append("No @BackpressureSupport annotation (having Flowable return): ").append(m).append("\r\n"); + b.append("No @BackpressureSupport annotation (having ") + .append(m.getReturnType().getSimpleName()) + .append(" return): ").append(m).append("\r\n"); } } else { boolean found = false; @@ -200,6 +210,86 @@ public void checkReturnValueMaybe() { checkCheckReturnValueSupport(Maybe.class); } + @Test + public void checkReturnValueConnectableObservable() { + checkCheckReturnValueSupport(ConnectableObservable.class); + } + + @Test + public void checkReturnValueConnectableFlowable() { + checkCheckReturnValueSupport(ConnectableFlowable.class); + } + + @Test + public void checkReturnValueParallelFlowable() { + checkCheckReturnValueSupport(ParallelFlowable.class); + } + + @Test + public void checkReturnValueAsyncSubject() { + checkCheckReturnValueSupport(AsyncSubject.class); + } + + @Test + public void checkReturnValueBehaviorSubject() { + checkCheckReturnValueSupport(BehaviorSubject.class); + } + + @Test + public void checkReturnValuePublishSubject() { + checkCheckReturnValueSupport(PublishSubject.class); + } + + @Test + public void checkReturnValueReplaySubject() { + checkCheckReturnValueSupport(ReplaySubject.class); + } + + @Test + public void checkReturnValueUnicastSubject() { + checkCheckReturnValueSupport(UnicastSubject.class); + } + + @Test + public void checkReturnValueAsyncProcessor() { + checkCheckReturnValueSupport(AsyncProcessor.class); + } + + @Test + public void checkReturnValueBehaviorProcessor() { + checkCheckReturnValueSupport(BehaviorProcessor.class); + } + + @Test + public void checkReturnValuePublishProcessor() { + checkCheckReturnValueSupport(PublishProcessor.class); + } + + @Test + public void checkReturnValueReplayProcessor() { + checkCheckReturnValueSupport(ReplayProcessor.class); + } + + @Test + public void checkReturnValueUnicastProcessor() { + checkCheckReturnValueSupport(UnicastProcessor.class); + } + + @Test + public void checkReturnValueMulticastProcessor() { + checkCheckReturnValueSupport(MulticastProcessor.class); + } + + @Test + public void checkReturnValueSubject() { + checkCheckReturnValueSupport(Subject.class); + } + + @Test + public void checkReturnValueFlowableProcessor() { + checkCheckReturnValueSupport(FlowableProcessor.class); + } + @Test public void schedulerSupportFlowable() { checkSchedulerSupport(Flowable.class); @@ -225,6 +315,21 @@ public void schedulerSupportMaybe() { checkSchedulerSupport(Maybe.class); } + @Test + public void schedulerSupportConnectableObservable() { + checkSchedulerSupport(ConnectableObservable.class); + } + + @Test + public void schedulerSupportConnectableFlowable() { + checkSchedulerSupport(ConnectableFlowable.class); + } + + @Test + public void schedulerSupportParallelFlowable() { + checkSchedulerSupport(ParallelFlowable.class); + } + @Test public void backpressureSupportFlowable() { checkBackpressureSupport(Flowable.class); @@ -249,4 +354,19 @@ public void backpressureSupportCompletable() { public void backpressureSupportMaybe() { checkBackpressureSupport(Maybe.class); } + + @Test + public void backpressureSupportConnectableFlowable() { + checkBackpressureSupport(ConnectableFlowable.class); + } + + @Test + public void backpressureSupportConnectableObservable() { + checkBackpressureSupport(ConnectableObservable.class); + } + + @Test + public void backpressureSupportParallelFlowable() { + checkBackpressureSupport(ParallelFlowable.class); + } } diff --git a/src/test/java/io/reactivex/rxjava3/validators/ParamValidationNaming.java b/src/test/java/io/reactivex/rxjava3/validators/ParamValidationNaming.java new file mode 100644 index 0000000000..6e66d4249e --- /dev/null +++ b/src/test/java/io/reactivex/rxjava3/validators/ParamValidationNaming.java @@ -0,0 +1,235 @@ +/** + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava3.validators; + +import java.io.File; +import java.nio.file.Files; +import java.util.*; + +import org.junit.Test; + +import io.reactivex.rxjava3.core.*; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.flowables.ConnectableFlowable; +import io.reactivex.rxjava3.observables.ConnectableObservable; +import io.reactivex.rxjava3.parallel.ParallelFlowable; +import io.reactivex.rxjava3.processors.*; +import io.reactivex.rxjava3.schedulers.Schedulers; +import io.reactivex.rxjava3.subjects.*; +import io.reactivex.rxjava3.testsupport.TestHelper; + +/** + * Check if the parameter name in Objects.requireNonNull + * and ObjectHelper.verifyPositive calls match the parameter + * name in the message. + */ +public class ParamValidationNaming { + + @Test + public void checkCompletable() throws Exception { + processFile(Completable.class); + } + + @Test + public void checkSingle() throws Exception { + processFile(Single.class); + } + + @Test + public void checkMaybe() throws Exception { + processFile(Maybe.class); + } + + @Test + public void checkObservable() throws Exception { + processFile(Observable.class); + } + + @Test + public void checkFlowable() throws Exception { + processFile(Flowable.class); + } + + @Test + public void checkParallelFlowable() throws Exception { + processFile(ParallelFlowable.class); + } + + @Test + public void checkConnectableObservable() throws Exception { + processFile(ConnectableObservable.class); + } + + @Test + public void checkConnectableFlowable() throws Exception { + processFile(ConnectableFlowable.class); + } + + @Test + public void checkSubject() throws Exception { + processFile(Subject.class); + } + + @Test + public void checkFlowableProcessor() throws Exception { + processFile(FlowableProcessor.class); + } + + @Test + public void checkDisposable() throws Exception { + processFile(Disposable.class); + } + + @Test + public void checkScheduler() throws Exception { + processFile(Scheduler.class); + } + + @Test + public void checkSchedulers() throws Exception { + processFile(Schedulers.class); + } + + @Test + public void checkAsyncSubject() throws Exception { + processFile(AsyncSubject.class); + } + + @Test + public void checkBehaviorSubject() throws Exception { + processFile(BehaviorSubject.class); + } + + @Test + public void checkPublishSubject() throws Exception { + processFile(PublishSubject.class); + } + + @Test + public void checkReplaySubject() throws Exception { + processFile(ReplaySubject.class); + } + + @Test + public void checkUnicastSubject() throws Exception { + processFile(UnicastSubject.class); + } + + @Test + public void checkSingleSubject() throws Exception { + processFile(SingleSubject.class); + } + + @Test + public void checkMaybeSubject() throws Exception { + processFile(MaybeSubject.class); + } + + @Test + public void checkCompletableSubject() throws Exception { + processFile(CompletableSubject.class); + } + + @Test + public void checkAsyncProcessor() throws Exception { + processFile(AsyncProcessor.class); + } + + @Test + public void checkBehaviorProcessor() throws Exception { + processFile(BehaviorProcessor.class); + } + + @Test + public void checkPublishProcessor() throws Exception { + processFile(PublishProcessor.class); + } + + @Test + public void checkReplayProcessor() throws Exception { + processFile(ReplayProcessor.class); + } + + @Test + public void checkUnicastProcessor() throws Exception { + processFile(UnicastProcessor.class); + } + + @Test + public void checkMulticastProcessor() throws Exception { + processFile(MulticastProcessor.class); + } + + static void processFile(Class clazz) throws Exception { + String baseClassName = clazz.getSimpleName(); + File f = TestHelper.findSource(baseClassName, clazz.getPackage().getName()); + if (f == null) { + return; + } + String fullClassName = clazz.getName(); + + int errorCount = 0; + StringBuilder errors = new StringBuilder(); + + List lines = Files.readAllLines(f.toPath()); + + for (int j = 0; j < lines.size(); j++) { + String line = lines.get(j).trim(); + + for (String validatorStr : VALIDATOR_STRINGS) + if (line.startsWith(validatorStr)) { + + int comma = line.indexOf(','); + + String paramName = line.substring(validatorStr.length(), comma); + + int quote = line.indexOf('"', comma); + + String message = line.substring(quote + 1, quote + 2 + paramName.length()); + + if (!line.contains("The RxJavaPlugins") + && !(message.startsWith(paramName) + && (message.endsWith(" ") || message.endsWith("\"")))) { + errorCount++; + errors.append("L") + .append(j) + .append(" : Wrong validator message parameter name\r\n ") + .append(line) + .append("\r\n") + .append(" ").append(paramName).append(" != ").append(message) + .append("\r\n at ") + .append(fullClassName) + .append(".method(") + .append(f.getName()) + .append(":") + .append(j + 1) + .append(")\r\n") + ; + } + } + } + + if (errorCount != 0) { + errors.insert(0, errorCount + " problems\r\n"); + errors.setLength(errors.length() - 2); + throw new AssertionError(errors.toString()); + } + } + + static final List VALIDATOR_STRINGS = Arrays.asList( + "Objects.requireNonNull(", + "ObjectHelper.requirePositive(" + ); +} diff --git a/src/test/java/io/reactivex/rxjava3/validators/SourceAnnotationCheck.java b/src/test/java/io/reactivex/rxjava3/validators/SourceAnnotationCheck.java index 8cde4fac7e..6fb50a141b 100644 --- a/src/test/java/io/reactivex/rxjava3/validators/SourceAnnotationCheck.java +++ b/src/test/java/io/reactivex/rxjava3/validators/SourceAnnotationCheck.java @@ -21,7 +21,13 @@ import io.reactivex.rxjava3.core.*; import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.flowables.ConnectableFlowable; +import io.reactivex.rxjava3.observables.ConnectableObservable; import io.reactivex.rxjava3.parallel.ParallelFlowable; +import io.reactivex.rxjava3.processors.*; +import io.reactivex.rxjava3.schedulers.Schedulers; +import io.reactivex.rxjava3.subjects.*; import io.reactivex.rxjava3.testsupport.TestHelper; /** @@ -46,8 +52,7 @@ public void checkMaybe() throws Exception { processFile(Maybe.class); } - // TODO later - // @Test + @Test public void checkObservable() throws Exception { processFile(Observable.class); } @@ -57,15 +62,119 @@ public void checkFlowable() throws Exception { processFile(Flowable.class); } - // TODO later - // @Test + @Test public void checkParallelFlowable() throws Exception { processFile(ParallelFlowable.class); } + @Test + public void checkConnectableObservable() throws Exception { + processFile(ConnectableObservable.class); + } + + @Test + public void checkConnectableFlowable() throws Exception { + processFile(ConnectableFlowable.class); + } + + @Test + public void checkSubject() throws Exception { + processFile(Subject.class); + } + + @Test + public void checkFlowableProcessor() throws Exception { + processFile(FlowableProcessor.class); + } + + @Test + public void checkDisposable() throws Exception { + processFile(Disposable.class); + } + + @Test + public void checkScheduler() throws Exception { + processFile(Scheduler.class); + } + + @Test + public void checkSchedulers() throws Exception { + processFile(Schedulers.class); + } + + @Test + public void checkAsyncSubject() throws Exception { + processFile(AsyncSubject.class); + } + + @Test + public void checkBehaviorSubject() throws Exception { + processFile(BehaviorSubject.class); + } + + @Test + public void checkPublishSubject() throws Exception { + processFile(PublishSubject.class); + } + + @Test + public void checkReplaySubject() throws Exception { + processFile(ReplaySubject.class); + } + + @Test + public void checkUnicastSubject() throws Exception { + processFile(UnicastSubject.class); + } + + @Test + public void checkSingleSubject() throws Exception { + processFile(SingleSubject.class); + } + + @Test + public void checkMaybeSubject() throws Exception { + processFile(MaybeSubject.class); + } + + @Test + public void checkCompletableSubject() throws Exception { + processFile(CompletableSubject.class); + } + + @Test + public void checkAsyncProcessor() throws Exception { + processFile(AsyncProcessor.class); + } + + @Test + public void checkBehaviorProcessor() throws Exception { + processFile(BehaviorProcessor.class); + } + + @Test + public void checkPublishProcessor() throws Exception { + processFile(PublishProcessor.class); + } + + @Test + public void checkReplayProcessor() throws Exception { + processFile(ReplayProcessor.class); + } + + @Test + public void checkUnicastProcessor() throws Exception { + processFile(UnicastProcessor.class); + } + + @Test + public void checkMulticastProcessor() throws Exception { + processFile(MulticastProcessor.class); + } + static void processFile(Class clazz) throws Exception { String baseClassName = clazz.getSimpleName(); - File f = TestHelper.findSource(baseClassName); + File f = TestHelper.findSource(baseClassName, clazz.getPackage().getName()); if (f == null) { return; } @@ -79,7 +188,14 @@ static void processFile(Class clazz) throws Exception { for (int j = 0; j < lines.size(); j++) { String line = lines.get(j).trim(); - if (line.startsWith("public static") || line.startsWith("public final")) { + if (line.contains("class")) { + continue; + } + if (line.startsWith("public static") + || line.startsWith("public final") + || line.startsWith("protected final") + || line.startsWith("protected abstract") + || line.startsWith("public abstract")) { int methodArgStart = line.indexOf("("); int isBoolean = line.indexOf(" boolean "); @@ -168,10 +284,12 @@ else if (skippingDepth == 0) { String strippedArgumentsStr = strippedArguments.toString(); String[] args = strippedArgumentsStr.split("\\s*,\\s*"); - for (String typeName : CLASS_NAMES) { - String typeNameSpaced = typeName + " "; - for (int k = 0; k < args.length; k++) { - String typeDef = args[k]; + for (int k = 0; k < args.length; k++) { + String typeDef = args[k]; + + for (String typeName : CLASS_NAMES) { + String typeNameSpaced = typeName + " "; + if (typeDef.contains(typeNameSpaced) && !typeDef.contains("@NonNull") && !typeDef.contains("@Nullable")) { @@ -181,8 +299,9 @@ else if (skippingDepth == 0) { errorCount++; errors.append("L") .append(j) - .append(" - argument ").append(k + 1).append(" - ").append(typeDef) - .append(" : Missing argument type nullability annotation |\r\n ") + .append(" - argument ").append(k + 1) + .append(" : Missing argument type nullability annotation\r\n ") + .append(typeDef).append("\r\n ") .append(strippedArgumentsStr) .append("\r\n") .append(" at ") @@ -196,13 +315,55 @@ else if (skippingDepth == 0) { } } } + + if (typeDef.contains("final ")) { + errorCount++; + errors.append("L") + .append(j) + .append(" - argument ").append(k + 1) + .append(" : unnecessary final on argument\r\n ") + .append(typeDef).append("\r\n ") + .append(strippedArgumentsStr) + .append("\r\n") + .append(" at ") + .append(fullClassName) + .append(".method(") + .append(f.getName()) + .append(":") + .append(j + 1) + .append(")\r\n") + ; + } + if (typeDef.contains("@NonNull int") + || typeDef.contains("@NonNull long") + || typeDef.contains("@Nullable int") + || typeDef.contains("@Nullable long") + ) { + errorCount++; + errors.append("L") + .append(j) + .append(" - argument ").append(k + 1) + .append(" : unnecessary nullability annotation\r\n ") + .append(typeDef).append("\r\n ") + .append(strippedArgumentsStr) + .append("\r\n") + .append(" at ") + .append(fullClassName) + .append(".method(") + .append(f.getName()) + .append(":") + .append(j + 1) + .append(")\r\n") + ; + } + } if (strippedArgumentsStr.contains("...") && !hasSafeVarargsAnnotation) { errorCount++; errors.append("L") .append(j) - .append(" : Missing @SafeVarargs annotation |\r\n ") + .append(" : Missing @SafeVarargs annotation\r\n ") .append(strippedArgumentsStr) .append("\r\n") .append(" at ") @@ -218,7 +379,7 @@ else if (skippingDepth == 0) { } if (errorCount != 0) { - errors.insert(0, errorCount + " missing annotations\r\n"); + errors.insert(0, errorCount + " problems\r\n"); errors.setLength(errors.length() - 2); throw new AssertionError(errors.toString()); } @@ -249,6 +410,8 @@ else if (skippingDepth == 0) { "Throwable", "Optional", "CompletionStage", "BooleanSupplier", "LongConsumer", "Predicate", "BiPredicate", "Object", + "Iterable", "Stream", "Iterator", + "BackpressureOverflowStrategy", "BackpressureStrategy", "Subject", "Processor", "FlowableProcessor",