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

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

package org.zalando.riptide;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

final class CompletionAdapter implements Completion {

    private final CompletableFuture future;

    CompletionAdapter(final CompletableFuture future) {
        this.future = future;
    }

    @Override
    public  Completion thenApply(final Function fn) {
        return Completion.valueOf(future.thenApply(fn));
    }

    @Override
    public  Completion thenApplyAsync(final Function fn) {
        return Completion.valueOf(future.thenApplyAsync(fn));
    }

    @Override
    public  Completion thenApplyAsync(final Function fn, final Executor executor) {
        return Completion.valueOf(future.thenApplyAsync(fn, executor));
    }

    @Override
    public Completion thenAccept(final Consumer action) {
        return Completion.valueOf(future.thenAccept(action));
    }

    @Override
    public Completion thenAcceptAsync(final Consumer action) {
        return Completion.valueOf(future.thenAcceptAsync(action));
    }

    @Override
    public Completion thenAcceptAsync(final Consumer action, final Executor executor) {
        return Completion.valueOf(future.thenAcceptAsync(action, executor));
    }

    @Override
    public Completion thenRun(final Runnable action) {
        return Completion.valueOf(future.thenRun(action));
    }

    @Override
    public Completion thenRunAsync(final Runnable action) {
        return Completion.valueOf(future.thenRunAsync(action));
    }

    @Override
    public Completion thenRunAsync(final Runnable action, final Executor executor) {
        return Completion.valueOf(future.thenRunAsync(action, executor));
    }

    @Override
    public  Completion thenCombine(final CompletionStage other, final BiFunction fn) {
        return Completion.valueOf(future.thenCombine(other, fn));
    }

    @Override
    public  Completion thenCombineAsync(final CompletionStage other, final BiFunction fn) {
        return Completion.valueOf(future.thenCombineAsync(other, fn));
    }

    @Override
    public  Completion thenCombineAsync(final CompletionStage other, final BiFunction fn, final Executor executor) {
        return Completion.valueOf(future.thenCombineAsync(other, fn, executor));
    }

    @Override
    public  Completion thenAcceptBoth(final CompletionStage other, final BiConsumer action) {
        return Completion.valueOf(future.thenAcceptBoth(other, action));
    }

    @Override
    public  Completion thenAcceptBothAsync(final CompletionStage other, final BiConsumer action) {
        return Completion.valueOf(future.thenAcceptBothAsync(other, action));
    }

    @Override
    public  Completion thenAcceptBothAsync(final CompletionStage other, final BiConsumer action, final Executor executor) {
        return Completion.valueOf(future.thenAcceptBothAsync(other, action, executor));
    }

    @Override
    public Completion runAfterBoth(final CompletionStage other, final Runnable action) {
        return Completion.valueOf(future.runAfterBoth(other, action));
    }

    @Override
    public Completion runAfterBothAsync(final CompletionStage other, final Runnable action) {
        return Completion.valueOf(future.runAfterBothAsync(other, action));
    }

    @Override
    public Completion runAfterBothAsync(final CompletionStage other, final Runnable action, final Executor executor) {
        return Completion.valueOf(future.runAfterBothAsync(other, action, executor));
    }

    @Override
    public  Completion applyToEither(final CompletionStage other, final Function fn) {
        return Completion.valueOf(future.applyToEither(other, fn));
    }

    @Override
    public  Completion applyToEitherAsync(final CompletionStage other, final Function fn) {
        return Completion.valueOf(future.applyToEitherAsync(other, fn));
    }

    @Override
    public  Completion applyToEitherAsync(final CompletionStage other, final Function fn, final Executor executor) {
        return Completion.valueOf(future.applyToEitherAsync(other, fn, executor));
    }

    @Override
    public Completion acceptEither(final CompletionStage other, final Consumer action) {
        return Completion.valueOf(future.acceptEither(other, action));
    }

    @Override
    public Completion acceptEitherAsync(final CompletionStage other, final Consumer action) {
        return Completion.valueOf(future.acceptEitherAsync(other, action));
    }

    @Override
    public Completion acceptEitherAsync(final CompletionStage other, final Consumer action, final Executor executor) {
        return Completion.valueOf(future.acceptEitherAsync(other, action, executor));
    }

    @Override
    public Completion runAfterEither(final CompletionStage other, final Runnable action) {
        return Completion.valueOf(future.runAfterEither(other, action));
    }

    @Override
    public Completion runAfterEitherAsync(final CompletionStage other, final Runnable action) {
        return Completion.valueOf(future.runAfterEitherAsync(other, action));
    }

    @Override
    public Completion runAfterEitherAsync(final CompletionStage other, final Runnable action, final Executor executor) {
        return Completion.valueOf(future.runAfterEitherAsync(other, action, executor));
    }

    @Override
    public  Completion thenCompose(final Function> fn) {
        return Completion.valueOf(future.thenCompose(fn));
    }

    @Override
    public  Completion thenComposeAsync(final Function> fn) {
        return Completion.valueOf(future.thenComposeAsync(fn));
    }

    @Override
    public  Completion thenComposeAsync(final Function> fn, final Executor executor) {
        return Completion.valueOf(future.thenComposeAsync(fn, executor));
    }

    @Override
    public Completion exceptionally(final Function fn) {
        return Completion.valueOf(future.exceptionally(fn));
    }

    @Override
    public Completion whenComplete(final BiConsumer action) {
        return Completion.valueOf(future.whenComplete(action));
    }

    @Override
    public Completion whenCompleteAsync(final BiConsumer action) {
        return Completion.valueOf(future.whenCompleteAsync(action));
    }

    @Override
    public Completion whenCompleteAsync(final BiConsumer action, final Executor executor) {
        return Completion.valueOf(future.whenCompleteAsync(action, executor));
    }

    @Override
    public  Completion handle(final BiFunction fn) {
        return Completion.valueOf(future.handle(fn));
    }

    @Override
    public  Completion handleAsync(final BiFunction fn) {
        return Completion.valueOf(future.handleAsync(fn));
    }

    @Override
    public  Completion handleAsync(final BiFunction fn, final Executor executor) {
        return Completion.valueOf(future.handleAsync(fn, executor));
    }

    @Override
    public CompletableFuture toCompletableFuture() {
        return future;
    }

    @Override
    public boolean cancel(final boolean mayInterruptIfRunning) {
        return future.cancel(mayInterruptIfRunning);
    }

    @Override
    public boolean isCancelled() {
        return future.isCancelled();
    }

    @Override
    public boolean isDone() {
        return future.isDone();
    }

    @Override
    public T get() throws InterruptedException, ExecutionException {
        return future.get();
    }

    @Override
    public T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        return future.get(timeout, unit);
    }

    @Override
    public T join() {
        return future.join();
    }

    @Override
    public T getNow(final T valueIfAbsent) {
        return future.getNow(valueIfAbsent);
    }

}