12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/*
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Copyright (C) 2011 The Guava Authors
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License");
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * you may not use this file except in compliance with the License.
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * You may obtain a copy of the License at
7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *
8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * http://www.apache.org/licenses/LICENSE-2.0
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * Unless required by applicable law or agreed to in writing, software
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS,
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * See the License for the specific language governing permissions and
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * limitations under the License.
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) */
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)package com.google.common.cache;
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)import com.google.common.annotations.Beta;
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * An object that can receive a notification when an entry is removed from a cache. The removal
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * resulting in notification could have occured to an entry being manually removed or replaced, or
2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * due to eviction resulting from timed expiration, exceeding a maximum size, or garbage
2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) * collection.
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) *
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * <p>An instance may be called concurrently by multiple threads to process different entries.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Implementations of this interface should avoid performing blocking calls or synchronizing on
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * shared resources.
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * @param <K> the most general type of keys this listener can listen for; for
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *     example {@code Object} if any key is acceptable
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * @param <V> the most general type of values this listener can listen for; for
34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *     example {@code Object} if any key is acceptable
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * @author Charles Fry
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * @since 10.0
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@Beta
39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)public interface RemovalListener<K, V> {
40c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  /**
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Notifies the listener that a removal occurred at some point in the past.
42   */
43  // Technically should accept RemovalNotification<? extends K, ? extends V>, but because
44  // RemovalNotification is guaranteed covariant, let's make users' lives simpler.
45  void onRemoval(RemovalNotification<K, V> notification);
46}
47