Package hu.akarnokd.rxjava3.expr
Class StatementSingle
- java.lang.Object
-
- hu.akarnokd.rxjava3.expr.StatementSingle
-
public final class StatementSingle extends java.lang.ObjectImperative 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.
-
-
-
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 typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an SingleObserver subscribesmapOfCases- a map that maps a case key to a SingledefaultCase- the default Single if themapOfCasesdoesn't contain a value for the key returned by thecaseSelector- 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 fromthen- the Single sequence to emit to ifconditionistrueorElse- the Single sequence to emit to ifconditionisfalse- Returns:
- a Single that mimics either the
thenororElseSingles depending on a condition function
-
-