Class StatementFlowable


  • public final class StatementFlowable
    extends java.lang.Object
    Imperative statements expressed as Flowable operators.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Flowable<T> doWhile​(Publisher<? extends T> source, BooleanSupplier postCondition)
      Return an Flowable that re-emits the emissions from the source Flowable, and then re-subscribes to the source long as a condition is true.
      static <R> Flowable<R> ifThen​(BooleanSupplier condition, Publisher<? extends R> then)
      Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable.
      static <R> Flowable<R> ifThen​(BooleanSupplier condition, Publisher<? extends R> then, Flowable<? extends R> orElse)
      Return an Flowable that emits the emissions from one specified Flowable if a condition evaluates to true, or from another specified Flowable otherwise.
      static <R> Flowable<R> ifThen​(BooleanSupplier condition, Publisher<? extends R> then, Scheduler scheduler)
      Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable that runs on a specified Scheduler.
      static <K,​R>
      Flowable<R>
      switchCase​(Supplier<? extends K> caseSelector, java.util.Map<? super K,​? extends Publisher<? extends R>> mapOfCases)
      Return a particular one of several possible Observables based on a case selector.
      static <K,​R>
      Flowable<R>
      switchCase​(Supplier<? extends K> caseSelector, java.util.Map<? super K,​? extends Publisher<? extends R>> mapOfCases, Scheduler scheduler)
      Return a particular one of several possible Observables based on a case selector and run it on the designated scheduler.
      static <K,​R>
      Flowable<R>
      switchCase​(Supplier<? extends K> caseSelector, java.util.Map<? super K,​? extends Publisher<? extends R>> mapOfCases, Publisher<? extends R> defaultCase)
      Return a particular one of several possible Observables based on a case selector, or a default Flowable if the case selector does not map to a particular one.
      static <T> Flowable<T> whileDo​(Publisher<? extends T> source, BooleanSupplier preCondition)
      Return an Flowable that re-emits the emissions from the source Flowable 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> Flowable<R> switchCase​(Supplier<? extends K> caseSelector,
                                                         java.util.Map<? super K,​? extends Publisher<? 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 Flowable
        Returns:
        a particular Flowable chosen by key from the map of Observables, or an empty Flowable if no Flowable matches the key
      • switchCase

        public static <K,​R> Flowable<R> switchCase​(Supplier<? extends K> caseSelector,
                                                         java.util.Map<? super K,​? extends Publisher<? extends R>> mapOfCases,
                                                         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 Flowable
        scheduler - the scheduler where the empty observable is observed
        Returns:
        a particular Flowable chosen by key from the map of Observables, or an empty Flowable if no Flowable matches the key, but one that runs on the designated scheduler in either case
      • switchCase

        public static <K,​R> Flowable<R> switchCase​(Supplier<? extends K> caseSelector,
                                                         java.util.Map<? super K,​? extends Publisher<? extends R>> mapOfCases,
                                                         Publisher<? extends R> defaultCase)
        Return a particular one of several possible Observables based on a case selector, or a default Flowable 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 Flowable
        defaultCase - the default Flowable if the mapOfCases doesn't contain a value for the key returned by the caseSelector
        Returns:
        a particular Flowable chosen by key from the map of Observables, or the default case if no Flowable matches the key
      • doWhile

        public static <T> Flowable<T> doWhile​(Publisher<? extends T> source,
                                              BooleanSupplier postCondition)
        Return an Flowable that re-emits the emissions from the source Flowable, and then re-subscribes to the source long as a condition is true.

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

        public static <T> Flowable<T> whileDo​(Publisher<? extends T> source,
                                              BooleanSupplier preCondition)
        Return an Flowable that re-emits the emissions from the source Flowable as long as the condition is true before the first or subsequent subscribe() calls.

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

        public static <R> Flowable<R> ifThen​(BooleanSupplier condition,
                                             Publisher<? extends R> then)
        Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable.

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

        public static <R> Flowable<R> ifThen​(BooleanSupplier condition,
                                             Publisher<? extends R> then,
                                             Scheduler scheduler)
        Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable 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 Flowable
        then - the Flowable sequence to emit to if condition is true
        scheduler - the Scheduler on which the empty Flowable runs if the in case the condition returns false
        Returns:
        an Flowable that mimics the then Flowable if the condition function evaluates to true, or an empty Flowable running on the specified Scheduler otherwise
      • ifThen

        public static <R> Flowable<R> ifThen​(BooleanSupplier condition,
                                             Publisher<? extends R> then,
                                             Flowable<? extends R> orElse)
        Return an Flowable that emits the emissions from one specified Flowable if a condition evaluates to true, or from another specified Flowable otherwise.

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