diff --git a/src/main/java/io/reactivex/Flowable.java b/src/main/java/io/reactivex/Flowable.java index ce0a00d214..c966716a1d 100644 --- a/src/main/java/io/reactivex/Flowable.java +++ b/src/main/java/io/reactivex/Flowable.java @@ -12341,32 +12341,6 @@ public final Flowable take(long time, TimeUnit unit, Scheduler scheduler) { return takeUntil(timer(time, unit, scheduler)); } - /** - * Returns a Flowable that emits only the very first item emitted by the source Publisher that satisfies - * a specified condition. - *

- * - *

- *
Backpressure:
- *
The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s backpressure - * behavior.
- *
Scheduler:
- *
{@code takeFirst} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param predicate - * the condition any item emitted by the source Publisher has to satisfy - * @return a Flowable that emits only the very first item emitted by the source Publisher that satisfies - * the given condition, or that completes without emitting anything if the source Publisher - * completes without emitting a single condition-satisfying item - * @see ReactiveX operators documentation: First - */ - @BackpressureSupport(BackpressureKind.SPECIAL) // may trigger UNBOUNDED_IN - @SchedulerSupport(SchedulerSupport.NONE) - public final Flowable takeFirst(Predicate predicate) { - return filter(predicate).take(1); - } - /** * Returns a Flowable that emits at most the last {@code count} items emitted by the source Publisher. If the source emits fewer than * {@code count} items then all of its items are emitted. diff --git a/src/main/java/io/reactivex/Observable.java b/src/main/java/io/reactivex/Observable.java index a9cf4f2c97..e4460639bb 100644 --- a/src/main/java/io/reactivex/Observable.java +++ b/src/main/java/io/reactivex/Observable.java @@ -10333,28 +10333,6 @@ public final Observable take(long time, TimeUnit unit, Scheduler scheduler) { return takeUntil(timer(time, unit, scheduler)); } - /** - * Returns an Observable that emits only the very first item emitted by the source ObservableSource that satisfies - * a specified condition. - *

- * - *

- *
Scheduler:
- *
{@code takeFirst} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param predicate - * the condition any item emitted by the source ObservableSource has to satisfy - * @return an Observable that emits only the very first item emitted by the source ObservableSource that satisfies - * the given condition, or that completes without emitting anything if the source ObservableSource - * completes without emitting a single condition-satisfying item - * @see ReactiveX operators documentation: First - */ - @SchedulerSupport(SchedulerSupport.NONE) - public final Observable takeFirst(Predicate predicate) { - return filter(predicate).take(1); - } - /** * Returns an Observable that emits at most the last {@code count} items emitted by the source ObservableSource. If the source emits fewer than * {@code count} items then all of its items are emitted. diff --git a/src/test/java/io/reactivex/flowable/FlowableNullTests.java b/src/test/java/io/reactivex/flowable/FlowableNullTests.java index 6862a77995..af2f83f67c 100644 --- a/src/test/java/io/reactivex/flowable/FlowableNullTests.java +++ b/src/test/java/io/reactivex/flowable/FlowableNullTests.java @@ -2179,11 +2179,6 @@ public void takeTimedSchedulerNull() { just1.take(1, TimeUnit.SECONDS, null); } - @Test(expected = NullPointerException.class) - public void takeFirstNull() { - just1.takeFirst(null); - } - @Test(expected = NullPointerException.class) public void takeLastTimedUnitNull() { just1.takeLast(1, null, Schedulers.single()); @@ -2957,4 +2952,4 @@ public Object apply(Object[] v) { } }, 128, just1).blockingLast(); } -} \ No newline at end of file +} diff --git a/src/test/java/io/reactivex/flowable/FlowableTests.java b/src/test/java/io/reactivex/flowable/FlowableTests.java index 8cd75c8361..b3be555258 100644 --- a/src/test/java/io/reactivex/flowable/FlowableTests.java +++ b/src/test/java/io/reactivex/flowable/FlowableTests.java @@ -182,9 +182,10 @@ public Throwable call() { verify(wo, times(1)).onError(any(RuntimeException.class)); } + @Test public void testTakeFirstWithPredicateOfSome() { Flowable observable = Flowable.just(1, 3, 5, 4, 6, 3); - observable.takeFirst(IS_EVEN).subscribe(w); + observable.filter(IS_EVEN).take(1).subscribe(w); verify(w, times(1)).onNext(anyInt()); verify(w).onNext(4); verify(w, times(1)).onComplete(); @@ -194,7 +195,7 @@ public void testTakeFirstWithPredicateOfSome() { @Test public void testTakeFirstWithPredicateOfNoneMatchingThePredicate() { Flowable observable = Flowable.just(1, 3, 5, 7, 9, 7, 5, 3, 1); - observable.takeFirst(IS_EVEN).subscribe(w); + observable.filter(IS_EVEN).take(1).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, times(1)).onComplete(); verify(w, never()).onError(any(Throwable.class)); diff --git a/src/test/java/io/reactivex/observable/ObservableNullTests.java b/src/test/java/io/reactivex/observable/ObservableNullTests.java index 8696966160..2f43c85452 100644 --- a/src/test/java/io/reactivex/observable/ObservableNullTests.java +++ b/src/test/java/io/reactivex/observable/ObservableNullTests.java @@ -2250,11 +2250,6 @@ public void takeTimedSchedulerNull() { just1.take(1, TimeUnit.SECONDS, null); } - @Test(expected = NullPointerException.class) - public void takeFirstNull() { - just1.takeFirst(null); - } - @Test(expected = NullPointerException.class) public void takeLastTimedUnitNull() { just1.takeLast(1, null, Schedulers.single()); diff --git a/src/test/java/io/reactivex/observable/ObservableTest.java b/src/test/java/io/reactivex/observable/ObservableTest.java index a2ef298287..8c905ee912 100644 --- a/src/test/java/io/reactivex/observable/ObservableTest.java +++ b/src/test/java/io/reactivex/observable/ObservableTest.java @@ -186,7 +186,7 @@ public Throwable call() { @Test public void testTakeFirstWithPredicateOfSome() { Observable o = Observable.just(1, 3, 5, 4, 6, 3); - o.takeFirst(IS_EVEN).subscribe(w); + o.filter(IS_EVEN).take(1).subscribe(w); verify(w, times(1)).onNext(anyInt()); verify(w).onNext(4); verify(w, times(1)).onComplete(); @@ -196,7 +196,7 @@ public void testTakeFirstWithPredicateOfSome() { @Test public void testTakeFirstWithPredicateOfNoneMatchingThePredicate() { Observable o = Observable.just(1, 3, 5, 7, 9, 7, 5, 3, 1); - o.takeFirst(IS_EVEN).subscribe(w); + o.filter(IS_EVEN).take(1).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, times(1)).onComplete(); verify(w, never()).onError(any(Throwable.class));