public final class StatementMaybe extends Object
Modifier and Type | Method and 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,
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,
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,
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.
|
public static <K,R> Maybe<R> switchCase(Supplier<? extends K> caseSelector, Map<? super K,? extends MaybeSource<? extends R>> mapOfCases)
K
- the case key typeR
- the result value typecaseSelector
- the function that produces a case key when an
MaybeObserver subscribesmapOfCases
- a map that maps a case key to a Maybepublic static <K,R> Maybe<R> switchCase(Supplier<? extends K> caseSelector, Map<? super K,? extends MaybeSource<? extends R>> mapOfCases, Scheduler scheduler)
K
- the case key typeR
- the result value typecaseSelector
- 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 observedpublic static <K,R> Maybe<R> switchCase(Supplier<? extends K> caseSelector, Map<? super K,? extends MaybeSource<? extends R>> mapOfCases, MaybeSource<? extends R> defaultCase)
K
- the case key typeR
- the result value typecaseSelector
- 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 the mapOfCases
doesn't contain a value for the key returned by the caseSelector
public static <R> Maybe<R> ifThen(BooleanSupplier condition, MaybeSource<? extends R> then)
R
- the result value typecondition
- the condition that decides whether to emit the emissions
from the then
Maybethen
- the Maybe sequence to emit to if condition
is true
then
Maybe if the condition
function evaluates to true, or an empty
Maybe otherwisepublic static <R> Maybe<R> ifThen(BooleanSupplier condition, MaybeSource<? extends R> then, Scheduler scheduler)
R
- the result value typecondition
- the condition that decides whether to emit the emissions
from the then
Maybethen
- 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 falsethen
Maybe if the condition
function evaluates to true, or an empty
Maybe running on the specified Scheduler otherwisepublic static <R> Maybe<R> ifThen(BooleanSupplier condition, MaybeSource<? extends R> then, Maybe<? extends R> orElse)
R
- the result value typecondition
- the condition that decides which Maybe to emit the
emissions fromthen
- the Maybe sequence to emit to if condition
is true
orElse
- the Maybe sequence to emit to if condition
is false
then
or orElse
Maybes depending on a condition function