class FutureUtils {

	public static <IN> CompletableFuture<IN> whenCompleteAsyncIfNotDone(
		CompletableFuture<IN> completableFuture,
		Executor executor,
		BiConsumer<? super IN, ? super Throwable> whenCompleteFun) {
		return completableFuture.isDone() ?
			completableFuture.whenComplete(whenCompleteFun) :
			completableFuture.whenCompleteAsync(whenCompleteFun, executor);
	}

}