Package hu.akarnokd.rxjava3.expr
Class StatementMaybe
- java.lang.Object
-
- hu.akarnokd.rxjava3.expr.StatementMaybe
-
public final class StatementMaybe extends java.lang.ObjectImperative 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.
-
-
-
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 typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an MaybeObserver subscribesmapOfCases- 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 typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an MaybeObserver subscribesmapOfCases- a map that maps a case key to a Maybescheduler- 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 typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an MaybeObserver subscribesmapOfCases- a map that maps a case key to a MaybedefaultCase- the default Maybe if themapOfCasesdoesn't contain a value for the key returned by thecaseSelector- 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 thethenMaybethen- the Maybe sequence to emit to ifconditionistrue- Returns:
- a Maybe that mimics the
thenMaybe if theconditionfunction 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 thethenMaybethen- the Maybe sequence to emit to ifconditionistruescheduler- the Scheduler on which the empty Maybe runs if the in case the condition returns false- Returns:
- a Maybe that mimics the
thenMaybe if theconditionfunction 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 fromthen- the Maybe sequence to emit to ifconditionistrueorElse- the Maybe sequence to emit to ifconditionisfalse- Returns:
- a Maybe that mimics either the
thenororElseMaybes depending on a condition function
-
-