Top Description Fields Constructors Methods
com.google.common.cache

public final Class RemovalNotification<K, V>

extends AbstractMap.SimpleImmutableEntry<@Nullable K, @Nullable V>
Class Inheritance
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

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.

Author
Charles Fry
Since
10.0

Field Summary

Modifier and TypeField and Description
private final RemovalCause
private static final long

Constructor Summary

AccessConstructor and Description
private
RemovalNotification(K key, V value, RemovalCause cause)

Method Summary

Modifier and TypeMethod and Description
public static <K, V> RemovalNotification<K, V>
create(K key, V value, RemovalCause cause)

Creates a new RemovalNotification for the given key/value pair, with the given cause for the removal.

public RemovalCause
getCause()

Returns the cause for which the entry was removed.

public boolean
wasEvicted()

Returns true if there was an automatic removal due to eviction (the cause is neither RemovalCause#EXPLICIT nor RemovalCause#REPLACED).

Inherited from java.util.AbstractMap.SimpleImmutableEntry:
equalsgetKeygetValuehashCodesetValuetoString

Field Detail

causeback to summary
private final RemovalCause cause
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.AbstractMap.SimpleImmutableEntry.serialVersionUID.

Constructor Detail

RemovalNotificationback to summary
private RemovalNotification(K key, V value, RemovalCause cause)

Method Detail

createback to summary
public static <K, V> RemovalNotification<K, V> create(K key, V value, RemovalCause cause)

Creates a new RemovalNotification for the given key/value pair, with the given cause for the removal. The key and/or value may be null if they were already garbage collected.

Since
19.0
getCauseback to summary
public RemovalCause getCause()

Returns the cause for which the entry was removed.

wasEvictedback to summary
public boolean wasEvicted()

Returns true if there was an automatic removal due to eviction (the cause is neither RemovalCause#EXPLICIT nor RemovalCause#REPLACED).