Interface ExecutionFlow<T>

Type Parameters:
T - The flow type
All Known Subinterfaces:
CompletableFutureExecutionFlow<T>, DelayedExecutionFlow<T>, ImperativeExecutionFlow<T>, ReactiveExecutionFlow<T>

@Internal public interface ExecutionFlow<T>
The execution flow class represents a data flow which state can be represented as a simple imperative flow or an async/reactive. The state can be resolved or lazy - based on the implementation. NOTE: The instance of the flow is not supposed to be used after a mapping operator is used.
Since:
4.0.0
Author:
Denis Stepanov
  • Method Details

    • just

      @NonNull static <K> ExecutionFlow<K> just(@Nullable K value)
      Create a simple flow representing a value.
      Type Parameters:
      K - The value type
      Parameters:
      value - The value
      Returns:
      a new flow
    • error

      @NonNull static <K> ExecutionFlow<K> error(@NonNull Throwable e)
      Create a simple flow representing an error.
      Type Parameters:
      K - The value type
      Parameters:
      e - The exception
      Returns:
      a new flow
    • empty

      @NonNull static <T> ExecutionFlow<T> empty()
      Create a simple flow representing an empty state.
      Type Parameters:
      T - The flow value type
      Returns:
      a new flow
    • async

      @NonNull static <T> ExecutionFlow<T> async(@NonNull Executor executor, @NonNull Supplier<? extends ExecutionFlow<T>> supplier)
      Create a flow by invoking a supplier asynchronously.
      Type Parameters:
      T - The flow value type
      Parameters:
      executor - The executor
      supplier - The supplier
      Returns:
      a new flow
    • map

      @NonNull <R> ExecutionFlow<R> map(@NonNull Function<? super T,? extends R> transformer)
      Map a not-empty value.
      Type Parameters:
      R - New value Type
      Parameters:
      transformer - The value transformer
      Returns:
      a new flow
    • flatMap

      @NonNull <R> ExecutionFlow<R> flatMap(@NonNull Function<? super T,? extends ExecutionFlow<? extends R>> transformer)
      Map a not-empty value to a new flow.
      Type Parameters:
      R - New value Type
      Parameters:
      transformer - The value transformer
      Returns:
      a new flow
    • then

      @NonNull <R> ExecutionFlow<R> then(@NonNull Supplier<? extends ExecutionFlow<? extends R>> supplier)
      Supply a new flow after the existing flow value is resolved.
      Type Parameters:
      R - New value Type
      Parameters:
      supplier - The supplier
      Returns:
      a new flow
    • onErrorResume

      @NonNull ExecutionFlow<T> onErrorResume(@NonNull Function<? super Throwable,? extends ExecutionFlow<? extends T>> fallback)
      Supply a new flow if the existing flow is erroneous.
      Parameters:
      fallback - The fallback
      Returns:
      a new flow
    • putInContext

      @NonNull ExecutionFlow<T> putInContext(@NonNull String key, @NonNull Object value)
      Store a contextual value.
      Parameters:
      key - The key
      value - The value
      Returns:
      a new flow
    • onComplete

      void onComplete(@NonNull BiConsumer<? super T,Throwable> fn)
      Invokes a provided function when the flow is resolved, or immediately if it is already done.
      Parameters:
      fn - The function
    • tryComplete

      Create an ImperativeExecutionFlow from this execution flow, if possible. The flow will have its result immediately available.
      Returns:
      The imperative flow, or null if this flow is not complete or does not support this operation
    • toCompletableFuture

      @NonNull default CompletableFuture<T> toCompletableFuture()
      Converts the existing flow into the completable future.
      Returns:
      a CompletableFuture that represents the state if this flow.