Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: Add a few more @Nullable & @NonNull annotations to public interfaces #5196

Merged
merged 1 commit into from
Mar 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/io/reactivex/CompletableEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Cancellable;

Expand All @@ -35,21 +36,21 @@ public interface CompletableEmitter {
* Signal an exception.
* @param t the exception, not null
*/
void onError(Throwable t);
void onError(@NonNull Throwable t);

/**
* Sets a Disposable on this emitter; any previous Disposable
* or Cancellation will be disposed/cancelled.
* @param d the disposable, null is allowed
*/
void setDisposable(Disposable d);
void setDisposable(@Nullable Disposable d);

/**
* Sets a Cancellable on this emitter; any previous Disposable
* or Cancellation will be disposed/cancelled.
* @param c the cancellable resource, null is allowed
*/
void setCancellable(Cancellable c);
void setCancellable(@Nullable Cancellable c);

/**
* Returns true if the downstream disposed the sequence.
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/reactivex/CompletableObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

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

/**
* Called once the deferred computation completes normally.
Expand All @@ -35,5 +36,5 @@ public interface CompletableObserver {
* Called once if the deferred computation 'throws' an exception.
* @param e the exception, not null.
*/
void onError(Throwable e);
void onError(@NonNull Throwable e);
}
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/CompletableOnSubscribe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.reactivex;

import io.reactivex.annotations.*;

/**
* A functional interface that has a {@code subscribe()} method that receives
* an instance of a {@link CompletableEmitter} instance that allows pushing
Expand All @@ -24,6 +26,6 @@ public interface CompletableOnSubscribe {
* @param e the safe emitter instance, never null
* @throws Exception on error
*/
void subscribe(CompletableEmitter e) throws Exception;
void subscribe(@NonNull CompletableEmitter e) throws Exception;
}

5 changes: 4 additions & 1 deletion src/main/java/io/reactivex/CompletableOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.reactivex;

import io.reactivex.annotations.*;

/**
* Interface to map/wrap a downstream observer to an upstream observer.
*/
Expand All @@ -23,5 +25,6 @@ public interface CompletableOperator {
* @return the parent CompletableObserver instance
* @throws Exception on failure
*/
CompletableObserver apply(CompletableObserver observer) throws Exception;
@NonNull
CompletableObserver apply(@NonNull CompletableObserver observer) throws Exception;
}
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/CompletableSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.reactivex;

import io.reactivex.annotations.*;

/**
* Represents a basic {@link Completable} source base interface,
* consumable via an {@link CompletableObserver}.
Expand All @@ -25,5 +27,5 @@ public interface CompletableSource {
* @param cs the CompletableObserver, not null
* @throws NullPointerException if {@code cs} is null
*/
void subscribe(CompletableObserver cs);
void subscribe(@NonNull CompletableObserver cs);
}
5 changes: 4 additions & 1 deletion src/main/java/io/reactivex/CompletableTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.reactivex;

import io.reactivex.annotations.*;

/**
* Convenience interface and callback used by the compose operator to turn a Completable into another
* Completable fluently.
Expand All @@ -23,5 +25,6 @@ public interface CompletableTransformer {
* @param upstream the upstream Completable instance
* @return the transformed CompletableSource instance
*/
CompletableSource apply(Completable upstream);
@NonNull
CompletableSource apply(@NonNull Completable upstream);
}
6 changes: 4 additions & 2 deletions src/main/java/io/reactivex/FlowableEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Cancellable;

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

/**
* Sets a Cancellable on this emitter; any previous Disposable
* or Cancellation will be unsubscribed/cancelled.
* @param c the cancellable resource, null is allowed
*/
void setCancellable(Cancellable c);
void setCancellable(@Nullable Cancellable c);

/**
* The current outstanding request amount.
Expand All @@ -62,5 +63,6 @@ public interface FlowableEmitter<T> extends Emitter<T> {
* Ensures that calls to onNext, onError and onComplete are properly serialized.
* @return the serialized FlowableEmitter
*/
@NonNull
FlowableEmitter<T> serialize();
}
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/FlowableOnSubscribe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.reactivex;

import io.reactivex.annotations.*;

/**
* A functional interface that has a {@code subscribe()} method that receives
* an instance of a {@link FlowableEmitter} instance that allows pushing
Expand All @@ -26,6 +28,6 @@ public interface FlowableOnSubscribe<T> {
* @param e the safe emitter instance, never null
* @throws Exception on error
*/
void subscribe(FlowableEmitter<T> e) throws Exception;
void subscribe(@NonNull FlowableEmitter<T> e) throws Exception;
}

4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/FlowableOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.*;
import org.reactivestreams.Subscriber;

/**
Expand All @@ -28,5 +29,6 @@ public interface FlowableOperator<Downstream, Upstream> {
* @return the parent Subscriber instance
* @throws Exception on failure
*/
Subscriber<? super Upstream> apply(Subscriber<? super Downstream> observer) throws Exception;
@NonNull
Subscriber<? super Upstream> apply(@NonNull Subscriber<? super Downstream> observer) throws Exception;
}
5 changes: 2 additions & 3 deletions src/main/java/io/reactivex/FlowableSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

package io.reactivex;

import io.reactivex.annotations.*;
import org.reactivestreams.*;

import io.reactivex.annotations.Experimental;

/**
* Represents a Reactive-Streams inspired Subscriber that is RxJava 2 only
* and weakens rules §1.3 and §3.9 of the specification for gaining performance.
Expand All @@ -37,5 +36,5 @@ public interface FlowableSubscriber<T> extends Subscriber<T> {
* {@inheritDoc}
*/
@Override
void onSubscribe(Subscription s);
void onSubscribe(@NonNull Subscription s);
}
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/FlowableTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.*;
import org.reactivestreams.Publisher;

/**
Expand All @@ -28,5 +29,6 @@ public interface FlowableTransformer<Upstream, Downstream> {
* @param upstream the upstream Flowable instance
* @return the transformed Publisher instance
*/
Publisher<Downstream> apply(Flowable<Upstream> upstream);
@NonNull
Publisher<Downstream> apply(@NonNull Flowable<Upstream> upstream);
}
9 changes: 5 additions & 4 deletions src/main/java/io/reactivex/MaybeEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package io.reactivex;

import io.reactivex.annotations.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Cancellable;

Expand All @@ -32,13 +33,13 @@ public interface MaybeEmitter<T> {
* Signal a success value.
* @param t the value, not null
*/
void onSuccess(T t);
void onSuccess(@NonNull T t);

/**
* Signal an exception.
* @param t the exception, not null
*/
void onError(Throwable t);
void onError(@NonNull Throwable t);

/**
* Signal the completion.
Expand All @@ -50,14 +51,14 @@ public interface MaybeEmitter<T> {
* or Cancellation will be unsubscribed/cancelled.
* @param s the disposable, null is allowed
*/
void setDisposable(Disposable s);
void setDisposable(@Nullable Disposable s);

/**
* Sets a Cancellable on this emitter; any previous Disposable
* or Cancellation will be unsubscribed/cancelled.
* @param c the cancellable resource, null is allowed
*/
void setCancellable(Cancellable c);
void setCancellable(@Nullable Cancellable c);

/**
* Returns true if the downstream cancelled the sequence.
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/io/reactivex/MaybeObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

package io.reactivex;

import io.reactivex.annotations.*;
import io.reactivex.disposables.Disposable;

/**
* Provides a mechanism for receiving push-based notifications.
* <p>
Expand All @@ -37,7 +39,7 @@ public interface MaybeObserver<T> {
* @param d the Disposable instance whose {@link Disposable#dispose()} can
* be called anytime to cancel the connection
*/
void onSubscribe(Disposable d);
void onSubscribe(@NonNull Disposable d);

/**
* Notifies the MaybeObserver with one item and that the {@link Maybe} has finished sending
Expand All @@ -48,7 +50,7 @@ public interface MaybeObserver<T> {
* @param t
* the item emitted by the Maybe
*/
void onSuccess(T t);
void onSuccess(@NonNull T t);

/**
* Notifies the MaybeObserver that the {@link Maybe} has experienced an error condition.
Expand All @@ -58,7 +60,7 @@ public interface MaybeObserver<T> {
* @param e
* the exception encountered by the Maybe
*/
void onError(Throwable e);
void onError(@NonNull Throwable e);

/**
* Called once the deferred computation completes normally.
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/MaybeOnSubscribe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.reactivex;

import io.reactivex.annotations.*;

/**
* A functional interface that has a {@code subscribe()} method that receives
* an instance of a {@link MaybeEmitter} instance that allows pushing
Expand All @@ -26,6 +28,6 @@ public interface MaybeOnSubscribe<T> {
* @param e the safe emitter instance, never null
* @throws Exception on error
*/
void subscribe(MaybeEmitter<T> e) throws Exception;
void subscribe(@NonNull MaybeEmitter<T> e) throws Exception;
}

6 changes: 4 additions & 2 deletions src/main/java/io/reactivex/MaybeOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
* 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;

import io.reactivex.annotations.*;

/**
* Interface to map/wrap a downstream observer to an upstream observer.
*
Expand All @@ -26,5 +27,6 @@ public interface MaybeOperator<Downstream, Upstream> {
* @return the parent MaybeObserver instance
* @throws Exception on failure
*/
MaybeObserver<? super Upstream> apply(MaybeObserver<? super Downstream> observer) throws Exception;
@NonNull
MaybeObserver<? super Upstream> apply(@NonNull MaybeObserver<? super Downstream> observer) throws Exception;
}
4 changes: 3 additions & 1 deletion src/main/java/io/reactivex/MaybeSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package io.reactivex;

import io.reactivex.annotations.*;

/**
* Represents a basic {@link Maybe} source base interface,
* consumable via an {@link MaybeObserver}.
Expand All @@ -29,5 +31,5 @@ public interface MaybeSource<T> {
* @param observer the MaybeObserver, not null
* @throws NullPointerException if {@code observer} is null
*/
void subscribe(MaybeObserver<? super T> observer);
void subscribe(@NonNull MaybeObserver<? super T> observer);
}
5 changes: 4 additions & 1 deletion src/main/java/io/reactivex/MaybeTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.reactivex;

import io.reactivex.annotations.*;

/**
* Interface to compose Maybes.
*
Expand All @@ -26,5 +28,6 @@ public interface MaybeTransformer<Upstream, Downstream> {
* @param upstream the upstream Maybe instance
* @return the transformed MaybeSource instance
*/
MaybeSource<Downstream> apply(Maybe<Upstream> upstream);
@NonNull
MaybeSource<Downstream> apply(@NonNull Maybe<Upstream> upstream);
}
Loading