001 /* 002 * Copyright (C) 2010 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package com.google.common.collect; 018 019 import com.google.common.annotations.Beta; 020 021 import javax.annotation.Nullable; 022 023 /** 024 * An object that can receive a notification when an entry is evicted from a 025 * map. 026 * 027 * <p>An instance may be called concurrently by multiple threads to process 028 * different entries. Implementations of this interface should avoid performing 029 * blocking calls or synchronizing on shared resources. 030 * 031 * @param <K> the type of keys being evicted 032 * @param <V> the type of values being evicted 033 * @author Ben Manes 034 * @since 7.0 035 * @deprecated use {@link MapMaker.RemovalListener} <b>This class is scheduled 036 * for deletion from Guava in Guava release 11.0.</b> 037 */ 038 @Beta 039 @Deprecated 040 public 041 interface MapEvictionListener<K, V> { 042 043 /** 044 * Notifies the listener that an eviction has occurred. Eviction may be for 045 * reasons such as timed expiration, exceeding a maximum size, or due to 046 * garbage collection. Eviction notification does <i>not</i> occur due to 047 * manual removal. 048 * 049 * @param key the key of the entry that has already been evicted, or {@code 050 * null} if its reference was collected 051 * @param value the value of the entry that has already been evicted, or 052 * {@code null} if its reference was collected 053 */ 054 void onEviction(@Nullable K key, @Nullable V value); 055 }