Coverage Summary for Class: AbstractListeningExecutorService (com.google.common.util.concurrent)

Class Class, % Method, % Line, %
AbstractListeningExecutorService 100% (1/1) 83.3% (5/6) 83.3% (5/6)


1 /* 2  * Copyright (C) 2011 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the License 10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11  * or implied. See the License for the specific language governing permissions and limitations under 12  * the License. 13  */ 14  15 package com.google.common.util.concurrent; 16  17 import com.google.common.annotations.Beta; 18 import com.google.common.annotations.GwtIncompatible; 19 import com.google.errorprone.annotations.CanIgnoreReturnValue; 20 import java.util.concurrent.AbstractExecutorService; 21 import java.util.concurrent.Callable; 22 import java.util.concurrent.RunnableFuture; 23 import org.checkerframework.checker.nullness.qual.Nullable; 24  25 /** 26  * Abstract {@link ListeningExecutorService} implementation that creates {@link ListenableFuture} 27  * instances for each {@link Runnable} and {@link Callable} submitted to it. These tasks are run 28  * with the abstract {@link #execute execute(Runnable)} method. 29  * 30  * <p>In addition to {@link #execute}, subclasses must implement all methods related to shutdown and 31  * termination. 32  * 33  * @author Chris Povirk 34  * @since 14.0 35  */ 36 @Beta 37 @CanIgnoreReturnValue 38 @GwtIncompatible 39 @ElementTypesAreNonnullByDefault 40 public abstract class AbstractListeningExecutorService extends AbstractExecutorService 41  implements ListeningExecutorService { 42  43  /** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */ 44  @Override 45  protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor( 46  Runnable runnable, @ParametricNullness T value) { 47  return TrustedListenableFutureTask.create(runnable, value); 48  } 49  50  /** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */ 51  @Override 52  protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Callable<T> callable) { 53  return TrustedListenableFutureTask.create(callable); 54  } 55  56  @Override 57  public ListenableFuture<?> submit(Runnable task) { 58  return (ListenableFuture<?>) super.submit(task); 59  } 60  61  @Override 62  public <T extends @Nullable Object> ListenableFuture<T> submit( 63  Runnable task, @ParametricNullness T result) { 64  return (ListenableFuture<T>) super.submit(task, result); 65  } 66  67  @Override 68  public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) { 69  return (ListenableFuture<T>) super.submit(task); 70  } 71 }