RxComprehensions { public static <A, R> Observable<R> doSwitchMap( final Callable<Observable<A>> zero, final Function<A, Observable<R>> one) { try { return zero.call() .switchMap(new Function<A, Observable<R>>() { @Override public Observable<R> apply(final A a) throws Exception { return one.apply(a); } }); } catch (Exception e) { throw new RuntimeException(e); } } private  RxComprehensions(); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<R>> one); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<R>> two); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<R>> three); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<R>> four); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<R>> five); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<R>> six); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<R>> seven); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<R>> eight); static Observable<R> doFlatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<I>> eight,
            final Function9<A, B, C, D, E, F, G, H, I, Observable<R>> nine); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<R>> one); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<R>> two); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<R>> three); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<R>> four); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<R>> five); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<R>> six); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<R>> seven); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<R>> eight); static Observable<R> doConcatMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<I>> eight,
            final Function9<A, B, C, D, E, F, G, H, I, Observable<R>> nine); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<R>> one); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<R>> two); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<R>> three); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<R>> four); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<R>> five); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<R>> six); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<R>> seven); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<R>> eight); static Observable<R> doSwitchMap(
            final Callable<Observable<A>> zero,
            final Function<A, Observable<B>> one,
            final BiFunction<A, B, Observable<C>> two,
            final Function3<A, B, C, Observable<D>> three,
            final Function4<A, B, C, D, Observable<E>> four,
            final Function5<A, B, C, D, E, Observable<F>> five,
            final Function6<A, B, C, D, E, F, Observable<G>> six,
            final Function7<A, B, C, D, E, F, G, Observable<H>> seven,
            final Function8<A, B, C, D, E, F, G, H, Observable<I>> eight,
            final Function9<A, B, C, D, E, F, G, H, I, Observable<R>> nine); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, R> one); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, R> two); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, R> three); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, R> four); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, E> four,
            final ObservableTransformer<E, R> five); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, E> four,
            final ObservableTransformer<E, F> five,
            final ObservableTransformer<F, R> six); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, E> four,
            final ObservableTransformer<E, F> five,
            final ObservableTransformer<F, G> six,
            final ObservableTransformer<G, R> seven); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, E> four,
            final ObservableTransformer<E, F> five,
            final ObservableTransformer<F, G> six,
            final ObservableTransformer<G, H> seven,
            final ObservableTransformer<H, R> eight); static Observable<R> doCompose(
            final Callable<Observable<A>> zero,
            final ObservableTransformer<A, B> one,
            final ObservableTransformer<B, C> two,
            final ObservableTransformer<C, D> three,
            final ObservableTransformer<D, E> four,
            final ObservableTransformer<E, F> five,
            final ObservableTransformer<F, G> six,
            final ObservableTransformer<G, H> seven,
            final ObservableTransformer<H, I> eight,
            final ObservableTransformer<I, R> nine);  }
@Test public void oneSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(1), one(true)).blockingFirst(), true); }
@Test public void twoSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(2), one(true), two("result")).blockingFirst(), "result"); }
@Test public void threeSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(3), one(true), two("result"), three("other")).blockingFirst(), "other"); }
@Test public void fourSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(4), one(true), two("result"), three("other"), four("other".length())).blockingFirst(), new Long("other".length())); }
@Test public void fiveSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(1), one(true), two("result"), three("other"), four("other".length()), five("other".length() < 5)).blockingFirst(), false); }
@Test public void sixSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(1), one(true), two("result"), three("other"), four("other".length()), five("other".length() < 5), six(Boolean.toString(false))).blockingFirst(), "false"); }
@Test public void sevenSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(1), one(true), two("result"), three("other"), four("other".length()), five("other".length() < 5), six(Boolean.toString(false)), seven("true")).blockingFirst(), false); }
@Test public void eightSM() { Assert.assertEquals(RxComprehensions.doSwitchMap(zero(1), one(true), two("result"), three("other"), four("other".length()), five("other".length() < 5), six(Boolean.toString(false)), seven("true"), eight(Long.class)).blockingFirst(), Long.class); }
@Test public void nineSM() { final TestObserver<Object> observer = TestObserver.create(); RxComprehensions.doSwitchMap(zero(1), one(true), two("result"), three("other"), four("other".length()), five("other".length() < 5), six(Boolean.toString(false)), seven("true"), eight(Long.class), this.<Long>nine()).subscribe(observer); observer.awaitTerminalEvent(); observer.assertComplete(); observer.assertNoErrors(); observer.assertResult(1, true, "result", "other", (long) "other".length(), "other".length() < 5, Boolean.toString(false), false, Long.class); }