Interface ApplyFunction<T,R>

Type Parameters:
T - the type of the input to the function
R - the type of the result of the function
All Superinterfaces:
Async<R>
All Known Subinterfaces:
AsyncApplyFunction<T,R>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ApplyFunction<T,R> extends Async<R>
Represents a function that accepts a value of type T and produces a result of type R. This interface extends Async and provides methods to apply the function asynchronously using CompletableFuture.

ApplyFunction is used to implement the following semantics:

 
    T res = doAsync(input);
    // Can use ApplyFunction
    R result = thenApply(res);
 
 
  • Method Details

    • apply

      R apply(T t) throws IOException
      Applies this function to the given argument.
      Parameters:
      t - the function argument
      Returns:
      the function result
      Throws:
      IOException - if an I/O error occurs
    • apply

      default CompletableFuture<R> apply(CompletableFuture<T> in)
      Applies this function asynchronously to the result of the given CompletableFuture. The function is executed on the same thread as the completion of the given future.
      Parameters:
      in - the input future
      Returns:
      a new future that holds the result of the function application
    • apply

      default CompletableFuture<R> apply(CompletableFuture<T> in, Executor executor)
      Applies this function asynchronously to the result of the given CompletableFuture, using the specified executor for the asynchronous computation.
      Parameters:
      in - the input future
      executor - the executor to use for the asynchronous computation
      Returns:
      a new future that holds the result of the function application