All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zalando.riptide.AbstractCancelableCompletableFuture Maven / Gradle / Ivy

package org.zalando.riptide;

import java.util.concurrent.CompletableFuture;

import static org.zalando.riptide.CancelableCompletableFuture.preserveCancelability;

public abstract class AbstractCancelableCompletableFuture extends CompletableFuture {

    /**
     * This method is introduced by Java 9 and it's a virtual constructor.
     * This method is especially useful when subclassing CompletableFuture, mainly because it is used internally in
     * almost all methods returning a new CompletionStage, allowing subclasses to control what subtype gets returned
     * by such methods.
     *
     * http://www.baeldung.com/java-9-completablefuture
     *
     * @param  generic future return type
     * @return a new incomplete future to be used when constructing a dependent future
     */
    // TODO (Java 9): @Override
    public  CompletableFuture newIncompleteFuture() {
        return preserveCancelability(this);
    }

}