001/*
002 * Copyright (C) 2011 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015package com.google.common.util.concurrent;
016
017import com.google.common.annotations.GwtIncompatible;
018import java.util.concurrent.Callable;
019import org.checkerframework.checker.nullness.qual.Nullable;
020
021/**
022 * A listening executor service which forwards all its method calls to another listening executor
023 * service. Subclasses should override one or more methods to modify the behavior of the backing
024 * executor service as desired per the <a
025 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
026 *
027 * @author Isaac Shum
028 * @since 10.0
029 */
030@GwtIncompatible
031@ElementTypesAreNonnullByDefault
032public abstract class ForwardingListeningExecutorService extends ForwardingExecutorService
033    implements ListeningExecutorService {
034  /** Constructor for use by subclasses. */
035  protected ForwardingListeningExecutorService() {}
036
037  @Override
038  protected abstract ListeningExecutorService delegate();
039
040  @Override
041  public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
042    return delegate().submit(task);
043  }
044
045  @Override
046  public ListenableFuture<?> submit(Runnable task) {
047    return delegate().submit(task);
048  }
049
050  @Override
051  public <T extends @Nullable Object> ListenableFuture<T> submit(
052      Runnable task, @ParametricNullness T result) {
053    return delegate().submit(task, result);
054  }
055}