Class ReactorResult
java.lang.Object
dmx.fun.reactor.ReactorResult
Railway-style operators over a
Mono<Result<V, E>>, so a reactive pipeline
can stay on the Result track without unwrapping at every step.
Each operator threads through the Ok path and passes Err along
untouched (or transforms only the error channel, for mapErr(Mono, Function) and
recover(Mono, Function)):
mapOk(Mono, Function)— transform the success value;flatMapOk(Mono, Function)— chain a dependent reactive step on the success value;mapErr(Mono, Function)— transform the error channel;recover(Mono, Function)— turn anErrback into anOkvia a fallback.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V,W, E> reactor.core.publisher.Mono <Result<W, E>> flatMapOk(reactor.core.publisher.Mono<Result<V, E>> mono, Function<? super V, reactor.core.publisher.Mono<Result<W, E>>> mapper) Chains a dependent reactive step on the success value: when the result isOk, the mapper'sMono<Result<W, E>>is sequenced; when it isErr, the error is passed through without invoking the mapper.static <V,E, F> reactor.core.publisher.Mono <Result<V, F>> Maps the error channel of aMono<Result<V, E>>, leavingOkuntouched.static <V,W, E> reactor.core.publisher.Mono <Result<W, E>> Maps the success value of aMono<Result<V, E>>, leavingErruntouched.static <V,E> reactor.core.publisher.Mono <Result<V, E>> Recovers fromErrby mapping the error to a fallback value, producing anOk; anOkis passed through unchanged.
-
Method Details
-
mapOk
public static <V,W, reactor.core.publisher.Mono<Result<W,E> E>> mapOk(reactor.core.publisher.Mono<Result<V, E>> mono, Function<? super V, ? extends W> mapper) Maps the success value of aMono<Result<V, E>>, leavingErruntouched.- Type Parameters:
V- the input value typeW- the output value typeE- the error type- Parameters:
mono- the sourcemapper- maps theOkvalue- Returns:
- a
Monoof the transformedResult
-
flatMapOk
public static <V,W, reactor.core.publisher.Mono<Result<W,E> E>> flatMapOk(reactor.core.publisher.Mono<Result<V, E>> mono, Function<? super V, reactor.core.publisher.Mono<Result<W, E>>> mapper) Chains a dependent reactive step on the success value: when the result isOk, the mapper'sMono<Result<W, E>>is sequenced; when it isErr, the error is passed through without invoking the mapper.- Type Parameters:
V- the input value typeW- the output value typeE- the error type- Parameters:
mono- the sourcemapper- maps theOkvalue to the next reactive step- Returns:
- a
Monoof the chainedResult
-
mapErr
public static <V,E, reactor.core.publisher.Mono<Result<V,F> F>> mapErr(reactor.core.publisher.Mono<Result<V, E>> mono, Function<? super E, ? extends F> mapper) Maps the error channel of aMono<Result<V, E>>, leavingOkuntouched.- Type Parameters:
V- the value typeE- the input error typeF- the output error type- Parameters:
mono- the sourcemapper- maps theErrvalue- Returns:
- a
Monoof theResultwith the mapped error channel
-
recover
public static <V,E> reactor.core.publisher.Mono<Result<V,E>> recover(reactor.core.publisher.Mono<Result<V, E>> mono, Function<? super E, ? extends V> fallback) Recovers fromErrby mapping the error to a fallback value, producing anOk; anOkis passed through unchanged.- Type Parameters:
V- the value typeE- the error type- Parameters:
mono- the sourcefallback- maps theErrvalue to a recovery value- Returns:
- a
Monoof the recoveredResult
-