common-utils/src/main/java/org/warp/commonutils/concurrency/executor/SimplerExecutorServiceDecor...

102 lines
2.6 KiB
Java

package org.warp.commonutils.concurrency.executor;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
public class SimplerExecutorServiceDecorator extends ExecutorServiceDecorator {
private final ExecutorDecorator executorDecorator;
public SimplerExecutorServiceDecorator(ExecutorService executorService,
Function<Executor, ExecutorDecorator> executorDecoratorInitializer) {
super(executorService);
this.executorDecorator = executorDecoratorInitializer.apply(executorService);
}
@Override
public void shutdown() {
super.shutdown();
}
@NotNull
@Override
public List<Runnable> shutdownNow() {
return super.shutdownNow();
}
@Override
public boolean isShutdown() {
return super.isShutdown();
}
@Override
public boolean isTerminated() {
return super.isTerminated();
}
@Override
public boolean awaitTermination(long l, @NotNull TimeUnit timeUnit) throws InterruptedException {
return super.awaitTermination(l, timeUnit);
}
@NotNull
@Override
public <T> Future<T> submit(@NotNull Callable<T> callable) {
return super.submit(callable);
}
@NotNull
@Override
public <T> Future<T> submit(@NotNull Runnable runnable, T t) {
return super.submit(runnable, t);
}
@NotNull
@Override
public Future<?> submit(@NotNull Runnable runnable) {
return super.submit(runnable);
}
@NotNull
@Override
public <T> List<Future<T>> invokeAll(@NotNull Collection<? extends Callable<T>> collection)
throws InterruptedException {
return super.invokeAll(collection);
}
@NotNull
@Override
public <T> List<Future<T>> invokeAll(@NotNull Collection<? extends Callable<T>> collection,
long l,
@NotNull TimeUnit timeUnit) throws InterruptedException {
return super.invokeAll(collection, l, timeUnit);
}
@NotNull
@Override
public <T> T invokeAny(@NotNull Collection<? extends Callable<T>> collection)
throws InterruptedException, ExecutionException {
return super.invokeAny(collection);
}
@Override
public <T> T invokeAny(@NotNull Collection<? extends Callable<T>> collection, long l, @NotNull TimeUnit timeUnit)
throws InterruptedException, ExecutionException, TimeoutException {
return super.invokeAny(collection, l, timeUnit);
}
@Override
public void execute(@NotNull Runnable runnable) {
executorDecorator.execute(runnable);
}
}