Skip to content

Commit 6eeb249

Browse files
committed
Javadoc overhaul: 1) standardize formatting, phrasing, terminology; 2) fill in gaps where javadocs (or parts of them) were missing; 3) add spurious @warn tags to cause build warnings for as-yet-unfilled gaps
1 parent e8afd05 commit 6eeb249

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1092
-546
lines changed

rxjava-core/src/main/java/rx/Notification.java

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* An object representing a notification sent to an {@link Observable}.
2020
*
21-
* For the Microsoft Rx equivalent see: http://msdn.microsoft.com/en-us/library/hh229462(v=vs.103).aspx
21+
* @see <a href="http://github.com/%3C/span%3Ehttp://msdn.microsoft.com/en-us/library/hh229462%3Cspan%20class="x x-first x-last">.aspx">the Microsoft Rx equivalent</a>
2222
*/
2323
public class Notification<T> {
2424

@@ -28,19 +28,42 @@ public class Notification<T> {
2828

2929
private static final Notification<Void> ON_COMPLETED = new Notification<Void>(Kind.OnCompleted, null, null);
3030

31+
/**
32+
* Creates and returns a {@code Notification} of variety {@code Kind.OnNext}, and assigns it a value.
33+
*
34+
* @param t
35+
* the item to assign to the notification as its value
36+
* @return an {@code OnNext} variety of {@code Notification}
37+
*/
3138
public static <T> Notification<T> createOnNext(T t) {
3239
return new Notification<T>(Kind.OnNext, t, null);
3340
}
3441

42+
/**
43+
* Creates and returns a {@code Notification} of variety {@code Kind.OnError}, and assigns it an exception.
44+
*
45+
* @param e
46+
* the exception to assign to the notification
47+
* @return an {@code OnError} variety of {@code Notification}
48+
*/
3549
public static <T> Notification<T> createOnError(Throwable e) {
3650
return new Notification<T>(Kind.OnError, null, e);
3751
}
3852

53+
/**
54+
* Creates and returns a {@code Notification} of variety {@code Kind.OnCompleted}.
55+
*
56+
* @return an {@code OnCompleted} variety of {@code Notification}
57+
*/
3958
@SuppressWarnings("unchecked")
4059
public static <T> Notification<T> createOnCompleted() {
4160
return (Notification<T>) ON_COMPLETED;
4261
}
4362

63+
/**
64+
* @warn javadoc missing
65+
* @return
66+
*/
4467
@SuppressWarnings("unchecked")
4568
public static <T> Notification<T> createOnCompleted(Class<T> type) {
4669
return (Notification<T>) ON_COMPLETED;
@@ -53,62 +76,81 @@ private Notification(Kind kind, T value, Throwable e) {
5376
}
5477

5578
/**
56-
* Retrieves the exception associated with an onError notification.
79+
* Retrieves the exception associated with this (onError) notification.
5780
*
58-
* @return Throwable associated with an onError notification.
81+
* @return the Throwable associated with this (onError) notification
5982
*/
6083
public Throwable getThrowable() {
6184
return throwable;
6285
}
6386

6487
/**
65-
* Retrieves the data associated with an onNext notification.
88+
* Retrieves the item associated with this (onNext) notification.
6689
*
67-
* @return The data associated with an onNext notification.
90+
* @return the item associated with this (onNext) notification
6891
*/
6992
public T getValue() {
7093
return value;
7194
}
7295

7396
/**
74-
* Retrieves a value indicating whether this notification has a value.
97+
* Indicates whether this notification has an item associated with it.
7598
*
76-
* @return a value indicating whether this notification has a value.
99+
* @return a boolean indicating whether or not this notification has an item associated with it
77100
*/
78101
public boolean hasValue() {
79102
return isOnNext() && value != null;
103+
// isn't "null" a valid item?
80104
}
81105

82106
/**
83-
* Retrieves a value indicating whether this notification has an exception.
107+
* Indicates whether this notification has an exception associated with it.
84108
*
85-
* @return a value indicating whether this notification has an exception.
109+
* @return a boolean indicating whether this notification has an exception associated with it
86110
*/
87111
public boolean hasThrowable() {
88112
return isOnError() && throwable != null;
89113
}
90114

91115
/**
92-
* Retrieves the kind of the notification: OnNext, OnError, OnCompleted
116+
* Retrieves the kind of this notification: {@code OnNext}, {@code OnError}, or {@code OnCompleted}
93117
*
94-
* @return the kind of the notification: OnNext, OnError, OnCompleted
118+
* @return the kind of the notification: {@code OnNext}, {@code OnError}, or {@code OnCompleted}
95119
*/
96120
public Kind getKind() {
97121
return kind;
98122
}
99123

124+
/**
125+
* Indicates whether this notification represents an {@code onError} event.
126+
*
127+
* @return a boolean indicating whether this notification represents an {@code onError} event
128+
*/
100129
public boolean isOnError() {
101130
return getKind() == Kind.OnError;
102131
}
103132

133+
/**
134+
* Indicates whether this notification represents an {@code onCompleted} event.
135+
*
136+
* @return a boolean indicating whether this notification represents an {@code onCompleted} event
137+
*/
104138
public boolean isOnCompleted() {
105139
return getKind() == Kind.OnCompleted;
106140
}
107141

142+
/**
143+
* Indicates whether this notification represents an {@code onNext} event.
144+
*
145+
* @return a boolean indicating whether this notification represents an {@code onNext} event
146+
*/
108147
public boolean isOnNext() {
109148
return getKind() == Kind.OnNext;
110149
}
111150

151+
/**
152+
* @warn javadoc missing
153+
*/
112154
public void accept(Observer<? super T> observer) {
113155
if (isOnNext()) {
114156
observer.onNext(getValue());

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,19 +2892,16 @@ public final Observable<T> asObservable() {
28922892
/**
28932893
* Returns an Observable that emits buffers of items it collects from the source Observable. The resulting
28942894
* Observable emits connected, non-overlapping buffers. It emits the current buffer and replaces it with a
2895-
* new buffer when the Observable produced by the specified {@code bufferClosingSelector} emits an item. It
2896-
* then uses the {@code bufferClosingSelector} to create a new Observable to observe to indicate the end of
2897-
* the next buffer.
2895+
* new buffer whenever the Observable produced by the specified {@code bufferClosingSelector} emits an item.
28982896
* <p>
28992897
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/buffer1.png">
29002898
*
29012899
* @param bufferClosingSelector
2902-
* a {@link Func0} that produces an Observable for each buffer created. When this
2903-
* {@code Observable} emits an item, {@code buffer} emits the associated buffer and replaces it
2904-
* with a new one
2900+
* a {@link Func0} that produces an Observable that governs the boundary between buffers.
2901+
* Whenever this {@code Observable} emits an item, {@code buffer} emits the current buffer and
2902+
* begins to fill a new one
29052903
* @return an Observable that emits a connected, non-overlapping buffer of items from the source Observable
2906-
* each time the current Observable created with the {@code bufferClosingSelector} argument emits an
2907-
* item
2904+
* each time the Observable created with the {@code bufferClosingSelector} argument emits an item
29082905
* @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#wiki-buffer">RxJava Wiki: buffer()</a>
29092906
*/
29102907
public final <TClosing> Observable<List<T>> buffer(Func0<? extends Observable<? extends TClosing>> bufferClosingSelector) {
@@ -5495,16 +5492,19 @@ public final <R> Observable<R> scan(R initialValue, Func2<R, ? super T, R> accum
54955492
}
54965493

54975494
/*
5498-
* Forces an Observable to make synchronous calls and to be well-behaved.
5495+
* Forces an Observable's emissions and notifications to be serialized and for it to obey the Rx contract
5496+
* in other ways.
54995497
* <p>
5500-
* It is possible for an Observable to invoke its Subscribers' methods asynchronously, perhaps in different
5501-
* threads. This could make an Observable poorly-behaved, in that it might invoke {@code onCompleted} or
5502-
* {@code onError} before one of its {@code onNext} invocations. You can force such an Observable to be
5503-
* well-behaved and synchronous by applying the {@code serialize} method to it.
5498+
* It is possible for an Observable to invoke its Subscribers' methods asynchronously, perhaps from
5499+
* different threads. This could make such an Observable poorly-behaved, in that it might try to invoke
5500+
* {@code onCompleted} or {@code onError} before one of its {@code onNext} invocations, or it might call
5501+
* {@code onNext} from two different threads simultaneously. You can force such an Observable to be
5502+
* well-behaved and sequential by applying the {@code serialize} method to it.
55045503
* <p>
55055504
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/synchronize.png">
55065505
*
5507-
* @return a {@link Observable} that is guaranteed to be well-behaved and synchronous
5506+
* @return an {@link Observable} that is guaranteed to be well-behaved and to make only serialized calls to
5507+
* its observers
55085508
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#serialize">RxJava Wiki: serialize()</a>
55095509
* @since 0.17
55105510
*/
@@ -7379,17 +7379,17 @@ public final Observable<T> unsubscribeOn(Scheduler scheduler) {
73797379

73807380
/**
73817381
* Returns an Observable that emits windows of items it collects from the source Observable. The resulting
7382-
* Observable emits connected, non-overlapping windows. It emits the current window and opens a new one when
7383-
* the Observable produced by the specified {@code closingSelector} emits an item. The
7384-
* {@code closingSelector} then creates a new Observable to generate the closer of the next window.
7382+
* Observable emits connected, non-overlapping windows. It emits the current window and opens a new one
7383+
* whenever the Observable produced by the specified {@code closingSelector} emits an item.
73857384
* <p>
73867385
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/window1.png">
73877386
*
73887387
* @param closingSelector
7389-
* a {@link Func0} that produces an Observable for every window created. When this Observable
7390-
* emits an item, {@code window} emits the associated window and begins a new one.
7388+
* a {@link Func0} that returns an {@code Observable} that governs the boundary between windows.
7389+
* When this {@code Observable} emits an item, {@code window} emits the current window and begins
7390+
* a new one.
73917391
* @return an Observable that emits connected, non-overlapping windows of items from the source Observable
7392-
* when {@code closingSelector} emits an item
7392+
* whenever {@code closingSelector} emits an item
73937393
* @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#wiki-window">RxJava Wiki: window()</a>
73947394
*/
73957395
public final <TClosing> Observable<Observable<T>> window(Func0<? extends Observable<? extends TClosing>> closingSelector) {

rxjava-core/src/main/java/rx/Observer.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,45 @@
1818
/**
1919
* Provides a mechanism for receiving push-based notifications.
2020
* <p>
21-
* After an Observer calls an {@link Observable}'s <code>Observable.subscribe</code> method, the
22-
* {@link Observable} calls the Observer's <code>onNext</code> method to provide notifications. A well-behaved
23-
* {@link Observable} will call an Observer's <code>onCompleted</code> closure exactly once or the Observer's
24-
* <code>onError</code> closure exactly once.
25-
* <p>
26-
* For more information see the <a href="https://github.com/Netflix/RxJava/wiki/Observable">RxJava Wiki</a>
21+
* After an Observer calls an {@link Observable}'s {@link Observable#subscribe subscribe} method, the
22+
* {@code Observable} calls the Observer's {@link #onNext} method to provide notifications. A well-behaved
23+
* {@code Observable} will call an Observer's {@link #onCompleted} method exactly once or the Observer's
24+
* {@link #onError} method exactly once.
2725
*
26+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable">RxJava Wiki: Observable</a>
2827
* @param <T>
28+
* the type of item the Observer expects to observe
2929
*/
3030
public interface Observer<T> {
3131

3232
/**
3333
* Notifies the Observer that the {@link Observable} has finished sending push-based notifications.
3434
* <p>
35-
* The {@link Observable} will not call this closure if it calls <code>onError</code>.
35+
* The {@link Observable} will not call this method if it calls {@link #onError}.
3636
*/
3737
public abstract void onCompleted();
3838

3939
/**
4040
* Notifies the Observer that the {@link Observable} has experienced an error condition.
4141
* <p>
42-
* If the {@link Observable} calls this closure, it will not thereafter call <code>onNext</code> or
43-
* <code>onCompleted</code>.
42+
* If the {@link Observable} calls this method, it will not thereafter call {@link #onNext} or
43+
* {@link #onCompleted}.
4444
*
4545
* @param e
46+
* the exception encountered by the Observable
4647
*/
4748
public abstract void onError(Throwable e);
4849

4950
/**
50-
* Provides the Observer with new data.
51+
* Provides the Observer with a new item to observe.
5152
* <p>
52-
* The {@link Observable} calls this closure 1 or more times, unless it calls <code>onError</code> in which
53-
* case this closure may never be called.
53+
* The {@link Observable} may call this closure 0 or more times.
5454
* <p>
55-
* The {@link Observable} will not call this closure again after it calls either <code>onCompleted</code> or
56-
* <code>onError</code>.
55+
* The {@code Observable} will not call this closure again after it calls either {@link #onCompleted} or
56+
* {@link #onError}.
5757
*
5858
* @param t
59+
* the item emitted by the Observable
5960
*/
6061
public abstract void onNext(T t);
6162

rxjava-core/src/main/java/rx/Scheduler.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
* Common implementations can be found in {@link Schedulers}.
2727
* <p>
2828
* Why is this an abstract class instead of an interface?
29-
* <p>
3029
* <ol>
3130
* <li>Java doesn't support extension methods and there are many overload methods needing default
3231
* implementations.</li>
@@ -42,13 +41,13 @@
4241
public abstract class Scheduler {
4342

4443
/**
45-
* Retrieve or create a new {@link Scheduler.Worker} that represents serial execution of actions.
44+
* Retrieves or creates a new {@link Scheduler.Worker} that represents serial execution of actions.
4645
* <p>
4746
* When work is completed it should be unsubscribed using {@link Scheduler.Worker#unsubscribe()}.
4847
* <p>
4948
* Work on a {@link Scheduler.Worker} is guaranteed to be sequential.
5049
*
51-
* @return Worker representing a serial queue of actions to be executed
50+
* @return a Worker representing a serial queue of actions to be executed
5251
*/
5352
public abstract Worker createWorker();
5453

@@ -66,19 +65,21 @@ public abstract static class Worker implements Subscription {
6665
* Action to schedule
6766
* @return a subscription to be able to unsubscribe the action (unschedule it if not executed)
6867
*/
69-
7068
public abstract Subscription schedule(Action0 action);
7169

7270
/**
7371
* Schedules an Action for execution at some point in the future.
74-
* <p>Note to implementors: non-positive {@code delayTime} should be regarded as
75-
* undelayed schedule, i.e., as if the {@link #schedule(rx.functions.Action0)} was called.
72+
* <p>
73+
* Note to implementors: non-positive {@code delayTime} should be regarded as undelayed schedule, i.e.,
74+
* as if the {@link #schedule(rx.functions.Action0)} was called.
75+
*
7676
* @param action
7777
* the Action to schedule
7878
* @param delayTime
79-
* time to wait before executing the action, non-positive values indicate an undelayed schedule
79+
* time to wait before executing the action; non-positive values indicate an undelayed
80+
* schedule
8081
* @param unit
81-
* the time unit the delay time is given in
82+
* the time unit of {@code delayTime}
8283
* @return a subscription to be able to unsubscribe the action (unschedule it if not executed)
8384
*/
8485
public abstract Subscription schedule(final Action0 action, final long delayTime, final TimeUnit unit);
@@ -87,19 +88,20 @@ public abstract static class Worker implements Subscription {
8788
* Schedules a cancelable action to be executed periodically. This default implementation schedules
8889
* recursively and waits for actions to complete (instead of potentially executing long-running actions
8990
* concurrently). Each scheduler that can do periodic scheduling in a better way should override this.
90-
* <p>Note to implementors: non-positive {@code initialTime} and {@code period} should be regarded as
91+
* <p>
92+
* Note to implementors: non-positive {@code initialTime} and {@code period} should be regarded as
9193
* undelayed scheduling of the first and any subsequent executions.
9294
*
9395
* @param action
9496
* the Action to execute periodically
9597
* @param initialDelay
96-
* time to wait before executing the action for the first time,
97-
* non-positive values indicate an undelayed schedule
98+
* time to wait before executing the action for the first time; non-positive values indicate
99+
* an undelayed schedule
98100
* @param period
99-
* the time interval to wait each time in between executing the action,
100-
* non-positive values indicate no delay between repeated schedules
101+
* the time interval to wait each time in between executing the action; non-positive values
102+
* indicate no delay between repeated schedules
101103
* @param unit
102-
* the time unit the interval above is given in
104+
* the time unit of {@code period}
103105
* @return a subscription to be able to unsubscribe the action (unschedule it if not executed)
104106
*/
105107
public Subscription schedulePeriodically(final Action0 action, long initialDelay, long period, TimeUnit unit) {
@@ -121,15 +123,17 @@ public void call() {
121123
}
122124

123125
/**
124-
* @return the scheduler's notion of current absolute time in milliseconds.
126+
* Gets the current time, in milliseconds, according to this Scheduler.
127+
*
128+
* @return the scheduler's notion of current absolute time in milliseconds
125129
*/
126130
public long now() {
127131
return System.currentTimeMillis();
128132
}
129133
}
130134

131135
/**
132-
* Parallelism available to a Scheduler.
136+
* Indicates the parallelism available to this Scheduler.
133137
* <p>
134138
* This defaults to {@code Runtime.getRuntime().availableProcessors()} but can be overridden for use cases
135139
* such as scheduling work on a computer cluster.
@@ -141,7 +145,9 @@ public int parallelism() {
141145
}
142146

143147
/**
144-
* @return the scheduler's notion of current absolute time in milliseconds.
148+
* Gets the current time, in milliseconds, according to this Scheduler.
149+
*
150+
* @return the scheduler's notion of current absolute time in milliseconds
145151
*/
146152
public long now() {
147153
return System.currentTimeMillis();

0 commit comments

Comments
 (0)