ApplyFunction (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.router.async.utils, interface: ApplyFunction

Package org.apache.hadoop.hdfs.server.federation.router.async.utils

# 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);

- ## Field Summary

  ### Fields inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async

  `CUR_COMPLETABLE_FUTURE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default CompletableFuture<R>`
  `apply(CompletableFuture<T> in)`
  Applies this function asynchronously to the result of the given `CompletableFuture`.
  `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.
  `R`
  `apply(T t)`
  Applies this function to the given argument.

  ### Methods inherited from interface org.apache.hadoop.hdfs.server.federation.router.async.utils.Async

  `getCurCompletableFuture, result, setCurCompletableFuture`

- ## 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