Class RemovalNotification<K,V>
java.lang.Object
java.util.AbstractMap.SimpleImmutableEntry<@Nullable K,@Nullable V>
com.google.common.cache.RemovalNotification<K,V>
- All Implemented Interfaces:
Serializable
,Map.Entry<K,
V>
@GwtCompatible
public final class RemovalNotification<K,V>
extends AbstractMap.SimpleImmutableEntry<@Nullable K,@Nullable V>
A notification of the removal of a single entry. The key and/or value may be null if they were
already garbage collected.
Like other Entry
instances associated with CacheBuilder
, this class holds
strong references to the key and value, regardless of the type of references the cache may be
using.
- Since:
- 10.0
- Author:
- Charles Fry
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> RemovalNotification <K, V> create
(@Nullable K key, @Nullable V value, RemovalCause cause) Creates a newRemovalNotification
for the givenkey
/value
pair, with the givencause
for the removal.getCause()
Returns the cause for which the entry was removed.boolean
Returnstrue
if there was an automatic removal due to eviction (the cause is neitherRemovalCause.EXPLICIT
norRemovalCause.REPLACED
).
-
Method Details
-
create
public static <K,V> RemovalNotification<K,V> create(@Nullable K key, @Nullable V value, RemovalCause cause) Creates a newRemovalNotification
for the givenkey
/value
pair, with the givencause
for the removal. Thekey
and/orvalue
may benull
if they were already garbage collected.- Since:
- 19.0
-
getCause
Returns the cause for which the entry was removed. -
wasEvicted
Returnstrue
if there was an automatic removal due to eviction (the cause is neitherRemovalCause.EXPLICIT
norRemovalCause.REPLACED
).
-