Interface ApplyFunction<T,R>
- Type Parameters:
T- the type of the input to the functionR- 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.
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 TypeMethodDescriptiondefault CompletableFuture<R>apply(CompletableFuture<T> in) Applies this function asynchronously to the result of the givenCompletableFuture.default CompletableFuture<R>apply(CompletableFuture<T> in, Executor executor) Applies this function asynchronously to the result of the givenCompletableFuture, using the specified executor for the asynchronous computation.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
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
Applies this function asynchronously to the result of the givenCompletableFuture. 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
Applies this function asynchronously to the result of the givenCompletableFuture, using the specified executor for the asynchronous computation.- Parameters:
in- the input futureexecutor- the executor to use for the asynchronous computation- Returns:
- a new future that holds the result of the function application
-