Skip to content

Commit 2d5ce69

Browse files
committed
takeLast javadoc fixes, standardize on parameter names (count instead of num), improve message in OperatorTakeLast exception
1 parent 3cc254c commit 2d5ce69

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

src/main/java/rx/Observable.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,28 +5141,28 @@ public final Observable<T> lastOrDefault(T defaultValue, Func1<? super T, Boolea
51415141
}
51425142

51435143
/**
5144-
* Returns an Observable that emits only the first {@code num} items emitted by the source Observable.
5144+
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable.
51455145
* <p>
51465146
* Alias of {@link #take(int)} to match Java 8 Stream API naming convention.
51475147
* <p>
51485148
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/take.png" alt="">
51495149
* <p>
51505150
* This method returns an Observable that will invoke a subscribing {@link Observer}'s
5151-
* {@link Observer#onNext onNext} function a maximum of {@code num} times before invoking
5151+
* {@link Observer#onNext onNext} function a maximum of {@code count} times before invoking
51525152
* {@link Observer#onCompleted onCompleted}.
51535153
* <dl>
51545154
* <dt><b>Scheduler:</b></dt>
51555155
* <dd>{@code limit} does not operate by default on a particular {@link Scheduler}.</dd>
51565156
* </dl>
51575157
*
5158-
* @param num
5158+
* @param count
51595159
* the maximum number of items to emit
5160-
* @return an Observable that emits only the first {@code num} items emitted by the source Observable, or
5161-
* all of the items from the source Observable if that Observable emits fewer than {@code num} items
5160+
* @return an Observable that emits only the first {@code count} items emitted by the source Observable, or
5161+
* all of the items from the source Observable if that Observable emits fewer than {@code count} items
51625162
* @see <a href="http://reactivex.io/documentation/operators/take.html">ReactiveX operators documentation: Take</a>
51635163
*/
5164-
public final Observable<T> limit(int num) {
5165-
return take(num);
5164+
public final Observable<T> limit(int count) {
5165+
return take(count);
51665166
}
51675167

51685168
/**
@@ -6894,7 +6894,7 @@ public final Observable<T> singleOrDefault(T defaultValue, Func1<? super T, Bool
68946894
}
68956895

68966896
/**
6897-
* Returns an Observable that skips the first {@code num} items emitted by the source Observable and emits
6897+
* Returns an Observable that skips the first {@code count} items emitted by the source Observable and emits
68986898
* the remainder.
68996899
* <p>
69006900
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/skip.png" alt="">
@@ -6903,14 +6903,14 @@ public final Observable<T> singleOrDefault(T defaultValue, Func1<? super T, Bool
69036903
* <dd>This version of {@code skip} does not operate by default on a particular {@link Scheduler}.</dd>
69046904
* </dl>
69056905
*
6906-
* @param num
6906+
* @param count
69076907
* the number of items to skip
69086908
* @return an Observable that is identical to the source Observable except that it does not emit the first
6909-
* {@code num} items that the source Observable emits
6909+
* {@code count} items that the source Observable emits
69106910
* @see <a href="http://reactivex.io/documentation/operators/skip.html">ReactiveX operators documentation: Skip</a>
69116911
*/
6912-
public final Observable<T> skip(int num) {
6913-
return lift(new OperatorSkip<T>(num));
6912+
public final Observable<T> skip(int count) {
6913+
return lift(new OperatorSkip<T>(count));
69146914
}
69156915

69166916
/**
@@ -7766,26 +7766,27 @@ public final <R> Observable<R> switchMap(Func1<? super T, ? extends Observable<?
77667766
}
77677767

77687768
/**
7769-
* Returns an Observable that emits only the first {@code num} items emitted by the source Observable.
7769+
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable. If the source emits fewer than
7770+
* {@code count} items then all of its items are emitted.
77707771
* <p>
77717772
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/take.png" alt="">
77727773
* <p>
77737774
* This method returns an Observable that will invoke a subscribing {@link Observer}'s
7774-
* {@link Observer#onNext onNext} function a maximum of {@code num} times before invoking
7775+
* {@link Observer#onNext onNext} function a maximum of {@code count} times before invoking
77757776
* {@link Observer#onCompleted onCompleted}.
77767777
* <dl>
77777778
* <dt><b>Scheduler:</b></dt>
77787779
* <dd>This version of {@code take} does not operate by default on a particular {@link Scheduler}.</dd>
77797780
* </dl>
77807781
*
7781-
* @param num
7782+
* @param count
77827783
* the maximum number of items to emit
7783-
* @return an Observable that emits only the first {@code num} items emitted by the source Observable, or
7784-
* all of the items from the source Observable if that Observable emits fewer than {@code num} items
7784+
* @return an Observable that emits only the first {@code count} items emitted by the source Observable, or
7785+
* all of the items from the source Observable if that Observable emits fewer than {@code count} items
77857786
* @see <a href="http://reactivex.io/documentation/operators/take.html">ReactiveX operators documentation: Take</a>
77867787
*/
7787-
public final Observable<T> take(final int num) {
7788-
return lift(new OperatorTake<T>(num));
7788+
public final Observable<T> take(final int count) {
7789+
return lift(new OperatorTake<T>(count));
77897790
}
77907791

77917792
/**
@@ -7855,7 +7856,8 @@ public final Observable<T> takeFirst(Func1<? super T, Boolean> predicate) {
78557856
}
78567857

78577858
/**
7858-
* Returns an Observable that emits only the last {@code count} items emitted by the source Observable.
7859+
* Returns an Observable that emits at most the last {@code count} items emitted by the source Observable. If the source emits fewer than
7860+
* {@code count} items then all of its items are emitted.
78597861
* <p>
78607862
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLast.n.png" alt="">
78617863
* <dl>
@@ -7864,9 +7866,9 @@ public final Observable<T> takeFirst(Func1<? super T, Boolean> predicate) {
78647866
* </dl>
78657867
*
78667868
* @param count
7867-
* the number of items to emit from the end of the sequence of items emitted by the source
7869+
* the maximum number of items to emit from the end of the sequence of items emitted by the source
78687870
* Observable
7869-
* @return an Observable that emits only the last {@code count} items emitted by the source Observable
7871+
* @return an Observable that emits at most the last {@code count} items emitted by the source Observable
78707872
* @throws IndexOutOfBoundsException
78717873
* if {@code count} is less than zero
78727874
* @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX operators documentation: TakeLast</a>
@@ -7882,7 +7884,7 @@ else if (count == 1 )
78827884

78837885
/**
78847886
* Returns an Observable that emits at most a specified number of items from the source Observable that were
7885-
* emitted in a specified window of time before the Observable completed.
7887+
* emitted in a specified window of time before the Observable completed.
78867888
* <p>
78877889
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLast.tn.png" alt="">
78887890
* <dl>
@@ -7983,8 +7985,8 @@ public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
79837985
}
79847986

79857987
/**
7986-
* Returns an Observable that emits a single List containing the last {@code count} elements emitted by the
7987-
* source Observable.
7988+
* Returns an Observable that emits a single List containing at most the last {@code count} elements emitted by the
7989+
* source Observable. If the source emits fewer than {@code count} items then the emitted List will contain all of the source emissions.
79887990
* <p>
79897991
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLastBuffer.png" alt="">
79907992
* <dl>
@@ -7993,8 +7995,8 @@ public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
79937995
* </dl>
79947996
*
79957997
* @param count
7996-
* the number of items to emit in the list
7997-
* @return an Observable that emits a single list containing the last {@code count} elements emitted by the
7998+
* the maximum number of items to emit in the list
7999+
* @return an Observable that emits a single list containing at most the last {@code count} elements emitted by the
79988000
* source Observable
79998001
* @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX operators documentation: TakeLast</a>
80008002
*/

src/main/java/rx/internal/operators/OperatorTakeLast.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import rx.Subscriber;
2323

2424
/**
25-
* Returns an Observable that emits the last <code>count</code> items emitted by the source Observable.
25+
* Returns an Observable that emits the at most the last <code>count</code> items emitted by the source Observable.
2626
* <p>
2727
* <img width="640" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/last.png" alt="">
2828
*/
@@ -32,7 +32,7 @@ public final class OperatorTakeLast<T> implements Operator<T, T> {
3232

3333
public OperatorTakeLast(int count) {
3434
if (count < 0) {
35-
throw new IndexOutOfBoundsException("count could not be negative");
35+
throw new IndexOutOfBoundsException("count cannot be negative");
3636
}
3737
this.count = count;
3838
}

0 commit comments

Comments
 (0)