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 * <p><b>{@code default} method warning:</b> This class does <i>not</i> forward calls to {@code
028 * default} methods. Instead, it inherits their default implementations. When those implementations
029 * invoke methods, they invoke methods on the {@code ForwardingListeningExecutorService}.
030 *
031 * @author Isaac Shum
032 * @since 10.0
033 */
034@GwtIncompatible
035@ElementTypesAreNonnullByDefault
036public abstract class ForwardingListeningExecutorService extends ForwardingExecutorService
037    implements ListeningExecutorService {
038  /** Constructor for use by subclasses. */
039  protected ForwardingListeningExecutorService() {}
040
041  @Override
042  protected abstract ListeningExecutorService delegate();
043
044  @Override
045  public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
046    return delegate().submit(task);
047  }
048
049  @Override
050  public ListenableFuture<?> submit(Runnable task) {
051    return delegate().submit(task);
052  }
053
054  @Override
055  public <T extends @Nullable Object> ListenableFuture<T> submit(
056      Runnable task, @ParametricNullness T result) {
057    return delegate().submit(task, result);
058  }
059}