Class StatementSingle


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <R> Single<R> ifThen​(BooleanSupplier condition, SingleSource<? extends R> then, Single<? extends R> orElse)
      Return a Single that emits the emissions from one specified Single if a condition evaluates to true, or from another specified Single otherwise.
      static <K,​R>
      Single<R>
      switchCase​(Supplier<? extends K> caseSelector, java.util.Map<? super K,​? extends SingleSource<? extends R>> mapOfCases, SingleSource<? extends R> defaultCase)
      Return a particular one of several possible Singles based on a case selector, or a default Single if the case selector does not map to a particular one.
      • 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> Single<R> switchCase​(Supplier<? extends K> caseSelector,
                                                       java.util.Map<? super K,​? extends SingleSource<? extends R>> mapOfCases,
                                                       SingleSource<? extends R> defaultCase)
        Return a particular one of several possible Singles based on a case selector, or a default Single 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 SingleObserver subscribes
        mapOfCases - a map that maps a case key to a Single
        defaultCase - the default Single if the mapOfCases doesn't contain a value for the key returned by the caseSelector
        Returns:
        a particular Single chosen by key from the map of Singles, or the default case if no Single matches the key
      • ifThen

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

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