Skip to content

Commit 40ca8ef

Browse files
authored
3.x: Move nullability annotations into the type argument declaration (#7303)
* 3.x: Move nullability annotations into the type argument declaration * Reinforce Function<T, R> return argument type where R is non-trivial
1 parent 75e7e50 commit 40ca8ef

18 files changed

+1093
-894
lines changed

src/main/java/io/reactivex/rxjava3/core/Completable.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ public static Completable fromFuture(@NonNull Future<?> future) {
630630
@CheckReturnValue
631631
@NonNull
632632
@SchedulerSupport(SchedulerSupport.NONE)
633-
public static <T> Completable fromMaybe(@NonNull MaybeSource<T> maybe) {
633+
public static <@NonNull T> Completable fromMaybe(@NonNull MaybeSource<T> maybe) {
634634
Objects.requireNonNull(maybe, "maybe is null");
635635
return RxJavaPlugins.onAssembly(new MaybeIgnoreElementCompletable<>(maybe));
636636
}
@@ -686,7 +686,7 @@ public static Completable fromRunnable(@NonNull Runnable run) {
686686
@CheckReturnValue
687687
@NonNull
688688
@SchedulerSupport(SchedulerSupport.NONE)
689-
public static <T> Completable fromObservable(@NonNull ObservableSource<T> observable) {
689+
public static <@NonNull T> Completable fromObservable(@NonNull ObservableSource<T> observable) {
690690
Objects.requireNonNull(observable, "observable is null");
691691
return RxJavaPlugins.onAssembly(new CompletableFromObservable<>(observable));
692692
}
@@ -724,7 +724,7 @@ public static <T> Completable fromObservable(@NonNull ObservableSource<T> observ
724724
@NonNull
725725
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
726726
@SchedulerSupport(SchedulerSupport.NONE)
727-
public static <T> Completable fromPublisher(@NonNull Publisher<T> publisher) {
727+
public static <@NonNull T> Completable fromPublisher(@NonNull Publisher<T> publisher) {
728728
Objects.requireNonNull(publisher, "publisher is null");
729729
return RxJavaPlugins.onAssembly(new CompletableFromPublisher<>(publisher));
730730
}
@@ -746,7 +746,7 @@ public static <T> Completable fromPublisher(@NonNull Publisher<T> publisher) {
746746
@CheckReturnValue
747747
@NonNull
748748
@SchedulerSupport(SchedulerSupport.NONE)
749-
public static <T> Completable fromSingle(@NonNull SingleSource<T> single) {
749+
public static <@NonNull T> Completable fromSingle(@NonNull SingleSource<T> single) {
750750
Objects.requireNonNull(single, "single is null");
751751
return RxJavaPlugins.onAssembly(new CompletableFromSingle<>(single));
752752
}
@@ -1225,7 +1225,7 @@ public static Completable switchOnNextDelayError(@NonNull Publisher<@NonNull ? e
12251225
@CheckReturnValue
12261226
@SchedulerSupport(SchedulerSupport.NONE)
12271227
@NonNull
1228-
public static <R> Completable using(@NonNull Supplier<R> resourceSupplier,
1228+
public static <@NonNull R> Completable using(@NonNull Supplier<R> resourceSupplier,
12291229
@NonNull Function<? super R, ? extends CompletableSource> sourceSupplier,
12301230
@NonNull Consumer<? super R> resourceCleanup) {
12311231
return using(resourceSupplier, sourceSupplier, resourceCleanup, true);
@@ -1261,7 +1261,7 @@ public static <R> Completable using(@NonNull Supplier<R> resourceSupplier,
12611261
@CheckReturnValue
12621262
@NonNull
12631263
@SchedulerSupport(SchedulerSupport.NONE)
1264-
public static <R> Completable using(
1264+
public static <@NonNull R> Completable using(
12651265
@NonNull Supplier<R> resourceSupplier,
12661266
@NonNull Function<? super R, ? extends CompletableSource> sourceSupplier,
12671267
@NonNull Consumer<? super R> resourceCleanup,
@@ -2194,7 +2194,7 @@ public final Completable lift(@NonNull CompletableOperator onLift) {
21942194
@CheckReturnValue
21952195
@SchedulerSupport(SchedulerSupport.NONE)
21962196
@NonNull
2197-
public final <T> Single<Notification<T>> materialize() {
2197+
public final <@NonNull T> Single<Notification<T>> materialize() {
21982198
return RxJavaPlugins.onAssembly(new CompletableMaterialize<>(this));
21992199
}
22002200

@@ -2356,7 +2356,7 @@ public final Completable onErrorResumeWith(@NonNull CompletableSource fallback)
23562356
@CheckReturnValue
23572357
@NonNull
23582358
@SchedulerSupport(SchedulerSupport.NONE)
2359-
public final <T> Maybe<T> onErrorReturn(@NonNull Function<? super Throwable, ? extends T> itemSupplier) {
2359+
public final <@NonNull T> Maybe<T> onErrorReturn(@NonNull Function<? super Throwable, ? extends T> itemSupplier) {
23602360
Objects.requireNonNull(itemSupplier, "itemSupplier is null");
23612361
return RxJavaPlugins.onAssembly(new CompletableOnErrorReturn<>(this, itemSupplier));
23622362
}
@@ -2384,7 +2384,7 @@ public final <T> Maybe<T> onErrorReturn(@NonNull Function<? super Throwable, ? e
23842384
@CheckReturnValue
23852385
@NonNull
23862386
@SchedulerSupport(SchedulerSupport.NONE)
2387-
public final <T> Maybe<T> onErrorReturnItem(@NonNull T item) {
2387+
public final <@NonNull T> Maybe<T> onErrorReturnItem(@NonNull T item) {
23882388
Objects.requireNonNull(item, "item is null");
23892389
return onErrorReturn(Functions.justFunction(item));
23902390
}
@@ -2483,7 +2483,7 @@ public final Completable repeatUntil(@NonNull BooleanSupplier stop) {
24832483
@CheckReturnValue
24842484
@SchedulerSupport(SchedulerSupport.NONE)
24852485
@NonNull
2486-
public final Completable repeatWhen(@NonNull Function<? super Flowable<Object>, ? extends Publisher<@NonNull ?>> handler) {
2486+
public final Completable repeatWhen(@NonNull Function<? super Flowable<Object>, @NonNull ? extends Publisher<@NonNull ?>> handler) {
24872487
return fromPublisher(toFlowable().repeatWhen(handler));
24882488
}
24892489

@@ -2655,7 +2655,7 @@ public final Completable retryUntil(@NonNull BooleanSupplier stop) {
26552655
@CheckReturnValue
26562656
@SchedulerSupport(SchedulerSupport.NONE)
26572657
@NonNull
2658-
public final Completable retryWhen(@NonNull Function<? super Flowable<Throwable>, ? extends Publisher<@NonNull ?>> handler) {
2658+
public final Completable retryWhen(@NonNull Function<? super Flowable<Throwable>, @NonNull ? extends Publisher<@NonNull ?>> handler) {
26592659
return fromPublisher(toFlowable().retryWhen(handler));
26602660
}
26612661

@@ -2726,7 +2726,7 @@ public final Completable startWith(@NonNull CompletableSource other) {
27262726
@NonNull
27272727
@SchedulerSupport(SchedulerSupport.NONE)
27282728
@BackpressureSupport(BackpressureKind.FULL)
2729-
public final <T> Flowable<T> startWith(@NonNull SingleSource<T> other) {
2729+
public final <@NonNull T> Flowable<T> startWith(@NonNull SingleSource<T> other) {
27302730
Objects.requireNonNull(other, "other is null");
27312731
return Flowable.concat(Single.wrap(other).toFlowable(), toFlowable());
27322732
}
@@ -2752,7 +2752,7 @@ public final <T> Flowable<T> startWith(@NonNull SingleSource<T> other) {
27522752
@NonNull
27532753
@SchedulerSupport(SchedulerSupport.NONE)
27542754
@BackpressureSupport(BackpressureKind.FULL)
2755-
public final <T> Flowable<T> startWith(@NonNull MaybeSource<T> other) {
2755+
public final <@NonNull T> Flowable<T> startWith(@NonNull MaybeSource<T> other) {
27562756
Objects.requireNonNull(other, "other is null");
27572757
return Flowable.concat(Maybe.wrap(other).toFlowable(), toFlowable());
27582758
}
@@ -2774,7 +2774,7 @@ public final <T> Flowable<T> startWith(@NonNull MaybeSource<T> other) {
27742774
@CheckReturnValue
27752775
@NonNull
27762776
@SchedulerSupport(SchedulerSupport.NONE)
2777-
public final <T> Observable<T> startWith(@NonNull ObservableSource<T> other) {
2777+
public final <@NonNull T> Observable<T> startWith(@NonNull ObservableSource<T> other) {
27782778
Objects.requireNonNull(other, "other is null");
27792779
return Observable.wrap(other).concatWith(this.toObservable());
27802780
}
@@ -2800,7 +2800,7 @@ public final <T> Observable<T> startWith(@NonNull ObservableSource<T> other) {
28002800
@NonNull
28012801
@BackpressureSupport(BackpressureKind.FULL)
28022802
@SchedulerSupport(SchedulerSupport.NONE)
2803-
public final <T> Flowable<T> startWith(@NonNull Publisher<T> other) {
2803+
public final <@NonNull T> Flowable<T> startWith(@NonNull Publisher<T> other) {
28042804
Objects.requireNonNull(other, "other is null");
28052805
return this.<T>toFlowable().startWith(other);
28062806
}
@@ -3214,7 +3214,7 @@ public final <R> R to(@NonNull CompletableConverter<? extends R> converter) {
32143214
@BackpressureSupport(BackpressureKind.FULL)
32153215
@SchedulerSupport(SchedulerSupport.NONE)
32163216
@NonNull
3217-
public final <T> Flowable<T> toFlowable() {
3217+
public final <@NonNull T> Flowable<T> toFlowable() {
32183218
if (this instanceof FuseToFlowable) {
32193219
return ((FuseToFlowable<T>)this).fuseToFlowable();
32203220
}
@@ -3259,7 +3259,7 @@ public final Future<Void> toFuture() {
32593259
@SuppressWarnings("unchecked")
32603260
@SchedulerSupport(SchedulerSupport.NONE)
32613261
@NonNull
3262-
public final <T> Maybe<T> toMaybe() {
3262+
public final <@NonNull T> Maybe<T> toMaybe() {
32633263
if (this instanceof FuseToMaybe) {
32643264
return ((FuseToMaybe<T>)this).fuseToMaybe();
32653265
}
@@ -3282,7 +3282,7 @@ public final <T> Maybe<T> toMaybe() {
32823282
@SuppressWarnings("unchecked")
32833283
@SchedulerSupport(SchedulerSupport.NONE)
32843284
@NonNull
3285-
public final <T> Observable<T> toObservable() {
3285+
public final <@NonNull T> Observable<T> toObservable() {
32863286
if (this instanceof FuseToObservable) {
32873287
return ((FuseToObservable<T>)this).fuseToObservable();
32883288
}
@@ -3469,7 +3469,7 @@ public static Completable fromCompletionStage(@NonNull CompletionStage<?> stage)
34693469
@CheckReturnValue
34703470
@SchedulerSupport(SchedulerSupport.NONE)
34713471
@NonNull
3472-
public final <T> CompletionStage<T> toCompletionStage(@Nullable T defaultItem) {
3472+
public final <@Nullable T> CompletionStage<T> toCompletionStage(T defaultItem) {
34733473
return subscribeWith(new CompletionStageConsumer<>(true, defaultItem));
34743474
}
34753475
}

0 commit comments

Comments
 (0)