org.infinispan.commons.util.concurrent.CompletableFutures Maven / Gradle / Ivy
package org.infinispan.commons.util.concurrent;
import static java.util.Objects.requireNonNull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.infinispan.commons.CacheException;
/**
* Utility methods connecting {@link CompletableFuture} futures.
*
* @author Dan Berindei
* @since 8.0
*/
public final class CompletableFutures {
public static final CompletableFuture[] EMPTY_ARRAY = new CompletableFuture[0];
private static final CompletableFuture completedTrueFuture = CompletableFuture.completedFuture(Boolean.TRUE);
private static final CompletableFuture completedFalseFuture = CompletableFuture.completedFuture(Boolean.FALSE);
private static final CompletableFuture> completedEmptyMapFuture = CompletableFuture.completedFuture(Collections.emptyMap());
private static final CompletableFuture> completedNullFuture = CompletableFuture.completedFuture(null);
private static final long BIG_DELAY_NANOS = TimeUnit.DAYS.toNanos(1);
private static final Function, ?> TO_NULL = o -> null;
private static final Function, Boolean> TO_TRUE_FUNCTION = o -> Boolean.TRUE;
private static final Function, ?> identity = t -> t;
private CompletableFutures() {
}
@SuppressWarnings("unchecked")
public static CompletableFuture