23
23
/**
24
24
* For use in internal operators that need something like materialize and dematerialize wholly within the
25
25
* implementation of the operator but don't want to incur the allocation cost of actually creating
26
- * {@link rx.Notification} objects for every {@code onNext} and {@code onComplete}.
27
- *
26
+ * {@link rx.Notification} objects for every {@link Observer#onNext onNext} and
27
+ * {@link Observer#onCompleted onCompleted}.
28
+ * <p>
28
29
* An object is allocated inside {@link #error(Throwable)} to wrap the {@link Throwable} but this shouldn't
29
30
* affect performance because exceptions should be exceptionally rare.
30
- *
31
+ * <p>
31
32
* It's implemented as a singleton to maintain some semblance of type safety that is completely non-existent.
32
33
*
33
34
* @param <T>
34
- * @warn type param <T> undescribed
35
+ * @warn type param undescribed
35
36
*/
36
37
public final class NotificationLite <T > {
37
38
private NotificationLite () {
@@ -41,7 +42,9 @@ private NotificationLite() {
41
42
private static final NotificationLite INSTANCE = new NotificationLite ();
42
43
43
44
/**
44
- * @warn instance() undocumented
45
+ * Gets the {@code NotificationLite} singleton.
46
+ *
47
+ * @return the sole {@code NotificationLite} object
45
48
*/
46
49
@ SuppressWarnings ("unchecked" )
47
50
public static <T > NotificationLite <T > instance () {
@@ -70,8 +73,8 @@ public OnErrorSentinel(Throwable e) {
70
73
* be unwrapped and sent with the {@link #accept} method.
71
74
*
72
75
* @param t
73
- * @warn parameter "t" undescribed
74
- * @return the value or a null token
76
+ * the item emitted to {@code onNext}
77
+ * @return the item, or a null token representing the item if the item is {@code null}
75
78
*/
76
79
public Object next (T t ) {
77
80
if (t == null )
@@ -81,23 +84,22 @@ public Object next(T t) {
81
84
}
82
85
83
86
/**
84
- * Creates a lite {@code onComplete } notification without doing any allocation. Can be unwrapped and
87
+ * Creates a lite {@code onCompleted } notification without doing any allocation. Can be unwrapped and
85
88
* sent with the {@link #accept} method.
86
89
*
87
- * @return the completion token
90
+ * @return a completion token
88
91
*/
89
92
public Object completed () {
90
93
return ON_COMPLETED_SENTINEL ;
91
94
}
92
95
93
96
/**
94
- * Create a lite {@code onError} notification. This call does new up an object to wrap the {@link Throwable}
95
- * but since there should only be one of these the performance impact should be small. Can be unwrapped and
97
+ * Create a lite {@code onError} notification. This call creates an object to wrap the {@link Throwable},
98
+ * but since there should only be one of these, the performance impact should be small. Can be unwrapped and
96
99
* sent with the {@link #accept} method.
97
100
*
98
- * @warn description doesn't parse in English ("This call does new up an object...")
99
101
* @param e
100
- * @warn parameter "e" undescribed
102
+ * the {@code Throwable} in the {@code onError} notification
101
103
* @return an object encapsulating the exception
102
104
*/
103
105
public Object error (Throwable e ) {
@@ -108,10 +110,10 @@ public Object error(Throwable e) {
108
110
* Unwraps the lite notification and calls the appropriate method on the {@link Observer}.
109
111
*
110
112
* @param o
111
- * the {@link Observer} to call onNext, onCompleted, or onError.
112
- * @warn parameter "n" undescribed
113
+ * the {@link Observer} to call {@code onNext}, {@code onCompleted}, or {@code onError}.
113
114
* @param n
114
- * @return true if {@code n} was a termination event
115
+ * the lite notification
116
+ * @return {@code true} if {@code n} represents a termination event; {@code false} otherwise
115
117
* @throws IllegalArgumentException
116
118
* if the notification is null.
117
119
* @throws NullPointerException
@@ -138,28 +140,38 @@ public boolean accept(Observer<? super T> o, Object n) {
138
140
}
139
141
140
142
/**
141
- * @warn isCompleted() undocumented
143
+ * Indicates whether or not the lite notification represents an {@code onCompleted} event.
144
+ *
145
+ * @param n
146
+ * the lite notification
147
+ * @return {@code true} if {@code n} represents an {@code onCompleted} event; {@code false} otherwise
142
148
*/
143
149
public boolean isCompleted (Object n ) {
144
150
return n == ON_COMPLETED_SENTINEL ;
145
151
}
146
152
147
153
/**
148
- * @warn isError() undocumented
154
+ * Indicates whether or not the lite notification represents an {@code onError} event.
155
+ *
156
+ * @param n
157
+ * the lite notification
158
+ * @return {@code true} if {@code n} represents an {@code onError} event; {@code false} otherwise
149
159
*/
150
160
public boolean isError (Object n ) {
151
161
return n instanceof OnErrorSentinel ;
152
162
}
153
163
154
164
/**
155
- * If there is custom logic that isn't as simple as call the right method on an {@link Observer} then this
156
- * method can be used to get the {@link rx.Notification.Kind}.
165
+ * Indicates which variety a particular lite notification is. If you need something more complex than
166
+ * simply calling the right method on an {@link Observer} then you can use this method to get the
167
+ * {@link rx.Notification.Kind}.
157
168
*
158
169
* @param n
159
- * @warn parameter "n" undescribed
170
+ * the lite notification
160
171
* @throws IllegalArgumentException
161
172
* if the notification is null.
162
- * @return the kind of the raw object
173
+ * @return the {@link Kind} of lite notification {@code n} is: either {@code Kind.OnCompleted},
174
+ * {@code Kind.OnError}, or {@code Kind.OnNext}
163
175
*/
164
176
public Kind kind (Object n ) {
165
177
if (n == null )
@@ -174,12 +186,12 @@ else if (n instanceof OnErrorSentinel)
174
186
}
175
187
176
188
/**
177
- * Returns the value passed in {@link #next(Object)} method call . Bad things happen if you call this
178
- * the {@code onComplete } or {@code onError } notification type. For performance you are expected to use this
179
- * when it is appropriate .
189
+ * Returns the item corresponding to this {@code OnNext} lite notification . Bad things happen if you pass
190
+ * this an {@code OnComplete } or {@code OnError } notification type. For performance reasons, this method
191
+ * does not check for this, so you are expected to prevent such a mishap .
180
192
*
181
193
* @param n
182
- * @warn parameter "n" undescribed
194
+ * the lite notification (of type {@code Kind.OnNext})
183
195
* @return the unwrapped value, which can be null
184
196
*/
185
197
@ SuppressWarnings ("unchecked" )
@@ -188,13 +200,13 @@ public T getValue(Object n) {
188
200
}
189
201
190
202
/**
191
- * Returns the {@link Throwable} passed to the {@link #error(Throwable)} method call . Bad things happen if
192
- * you call this on the {@code onComplete } or {@code onNext } notification type. For performance you are
193
- * expected to use this when it is appropriate .
203
+ * Returns the {@link Throwable} corresponding to this {@code OnError} lite notification . Bad things happen
204
+ * if you pass this an {@code OnComplete } or {@code OnNext } notification type. For performance reasons, this
205
+ * method does not check for this, so you are expected to prevent such a mishap .
194
206
*
195
207
* @param n
196
- * @warn parameter "n" undescribed
197
- * @return the {@link Throwable} wrapped inside n
208
+ * the lite notification (of type {@code Kind.OnError})
209
+ * @return the {@link Throwable} wrapped inside {@code n}
198
210
*/
199
211
public Throwable getError (Object n ) {
200
212
return ((OnErrorSentinel ) n ).e ;
0 commit comments