com.jashmore.sqs.util.concurrent.CompletableFutureUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-utils Show documentation
Show all versions of common-utils Show documentation
Utility methods for dealing with basic functionality for this library, split out so so it can be consumed by other extensions
package com.jashmore.sqs.util.concurrent;
import lombok.experimental.UtilityClass;
import java.util.concurrent.CompletableFuture;
@UtilityClass
public class CompletableFutureUtils {
/**
* Creates a new {@link CompletableFuture} that is completed exceptionally with the provided {@link Throwable}.
*
* @param throwable the throwable to complete the {@link CompletableFuture} with
* @param the type that the future is returning
* @return a future that is completed exceptionally
*/
public static CompletableFuture completedExceptionally(final Throwable throwable) {
final CompletableFuture future = new CompletableFuture<>();
future.completeExceptionally(throwable);
return future;
}
}