net.florianschoppmann.java.futures.CheckedFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-futures Show documentation
Show all versions of java-futures Show documentation
Bridge gaps and help overcome inconveniences with CompletableFuture.
This module includes, among other features, methods to collect the results of multiple futures into a list,
provides equivalent alternatives to CompletableFuture’s monadic methods (thenApply, thenCompose, etc.) that can
deal with checked exceptions, and methods for asynchronous “try-with-resources” constructs.
The newest version!
package net.florianschoppmann.java.futures;
import javax.annotation.Nullable;
/**
* Represents a function that accepts one argument and produces a result. The function may throw a checked exception.
*
* This is a functional interface whose functional method is {@link #checkedApply(Object)}. It is similar to
* {@link java.util.function.Function}, except that the functional method may throw a checked exception.
*
* @param the type of the input to the function
* @param the type of the result of the function
*
* @see java.util.function.Function
*/
@FunctionalInterface
public interface CheckedFunction {
/**
* Applies this function to the given argument.
*
* @param argument the function argument
* @return the function result
* @throws Exception if unable to compute a result
*/
@Nullable
R checkedApply(@Nullable T argument) throws Exception;
}