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

org.xbib.helianthus.common.RequestContextAwareFuture Maven / Gradle / Ivy

package org.xbib.helianthus.common;

import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

final class RequestContextAwareFuture implements Future {

    private final RequestContext context;
    private final Future delegate;

    RequestContextAwareFuture(RequestContext context, Future delegate) {
        this.context = context;
        this.delegate = delegate;
    }

    @Override
    public boolean isSuccess() {
        return delegate.isSuccess();
    }

    @Override
    public boolean isCancellable() {
        return delegate.isCancellable();
    }

    @Override
    public Throwable cause() {
        return delegate.cause();
    }

    @Override
    public Future addListener(
            GenericFutureListener> listener) {
        return delegate.addListener(context.makeContextAware(listener));
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public Future addListeners(GenericFutureListener>... listeners) {
        return delegate.addListeners(Stream.of(listeners)
                .map(context::makeContextAware)
                .toArray(GenericFutureListener[]::new));
    }

    @Override
    public Future removeListener(GenericFutureListener> listener) {
        return delegate.removeListener(listener);
    }

    @SuppressWarnings("varargs")
    @Override
    @SafeVarargs
    public final Future removeListeners(GenericFutureListener>... listeners) {
        return delegate.removeListeners(listeners);
    }

    @Override
    public Future sync() throws InterruptedException {
        return delegate.sync();
    }

    @Override
    public Future syncUninterruptibly() {
        return delegate.syncUninterruptibly();
    }

    @Override
    public Future await() throws InterruptedException {
        return delegate.await();
    }

    @Override
    public Future awaitUninterruptibly() {
        return delegate.awaitUninterruptibly();
    }

    @Override
    public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
        return delegate.await(timeout, unit);
    }

    @Override
    public boolean await(long timeoutMillis) throws InterruptedException {
        return delegate.await(timeoutMillis);
    }

    @Override
    public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
        return delegate.awaitUninterruptibly(timeout, unit);
    }

    @Override
    public boolean awaitUninterruptibly(long timeoutMillis) {
        return delegate.awaitUninterruptibly(timeoutMillis);
    }

    @Override
    public T getNow() {
        return delegate.getNow();
    }

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

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

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

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

    @Override
    public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
            java.util.concurrent.TimeoutException {
        return delegate.get(timeout, unit);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy