Skip to content

Commit 5c58f82

Browse files
vpriscanakarnokd
authored andcommitted
Add @nonnull annotations to create methods of Subjects and Processors (#5930)
1 parent b0298ab commit 5c58f82

11 files changed

+35
-0
lines changed

src/main/java/io/reactivex/processors/BehaviorProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public final class BehaviorProcessor<T> extends FlowableProcessor<T> {
189189
* @return the constructed {@link BehaviorProcessor}
190190
*/
191191
@CheckReturnValue
192+
@NonNull
192193
public static <T> BehaviorProcessor<T> create() {
193194
return new BehaviorProcessor<T>();
194195
}
@@ -205,6 +206,7 @@ public static <T> BehaviorProcessor<T> create() {
205206
* @return the constructed {@link BehaviorProcessor}
206207
*/
207208
@CheckReturnValue
209+
@NonNull
208210
public static <T> BehaviorProcessor<T> createDefault(T defaultValue) {
209211
ObjectHelper.requireNonNull(defaultValue, "defaultValue is null");
210212
return new BehaviorProcessor<T>(defaultValue);

src/main/java/io/reactivex/processors/PublishProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public final class PublishProcessor<T> extends FlowableProcessor<T> {
7676
* @return the new PublishProcessor
7777
*/
7878
@CheckReturnValue
79+
@NonNull
7980
public static <T> PublishProcessor<T> create() {
8081
return new PublishProcessor<T>();
8182
}

src/main/java/io/reactivex/processors/ReplayProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public final class ReplayProcessor<T> extends FlowableProcessor<T> {
117117
* @return the created ReplayProcessor
118118
*/
119119
@CheckReturnValue
120+
@NonNull
120121
public static <T> ReplayProcessor<T> create() {
121122
return new ReplayProcessor<T>(new UnboundedReplayBuffer<T>(16));
122123
}
@@ -137,6 +138,7 @@ public static <T> ReplayProcessor<T> create() {
137138
* @return the created subject
138139
*/
139140
@CheckReturnValue
141+
@NonNull
140142
public static <T> ReplayProcessor<T> create(int capacityHint) {
141143
return new ReplayProcessor<T>(new UnboundedReplayBuffer<T>(capacityHint));
142144
}
@@ -162,6 +164,7 @@ public static <T> ReplayProcessor<T> create(int capacityHint) {
162164
* @return the created subject
163165
*/
164166
@CheckReturnValue
167+
@NonNull
165168
public static <T> ReplayProcessor<T> createWithSize(int maxSize) {
166169
return new ReplayProcessor<T>(new SizeBoundReplayBuffer<T>(maxSize));
167170
}
@@ -216,6 +219,7 @@ public static <T> ReplayProcessor<T> createWithSize(int maxSize) {
216219
* @return the created subject
217220
*/
218221
@CheckReturnValue
222+
@NonNull
219223
public static <T> ReplayProcessor<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) {
220224
return new ReplayProcessor<T>(new SizeAndTimeBoundReplayBuffer<T>(Integer.MAX_VALUE, maxAge, unit, scheduler));
221225
}
@@ -255,6 +259,7 @@ public static <T> ReplayProcessor<T> createWithTime(long maxAge, TimeUnit unit,
255259
* @return the created subject
256260
*/
257261
@CheckReturnValue
262+
@NonNull
258263
public static <T> ReplayProcessor<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) {
259264
return new ReplayProcessor<T>(new SizeAndTimeBoundReplayBuffer<T>(maxSize, maxAge, unit, scheduler));
260265
}

src/main/java/io/reactivex/processors/UnicastProcessor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.reactivex.annotations.Experimental;
2020
import io.reactivex.annotations.Nullable;
21+
import io.reactivex.annotations.NonNull;
2122
import org.reactivestreams.*;
2223

2324
import io.reactivex.internal.functions.ObjectHelper;
@@ -74,6 +75,7 @@ public final class UnicastProcessor<T> extends FlowableProcessor<T> {
7475
* @return an UnicastSubject instance
7576
*/
7677
@CheckReturnValue
78+
@NonNull
7779
public static <T> UnicastProcessor<T> create() {
7880
return new UnicastProcessor<T>(bufferSize());
7981
}
@@ -85,6 +87,7 @@ public static <T> UnicastProcessor<T> create() {
8587
* @return an UnicastProcessor instance
8688
*/
8789
@CheckReturnValue
90+
@NonNull
8891
public static <T> UnicastProcessor<T> create(int capacityHint) {
8992
return new UnicastProcessor<T>(capacityHint);
9093
}
@@ -98,6 +101,7 @@ public static <T> UnicastProcessor<T> create(int capacityHint) {
98101
*/
99102
@CheckReturnValue
100103
@Experimental
104+
@NonNull
101105
public static <T> UnicastProcessor<T> create(boolean delayError) {
102106
return new UnicastProcessor<T>(bufferSize(), null, delayError);
103107
}
@@ -115,6 +119,7 @@ public static <T> UnicastProcessor<T> create(boolean delayError) {
115119
* @return an UnicastProcessor instance
116120
*/
117121
@CheckReturnValue
122+
@NonNull
118123
public static <T> UnicastProcessor<T> create(int capacityHint, Runnable onCancelled) {
119124
ObjectHelper.requireNonNull(onCancelled, "onTerminate");
120125
return new UnicastProcessor<T>(capacityHint, onCancelled);
@@ -136,6 +141,7 @@ public static <T> UnicastProcessor<T> create(int capacityHint, Runnable onCancel
136141
*/
137142
@CheckReturnValue
138143
@Experimental
144+
@NonNull
139145
public static <T> UnicastProcessor<T> create(int capacityHint, Runnable onCancelled, boolean delayError) {
140146
ObjectHelper.requireNonNull(onCancelled, "onTerminate");
141147
return new UnicastProcessor<T>(capacityHint, onCancelled, delayError);

src/main/java/io/reactivex/subjects/AsyncSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package io.reactivex.subjects;
1515

1616
import io.reactivex.annotations.Nullable;
17+
import io.reactivex.annotations.NonNull;
1718
import java.util.Arrays;
1819
import java.util.concurrent.atomic.AtomicReference;
1920

@@ -129,6 +130,7 @@ public final class AsyncSubject<T> extends Subject<T> {
129130
* @return the new AsyncProcessor instance
130131
*/
131132
@CheckReturnValue
133+
@NonNull
132134
public static <T> AsyncSubject<T> create() {
133135
return new AsyncSubject<T>();
134136
}

src/main/java/io/reactivex/subjects/BehaviorSubject.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import io.reactivex.annotations.CheckReturnValue;
1717
import io.reactivex.annotations.Nullable;
18+
import io.reactivex.annotations.NonNull;
1819
import java.lang.reflect.Array;
1920
import java.util.concurrent.atomic.AtomicReference;
2021
import java.util.concurrent.locks.*;
@@ -180,6 +181,7 @@ public final class BehaviorSubject<T> extends Subject<T> {
180181
* @return the constructed {@link BehaviorSubject}
181182
*/
182183
@CheckReturnValue
184+
@NonNull
183185
public static <T> BehaviorSubject<T> create() {
184186
return new BehaviorSubject<T>();
185187
}
@@ -196,6 +198,7 @@ public static <T> BehaviorSubject<T> create() {
196198
* @return the constructed {@link BehaviorSubject}
197199
*/
198200
@CheckReturnValue
201+
@NonNull
199202
public static <T> BehaviorSubject<T> createDefault(T defaultValue) {
200203
return new BehaviorSubject<T>(defaultValue);
201204
}

src/main/java/io/reactivex/subjects/CompletableSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.reactivex.*;
2020
import io.reactivex.annotations.CheckReturnValue;
21+
import io.reactivex.annotations.NonNull;
2122
import io.reactivex.disposables.Disposable;
2223
import io.reactivex.internal.functions.ObjectHelper;
2324
import io.reactivex.plugins.RxJavaPlugins;
@@ -101,6 +102,7 @@ public final class CompletableSubject extends Completable implements Completable
101102
* @return the new CompletableSubject instance
102103
*/
103104
@CheckReturnValue
105+
@NonNull
104106
public static CompletableSubject create() {
105107
return new CompletableSubject();
106108
}

src/main/java/io/reactivex/subjects/MaybeSubject.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public final class MaybeSubject<T> extends Maybe<T> implements MaybeObserver<T>
129129
* @return the new MaybeSubject instance
130130
*/
131131
@CheckReturnValue
132+
@NonNull
132133
public static <T> MaybeSubject<T> create() {
133134
return new MaybeSubject<T>();
134135
}

src/main/java/io/reactivex/subjects/PublishSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import io.reactivex.annotations.CheckReturnValue;
1717
import io.reactivex.annotations.Nullable;
18+
import io.reactivex.annotations.NonNull;
1819
import java.util.concurrent.atomic.*;
1920

2021
import io.reactivex.Observer;
@@ -114,6 +115,7 @@ public final class PublishSubject<T> extends Subject<T> {
114115
* @return the new PublishSubject
115116
*/
116117
@CheckReturnValue
118+
@NonNull
117119
public static <T> PublishSubject<T> create() {
118120
return new PublishSubject<T>();
119121
}

src/main/java/io/reactivex/subjects/ReplaySubject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public final class ReplaySubject<T> extends Subject<T> {
158158
* @return the created subject
159159
*/
160160
@CheckReturnValue
161+
@NonNull
161162
public static <T> ReplaySubject<T> create() {
162163
return new ReplaySubject<T>(new UnboundedReplayBuffer<T>(16));
163164
}
@@ -178,6 +179,7 @@ public static <T> ReplaySubject<T> create() {
178179
* @return the created subject
179180
*/
180181
@CheckReturnValue
182+
@NonNull
181183
public static <T> ReplaySubject<T> create(int capacityHint) {
182184
return new ReplaySubject<T>(new UnboundedReplayBuffer<T>(capacityHint));
183185
}
@@ -203,6 +205,7 @@ public static <T> ReplaySubject<T> create(int capacityHint) {
203205
* @return the created subject
204206
*/
205207
@CheckReturnValue
208+
@NonNull
206209
public static <T> ReplaySubject<T> createWithSize(int maxSize) {
207210
return new ReplaySubject<T>(new SizeBoundReplayBuffer<T>(maxSize));
208211
}
@@ -257,6 +260,7 @@ public static <T> ReplaySubject<T> createWithSize(int maxSize) {
257260
* @return the created subject
258261
*/
259262
@CheckReturnValue
263+
@NonNull
260264
public static <T> ReplaySubject<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) {
261265
return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(Integer.MAX_VALUE, maxAge, unit, scheduler));
262266
}
@@ -296,6 +300,7 @@ public static <T> ReplaySubject<T> createWithTime(long maxAge, TimeUnit unit, Sc
296300
* @return the created subject
297301
*/
298302
@CheckReturnValue
303+
@NonNull
299304
public static <T> ReplaySubject<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) {
300305
return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(maxSize, maxAge, unit, scheduler));
301306
}

0 commit comments

Comments
 (0)