Class ReactorResult

java.lang.Object
dmx.fun.reactor.ReactorResult

@NullMarked public final class ReactorResult extends Object
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)):

  • Method Summary

    Modifier and Type
    Method
    Description
    static <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 is Ok, the mapper's Mono<Result<W, E>> is sequenced; when it is Err, the error is passed through without invoking the mapper.
    static <V,E,F> reactor.core.publisher.Mono<Result<V,F>>
    mapErr(reactor.core.publisher.Mono<Result<V,E>> mono, Function<? super E, ? extends F> mapper)
    Maps the error channel of a Mono<Result<V, E>>, leaving Ok untouched.
    static <V,W,E> reactor.core.publisher.Mono<Result<W,E>>
    mapOk(reactor.core.publisher.Mono<Result<V,E>> mono, Function<? super V, ? extends W> mapper)
    Maps the success value of a Mono<Result<V, E>>, leaving Err untouched.
    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 from Err by mapping the error to a fallback value, producing an Ok; an Ok is passed through unchanged.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • mapOk

      public static <V,W,E> reactor.core.publisher.Mono<Result<W,E>> mapOk(reactor.core.publisher.Mono<Result<V,E>> mono, Function<? super V, ? extends W> mapper)
      Maps the success value of a Mono<Result<V, E>>, leaving Err untouched.
      Type Parameters:
      V - the input value type
      W - the output value type
      E - the error type
      Parameters:
      mono - the source
      mapper - maps the Ok value
      Returns:
      a Mono of the transformed Result
    • flatMapOk

      public static <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 is Ok, the mapper's Mono<Result<W, E>> is sequenced; when it is Err, the error is passed through without invoking the mapper.
      Type Parameters:
      V - the input value type
      W - the output value type
      E - the error type
      Parameters:
      mono - the source
      mapper - maps the Ok value to the next reactive step
      Returns:
      a Mono of the chained Result
    • mapErr

      public static <V,E,F> reactor.core.publisher.Mono<Result<V,F>> mapErr(reactor.core.publisher.Mono<Result<V,E>> mono, Function<? super E, ? extends F> mapper)
      Maps the error channel of a Mono<Result<V, E>>, leaving Ok untouched.
      Type Parameters:
      V - the value type
      E - the input error type
      F - the output error type
      Parameters:
      mono - the source
      mapper - maps the Err value
      Returns:
      a Mono of the Result with 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 from Err by mapping the error to a fallback value, producing an Ok; an Ok is passed through unchanged.
      Type Parameters:
      V - the value type
      E - the error type
      Parameters:
      mono - the source
      fallback - maps the Err value to a recovery value
      Returns:
      a Mono of the recovered Result