Class StatementMaybe


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

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

        public static <K,​R> Maybe<R> switchCase​(Supplier<? extends K> caseSelector,
                                                      java.util.Map<? super K,​? extends MaybeSource<? extends R>> mapOfCases,
                                                      Scheduler scheduler)
        Return a particular one of several possible Maybes 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 MaybeObserver subscribes
        mapOfCases - a map that maps a case key to a Maybe
        scheduler - the scheduler where the empty maybe is observed
        Returns:
        a particular Maybe chosen by key from the map of Maybes, or an empty Maybe if no Maybe matches the key, but one that runs on the designated scheduler in either case
      • switchCase

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

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

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

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

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

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