All Known Implementing Classes:
Outcome.Failure, Outcome.Success, Outcome.TimedOut

public sealed interface Outcome<T> permits Outcome.Success<T>, Outcome.Failure<T>, Outcome.TimedOut<T>
Result of executing an operation with a pattern. Never throws — returns one of the sealed subtypes to allow exhaustive pattern matching.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Operation failed with an exception.
    static final record 
    Operation succeeded and returned a value.
    static final record 
    Operation did not complete within the configured timeout.
  • Method Summary

    Modifier and Type
    Method
    Description
    default <U> U
    fold(Function<T,U> onSuccess, Function<Throwable,U> onFailure)
    Fold over the outcome: apply one function if Success, another if Failure.
  • Method Details

    • fold

      default <U> U fold(Function<T,U> onSuccess, Function<Throwable,U> onFailure)
      Fold over the outcome: apply one function if Success, another if Failure. A TimedOut outcome folds as a failure, passing a ResilientTimeoutException carrying the exceeded timeout to onFailure.