Skip to content

Commit

Permalink
Switch Maybe and Single to use their Transformers in compose() (#4651)
Browse files Browse the repository at this point in the history
* Switch Maybe and Single to use their Transformers in compose()

Resolves #4650

* Update compose() tests
  • Loading branch information
ZacSweers authored and akarnokd committed Oct 1, 2016
1 parent 9047a3c commit 5ad1c04
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/main/java/io/reactivex/Maybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -1967,13 +1967,12 @@ public final <U> Maybe<U> cast(final Class<? extends U> clazz) {
* </dl>
*
* @param <R> the value type of the Maybe returned by the transformer function
* @param transformer
* implements the function that transforms the source Maybe
* @param transformer the transformer function, not null
* @return a Maybe, transformed by the transformer function
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators">RxJava wiki: Implementing Your Own Operators</a>
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Maybe<R> compose(Function<? super Maybe<T>, ? extends MaybeSource<R>> transformer) {
public final <R> Maybe<R> compose(MaybeTransformer<T, R> transformer) {
return wrap(to(transformer));
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/reactivex/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -1467,13 +1467,12 @@ public final Single<T> hide() {
* </dl>
*
* @param <R> the value type of the single returned by the transformer function
* @param transformer
* implements the function that transforms the source Single
* @param transformer the transformer function, not null
* @return the source Single, transformed by the transformer function
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators">RxJava wiki: Implementing Your Own Operators</a>
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Single<R> compose(Function<? super Single<T>, ? extends SingleSource<R>> transformer) {
public final <R> Single<R> compose(SingleTransformer<T, R> transformer) {
return wrap(to(transformer));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@

package io.reactivex.internal.operators.single;

import static org.junit.Assert.*;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

import org.junit.Test;

import io.reactivex.*;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.SingleSource;
import io.reactivex.SingleTransformer;
import io.reactivex.disposables.Disposables;
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.*;
import io.reactivex.schedulers.Schedulers;
import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;

public class SingleMiscTest {
@Test
Expand Down Expand Up @@ -78,7 +83,7 @@ public void contains() {
public void compose() {

Single.just(1)
.compose(new Function<Single<Integer>, SingleSource<Object>>() {
.compose(new SingleTransformer<Integer, Object>() {
@Override
public SingleSource<Object> apply(Single<Integer> f) throws Exception {
return f.map(new Function<Integer, Object>() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/reactivex/maybe/MaybeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void toNull() {

@Test
public void compose() {
Maybe.just(1).compose(new Function<Maybe<Integer>, MaybeSource<Integer>>() {
Maybe.just(1).compose(new MaybeTransformer<Integer, Integer>() {
@Override
public MaybeSource<Integer> apply(Maybe<Integer> m) throws Exception {
return m.map(new Function<Integer, Integer>() {
Expand Down

0 comments on commit 5ad1c04

Please sign in to comment.