hu.akarnokd.rxjava2.expr

## Class StatementObservable

- java.lang.Object
- - hu.akarnokd.rxjava2.expr.StatementObservable

    public final class StatementObservable
    extends java.lang.Object

Imperative statements expressed as Observable operators.

### Method Summary

All Methods Static Methods Concrete Methods
`static <T> io.reactivex.Observable<T>` `doWhile(io.reactivex.ObservableSource<? extends T> source, io.reactivex.functions.BooleanSupplier postCondition)` Return an Observable that re-emits the emissions from the source Observable, and then re-subscribes to the source long as a condition is true.
`static <R> io.reactivex.Observable<R>` `ifThen(io.reactivex.functions.BooleanSupplier condition, io.reactivex.ObservableSource<? extends R> then)` Return an Observable that emits the emissions from a specified Observable if a condition evaluates to true, otherwise return an empty Observable.
`static <R> io.reactivex.Observable<R>` `ifThen(io.reactivex.functions.BooleanSupplier condition, io.reactivex.ObservableSource<? extends R> then, io.reactivex.Observable<? extends R> orElse)` Return an Observable that emits the emissions from one specified Observable if a condition evaluates to true, or from another specified Observable otherwise.
`static <R> io.reactivex.Observable<R>` `ifThen(io.reactivex.functions.BooleanSupplier condition, io.reactivex.ObservableSource<? extends R> then, io.reactivex.Scheduler scheduler)` Return an Observable that emits the emissions from a specified Observable if a condition evaluates to true, otherwise return an empty Observable that runs on a specified Scheduler.
`static <K,R> io.reactivex.Observable<R>` `switchCase(java.util.concurrent.Callable<? extends K> caseSelector, java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases)` Return a particular one of several possible Observables based on a case selector.

`static <K,R> io.reactivex.Observable<R>`

`switchCase(java.util.concurrent.Callable<? extends K> caseSelector, java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases, io.reactivex.ObservableSource<? extends R> defaultCase)`
Return a particular one of several possible Observables based on a case selector, or a default Observable if the case selector does not map to a particular one.

`static <K,R> io.reactivex.Observable<R>` `switchCase(java.util.concurrent.Callable<? extends K> caseSelector, java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases, io.reactivex.Scheduler scheduler)` Return a particular one of several possible Observables based on a case selector and run it on the designated scheduler.
`static <T> io.reactivex.Observable<T>` `whileDo(io.reactivex.ObservableSource<? extends T> source, io.reactivex.functions.BooleanSupplier preCondition)` Return an Observable that re-emits the emissions from the source Observable as long as the condition is true before the first or subsequent subscribe() calls.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### switchCase

    public static <K,R> io.reactivex.Observable<R> switchCase(java.util.concurrent.Callable<? extends K> caseSelector,
                                                              java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases)

Return a particular one of several possible Observables based on a case selector.

Type Parameters:
  `K` - the case key type
  `R` - the result value type
Parameters:
  `caseSelector` - the function that produces a case key when an Observer subscribes
  `mapOfCases` - a map that maps a case key to an Observable
Returns:
  a particular Observable chosen by key from the map of Observables, or an empty Observable if no Observable matches the key

#### switchCase

    public static <K,R> io.reactivex.Observable<R> switchCase(java.util.concurrent.Callable<? extends K> caseSelector,
                                                              java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases,
                                                              io.reactivex.Scheduler scheduler)

Return a particular one of several possible Observables based on a case selector and run it on the designated scheduler.

Type Parameters:
  `K` - the case key type
  `R` - the result value type
Parameters:
  `caseSelector` - the function that produces a case key when an Observer subscribes
  `mapOfCases` - a map that maps a case key to an Observable
  `scheduler` - the scheduler where the empty observable is observed
Returns:
  a particular Observable chosen by key from the map of Observables, or an empty Observable if no Observable matches the key, but one that runs on the designated scheduler in either case

#### switchCase

    public static <K,R> io.reactivex.Observable<R> switchCase(java.util.concurrent.Callable<? extends K> caseSelector,
                                                              java.util.Map<? super K,? extends io.reactivex.ObservableSource<? extends R>> mapOfCases,
                                                              io.reactivex.ObservableSource<? extends R> defaultCase)

Return a particular one of several possible Observables based on a case selector, or a default Observable if the case selector does not map to a particular one.

Type Parameters:
  `K` - the case key type
  `R` - the result value type
Parameters:
  `caseSelector` - the function that produces a case key when an Observer subscribes
  `mapOfCases` - a map that maps a case key to an Observable
  `defaultCase` - the default Observable if the `mapOfCases` doesn't contain a value for the key returned by the `caseSelector`
Returns:
  a particular Observable chosen by key from the map of Observables, or the default case if no Observable matches the key

#### doWhile

    public static <T> io.reactivex.Observable<T> doWhile(io.reactivex.ObservableSource<? extends T> source,
                                                         io.reactivex.functions.BooleanSupplier postCondition)

Return an Observable that re-emits the emissions from the source Observable, and then re-subscribes to the source long as a condition is true.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Observable to work with
  `postCondition` - the post condition to test after the source Observable completes
Returns:
  an Observable that replays the emissions from the source Observable, and then continues to replay them so long as the post condition is true

#### whileDo

    public static <T> io.reactivex.Observable<T> whileDo(io.reactivex.ObservableSource<? extends T> source,
                                                         io.reactivex.functions.BooleanSupplier preCondition)

Return an Observable that re-emits the emissions from the source Observable as long as the condition is true before the first or subsequent subscribe() calls.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Observable to work with
  `preCondition` - the condition to evaluate before subscribing to or replaying the source Observable
Returns:
  an Observable that replays the emissions from the source Observable so long as `preCondition` is true

#### ifThen

    public static <R> io.reactivex.Observable<R> ifThen(io.reactivex.functions.BooleanSupplier condition,
                                                        io.reactivex.ObservableSource<? extends R> then)

Return an Observable that emits the emissions from a specified Observable if a condition evaluates to true, otherwise return an empty Observable.

Type Parameters:
  `R` - the result value type
Parameters:
  `condition` - the condition that decides whether to emit the emissions from the `then` Observable
  `then` - the Observable sequence to emit to if `condition` is `true`
Returns:
  an Observable that mimics the `then` Observable if the `condition` function evaluates to true, or an empty Observable otherwise

#### ifThen

    public static <R> io.reactivex.Observable<R> ifThen(io.reactivex.functions.BooleanSupplier condition,
                                                        io.reactivex.ObservableSource<? extends R> then,
                                                        io.reactivex.Scheduler scheduler)

Return an Observable that emits the emissions from a specified Observable if a condition evaluates to true, otherwise return an empty Observable that runs on a specified Scheduler.

Type Parameters:
  `R` - the result value type
Parameters:
  `condition` - the condition that decides whether to emit the emissions from the `then` Observable
  `then` - the Observable sequence to emit to if `condition` is `true`
  `scheduler` - the Scheduler on which the empty Observable runs if the in case the condition returns false
Returns:
  an Observable that mimics the `then` Observable if the `condition` function evaluates to true, or an empty Observable running on the specified Scheduler otherwise

#### ifThen

    public static <R> io.reactivex.Observable<R> ifThen(io.reactivex.functions.BooleanSupplier condition,
                                                        io.reactivex.ObservableSource<? extends R> then,
                                                        io.reactivex.Observable<? extends R> orElse)

Return an Observable that emits the emissions from one specified Observable if a condition evaluates to true, or from another specified Observable otherwise.

Type Parameters:
  `R` - the result value type
Parameters:
  `condition` - the condition that decides which Observable to emit the emissions from
  `then` - the Observable sequence to emit to if `condition` is `true`
  `orElse` - the Observable sequence to emit to if `condition` is `false`
Returns:
  an Observable that mimics either the `then` or `orElse` Observables depending on a condition function