Skip to content

Commit

Permalink
3.x: Move nullness annotation to use sites of Supplier (#7385)
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored Feb 3, 2022
1 parent 9d36262 commit 47189ac
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/reactivex/rxjava3/core/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public static Completable unsafeCreate(@NonNull CompletableSource onSubscribe) {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Completable defer(@NonNull Supplier<? extends CompletableSource> supplier) {
public static Completable defer(@NonNull Supplier<? extends @NonNull CompletableSource> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new CompletableDefer(supplier));
}
Expand All @@ -503,7 +503,7 @@ public static Completable defer(@NonNull Supplier<? extends CompletableSource> s
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Completable error(@NonNull Supplier<? extends Throwable> supplier) {
public static Completable error(@NonNull Supplier<? extends @NonNull Throwable> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new CompletableErrorSupplier(supplier));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/reactivex/rxjava3/core/Flowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ public static int bufferSize() {
@NonNull
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Flowable<T> defer(@NonNull Supplier<? extends Publisher<? extends T>> supplier) {
public static <@NonNull T> Flowable<T> defer(@NonNull Supplier<? extends @NonNull Publisher<? extends T>> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new FlowableDefer<>(supplier));
}
Expand Down Expand Up @@ -2095,7 +2095,7 @@ public static int bufferSize() {
@NonNull
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Flowable<T> error(@NonNull Supplier<? extends Throwable> supplier) {
public static <@NonNull T> Flowable<T> error(@NonNull Supplier<? extends @NonNull Throwable> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new FlowableError<>(supplier));
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/reactivex/rxjava3/core/Maybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ public abstract class Maybe<T> implements MaybeSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Maybe<T> defer(@NonNull Supplier<? extends MaybeSource<? extends T>> supplier) {
public static <@NonNull T> Maybe<T> defer(@NonNull Supplier<? extends @NonNull MaybeSource<? extends T>> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new MaybeDefer<>(supplier));
}
Expand Down Expand Up @@ -961,7 +961,7 @@ public abstract class Maybe<T> implements MaybeSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Maybe<T> error(@NonNull Supplier<? extends Throwable> supplier) {
public static <@NonNull T> Maybe<T> error(@NonNull Supplier<? extends @NonNull Throwable> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new MaybeErrorCallable<>(supplier));
}
Expand Down Expand Up @@ -1079,7 +1079,7 @@ public abstract class Maybe<T> implements MaybeSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Maybe<T> fromCallable(@NonNull Callable<? extends T> callable) {
public static <T> Maybe<@NonNull T> fromCallable(@NonNull Callable<? extends @Nullable T> callable) {
Objects.requireNonNull(callable, "callable is null");
return RxJavaPlugins.onAssembly(new MaybeFromCallable<>(callable));
}
Expand Down Expand Up @@ -1285,7 +1285,7 @@ public abstract class Maybe<T> implements MaybeSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Maybe<T> fromSupplier(@NonNull Supplier<? extends T> supplier) {
public static <T> Maybe<@NonNull T> fromSupplier(@NonNull Supplier<? extends @Nullable T> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new MaybeFromSupplier<>(supplier));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/reactivex/rxjava3/core/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ public static int bufferSize() {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Observable<T> defer(@NonNull Supplier<? extends ObservableSource<? extends T>> supplier) {
public static <@NonNull T> Observable<T> defer(@NonNull Supplier<? extends @NonNull ObservableSource<? extends T>> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new ObservableDefer<>(supplier));
}
Expand Down Expand Up @@ -1839,7 +1839,7 @@ public static int bufferSize() {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Observable<T> error(@NonNull Supplier<? extends Throwable> supplier) {
public static <@NonNull T> Observable<T> error(@NonNull Supplier<? extends @NonNull Throwable> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new ObservableError<>(supplier));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/reactivex/rxjava3/core/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ public abstract class Single<@NonNull T> implements SingleSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Single<T> defer(@NonNull Supplier<? extends SingleSource<? extends T>> supplier) {
public static <@NonNull T> Single<T> defer(@NonNull Supplier<? extends @NonNull SingleSource<? extends T>> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new SingleDefer<>(supplier));
}
Expand All @@ -917,7 +917,7 @@ public abstract class Single<@NonNull T> implements SingleSource<T> {
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static <@NonNull T> Single<T> error(@NonNull Supplier<? extends Throwable> supplier) {
public static <@NonNull T> Single<T> error(@NonNull Supplier<? extends @NonNull Throwable> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return RxJavaPlugins.onAssembly(new SingleError<>(supplier));
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/io/reactivex/rxjava3/functions/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

package io.reactivex.rxjava3.functions;

import io.reactivex.rxjava3.annotations.NonNull;

/**
* A functional interface (callback) that provides a single value or
* throws an exception.
Expand All @@ -25,7 +23,7 @@
* @since 3.0.0
*/
@FunctionalInterface
public interface Supplier<@NonNull T> {
public interface Supplier<T> {

/**
* Produces a value or throws an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ static void process(Class<?> clazz) {

for (String ta : parseTypeArguments(line)) {
if (!ta.startsWith("@NonNull") && !ta.startsWith("@Nullable")) {
result.append("Missing annotation on argument ").append(ta).append("\r\nat ")
.append(parentPackage).append(".").append(className).append(".method(")
.append(className).append(".java:").append(lineCount).append(")\r\n");
count++;
if (!("Maybe".equals(clazz.getSimpleName()) && (line.contains("fromCallable(") || line.contains("fromSupplier(")))) {
result.append("Missing annotation on argument ").append(ta).append("\r\nat ")
.append(parentPackage).append(".").append(className).append(".method(")
.append(className).append(".java:").append(lineCount).append(")\r\n");
count++;
}
}
}
}
Expand Down

0 comments on commit 47189ac

Please sign in to comment.