content: package com.alibaba.ttl.threadpool;
  
  import com.alibaba.ttl.TransmittableThreadLocal;
  import com.alibaba.ttl.TtlCallable;
  import com.alibaba.ttl.TtlRunnable;
  import com.alibaba.ttl.spi.TtlEnhanced;
  import edu.umd.cs.findbugs.annotations.NonNull;
  import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
  
  import java.util.Collection;
  import java.util.List;
  import java.util.concurrent.*;
  
  /**
   * {@link TransmittableThreadLocal} Wrapper of {@link ExecutorService},
   * transmit the {@link TransmittableThreadLocal} from the task submit time of {@link Runnable} or {@link Callable}
   * to the execution time of {@link Runnable} or {@link Callable}.
   *
   * @author Jerry Lee (oldratlee at gmail dot com)
   * @since 0.9.0
   */
  @SuppressFBWarnings({"EQ_DOESNT_OVERRIDE_EQUALS"})
  class ExecutorServiceTtlWrapper extends ExecutorTtlWrapper implements ExecutorService, TtlEnhanced {
      private final ExecutorService executorService;
  
      ExecutorServiceTtlWrapper(@NonNull ExecutorService executorService, boolean idempotent) {
          super(executorService, idempotent);
          this.executorService = executorService;
      }
  
      @Override
      public void shutdown() {
          executorService.shutdown();
      }
  
      @NonNull
      @Override
      public List<Runnable> shutdownNow() {
          return executorService.shutdownNow();
      }
  
      @Override
      public boolean isShutdown() {
          return executorService.isShutdown();
      }
  
      @Override
      public boolean isTerminated() {
          return executorService.isTerminated();
      }
  
      @Override
      public boolean awaitTermination(long timeout, @NonNull TimeUnit unit) throws InterruptedException {
          return executorService.awaitTermination(timeout, unit);
      }
  
      @NonNull
      @Override
      public <T> Future<T> submit(@NonNull Callable<T> task) {
          return executorService.submit(TtlCallable.get(task, false, idempotent));
      }
  
      @NonNull
      @Override
      public <T> Future<T> submit(@NonNull Runnable task, T result) {
          return executorService.submit(TtlRunnable.get(task, false, idempotent), result);
      }
  
      @NonNull
      @Override
      public Future<?> submit(@NonNull Runnable task) {
          return executorService.submit(TtlRunnable.get(task, false, idempotent));
      }
  
      @NonNull
      @Override
      public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException {
          return executorService.invokeAll(TtlCallable.gets(tasks, false, idempotent));
      }
  
      @NonNull
      @Override
      public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException {
          return executorService.invokeAll(TtlCallable.gets(tasks, false, idempotent), timeout, unit);
      }
  
      @NonNull
      @Override
      public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
          return executorService.invokeAny(TtlCallable.gets(tasks, false, idempotent));
      }
  
      @Override
      public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
          return executorService.invokeAny(TtlCallable.gets(tasks, false, idempotent), timeout, unit);
      }
  
      @NonNull
      @Override
      public ExecutorService unwrap() {
          return executorService;
      }
  }
  