Skip to content

Commit 7df3e3c

Browse files
vanniktechakarnokd
authored andcommitted
2.x: Add a few more @nullable & @nonnull annotations to public interfaces. (#5196)
1 parent 7265d33 commit 7df3e3c

28 files changed

+101
-46
lines changed

src/main/java/io/reactivex/CompletableEmitter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
1617
import io.reactivex.disposables.Disposable;
1718
import io.reactivex.functions.Cancellable;
1819

@@ -35,21 +36,21 @@ public interface CompletableEmitter {
3536
* Signal an exception.
3637
* @param t the exception, not null
3738
*/
38-
void onError(Throwable t);
39+
void onError(@NonNull Throwable t);
3940

4041
/**
4142
* Sets a Disposable on this emitter; any previous Disposable
4243
* or Cancellation will be disposed/cancelled.
4344
* @param d the disposable, null is allowed
4445
*/
45-
void setDisposable(Disposable d);
46+
void setDisposable(@Nullable Disposable d);
4647

4748
/**
4849
* Sets a Cancellable on this emitter; any previous Disposable
4950
* or Cancellation will be disposed/cancelled.
5051
* @param c the cancellable resource, null is allowed
5152
*/
52-
void setCancellable(Cancellable c);
53+
void setCancellable(@Nullable Cancellable c);
5354

5455
/**
5556
* Returns true if the downstream disposed the sequence.

src/main/java/io/reactivex/CompletableObserver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.NonNull;
1617
import io.reactivex.disposables.Disposable;
1718

1819
/**
@@ -24,7 +25,7 @@ public interface CompletableObserver {
2425
* then can be used to cancel the subscription at any time.
2526
* @param d the Disposable instance to call dispose on for cancellation, not null
2627
*/
27-
void onSubscribe(Disposable d);
28+
void onSubscribe(@NonNull Disposable d);
2829

2930
/**
3031
* Called once the deferred computation completes normally.
@@ -35,5 +36,5 @@ public interface CompletableObserver {
3536
* Called once if the deferred computation 'throws' an exception.
3637
* @param e the exception, not null.
3738
*/
38-
void onError(Throwable e);
39+
void onError(@NonNull Throwable e);
3940
}

src/main/java/io/reactivex/CompletableOnSubscribe.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
package io.reactivex;
1414

15+
import io.reactivex.annotations.*;
16+
1517
/**
1618
* A functional interface that has a {@code subscribe()} method that receives
1719
* an instance of a {@link CompletableEmitter} instance that allows pushing
@@ -24,6 +26,6 @@ public interface CompletableOnSubscribe {
2426
* @param e the safe emitter instance, never null
2527
* @throws Exception on error
2628
*/
27-
void subscribe(CompletableEmitter e) throws Exception;
29+
void subscribe(@NonNull CompletableEmitter e) throws Exception;
2830
}
2931

src/main/java/io/reactivex/CompletableOperator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
17+
1618
/**
1719
* Interface to map/wrap a downstream observer to an upstream observer.
1820
*/
@@ -23,5 +25,6 @@ public interface CompletableOperator {
2325
* @return the parent CompletableObserver instance
2426
* @throws Exception on failure
2527
*/
26-
CompletableObserver apply(CompletableObserver observer) throws Exception;
28+
@NonNull
29+
CompletableObserver apply(@NonNull CompletableObserver observer) throws Exception;
2730
}

src/main/java/io/reactivex/CompletableSource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
package io.reactivex;
1414

15+
import io.reactivex.annotations.*;
16+
1517
/**
1618
* Represents a basic {@link Completable} source base interface,
1719
* consumable via an {@link CompletableObserver}.
@@ -25,5 +27,5 @@ public interface CompletableSource {
2527
* @param cs the CompletableObserver, not null
2628
* @throws NullPointerException if {@code cs} is null
2729
*/
28-
void subscribe(CompletableObserver cs);
30+
void subscribe(@NonNull CompletableObserver cs);
2931
}

src/main/java/io/reactivex/CompletableTransformer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
17+
1618
/**
1719
* Convenience interface and callback used by the compose operator to turn a Completable into another
1820
* Completable fluently.
@@ -23,5 +25,6 @@ public interface CompletableTransformer {
2325
* @param upstream the upstream Completable instance
2426
* @return the transformed CompletableSource instance
2527
*/
26-
CompletableSource apply(Completable upstream);
28+
@NonNull
29+
CompletableSource apply(@NonNull Completable upstream);
2730
}

src/main/java/io/reactivex/FlowableEmitter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
1617
import io.reactivex.disposables.Disposable;
1718
import io.reactivex.functions.Cancellable;
1819

@@ -35,14 +36,14 @@ public interface FlowableEmitter<T> extends Emitter<T> {
3536
* or Cancellation will be unsubscribed/cancelled.
3637
* @param s the disposable, null is allowed
3738
*/
38-
void setDisposable(Disposable s);
39+
void setDisposable(@Nullable Disposable s);
3940

4041
/**
4142
* Sets a Cancellable on this emitter; any previous Disposable
4243
* or Cancellation will be unsubscribed/cancelled.
4344
* @param c the cancellable resource, null is allowed
4445
*/
45-
void setCancellable(Cancellable c);
46+
void setCancellable(@Nullable Cancellable c);
4647

4748
/**
4849
* The current outstanding request amount.
@@ -62,5 +63,6 @@ public interface FlowableEmitter<T> extends Emitter<T> {
6263
* Ensures that calls to onNext, onError and onComplete are properly serialized.
6364
* @return the serialized FlowableEmitter
6465
*/
66+
@NonNull
6567
FlowableEmitter<T> serialize();
6668
}

src/main/java/io/reactivex/FlowableOnSubscribe.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
package io.reactivex;
1414

15+
import io.reactivex.annotations.*;
16+
1517
/**
1618
* A functional interface that has a {@code subscribe()} method that receives
1719
* an instance of a {@link FlowableEmitter} instance that allows pushing
@@ -26,6 +28,6 @@ public interface FlowableOnSubscribe<T> {
2628
* @param e the safe emitter instance, never null
2729
* @throws Exception on error
2830
*/
29-
void subscribe(FlowableEmitter<T> e) throws Exception;
31+
void subscribe(@NonNull FlowableEmitter<T> e) throws Exception;
3032
}
3133

src/main/java/io/reactivex/FlowableOperator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
1617
import org.reactivestreams.Subscriber;
1718

1819
/**
@@ -28,5 +29,6 @@ public interface FlowableOperator<Downstream, Upstream> {
2829
* @return the parent Subscriber instance
2930
* @throws Exception on failure
3031
*/
31-
Subscriber<? super Upstream> apply(Subscriber<? super Downstream> observer) throws Exception;
32+
@NonNull
33+
Subscriber<? super Upstream> apply(@NonNull Subscriber<? super Downstream> observer) throws Exception;
3234
}

src/main/java/io/reactivex/FlowableSubscriber.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
package io.reactivex;
1515

16+
import io.reactivex.annotations.*;
1617
import org.reactivestreams.*;
1718

18-
import io.reactivex.annotations.Experimental;
19-
2019
/**
2120
* Represents a Reactive-Streams inspired Subscriber that is RxJava 2 only
2221
* and weakens rules §1.3 and §3.9 of the specification for gaining performance.
@@ -37,5 +36,5 @@ public interface FlowableSubscriber<T> extends Subscriber<T> {
3736
* {@inheritDoc}
3837
*/
3938
@Override
40-
void onSubscribe(Subscription s);
39+
void onSubscribe(@NonNull Subscription s);
4140
}

0 commit comments

Comments
 (0)