Coverage Summary for Class: RemovalListeners (com.google.common.cache)

Class Method, % Line, %
RemovalListeners 0% (0/2) 0% (0/4)
RemovalListeners$1 0% (0/2) 0% (0/2)
RemovalListeners$1$1 0% (0/2) 0% (0/2)
Total 0% (0/6) 0% (0/8)


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.cache; 16  17 import static com.google.common.base.Preconditions.checkNotNull; 18  19 import com.google.common.annotations.GwtIncompatible; 20 import java.util.concurrent.Executor; 21  22 /** 23  * A collection of common removal listeners. 24  * 25  * @author Charles Fry 26  * @since 10.0 27  */ 28 @GwtIncompatible 29 public final class RemovalListeners { 30  31  private RemovalListeners() {} 32  33  /** 34  * Returns a {@code RemovalListener} which processes all eviction notifications using {@code 35  * executor}. 36  * 37  * @param listener the backing listener 38  * @param executor the executor with which removal notifications are asynchronously executed 39  */ 40  public static <K, V> RemovalListener<K, V> asynchronous( 41  final RemovalListener<K, V> listener, final Executor executor) { 42  checkNotNull(listener); 43  checkNotNull(executor); 44  return new RemovalListener<K, V>() { 45  @Override 46  public void onRemoval(final RemovalNotification<K, V> notification) { 47  executor.execute( 48  new Runnable() { 49  @Override 50  public void run() { 51  listener.onRemoval(notification); 52  } 53  }); 54  } 55  }; 56  } 57 }