Package com.google.common.cache
Class RemovalNotification<K,V>
- java.lang.Object
-
- java.util.AbstractMap.SimpleImmutableEntry<K,V>
-
- com.google.common.cache.RemovalNotification<K,V>
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Map.Entry<K,V>
public final class RemovalNotification<K,V> extends java.util.AbstractMap.SimpleImmutableEntry<K,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 withCacheBuilder
, this class holds strong references to the key and value, regardless of the type of references the cache may be using.- Since:
- 10.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private RemovalCause
cause
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
RemovalNotification(K key, V value, RemovalCause cause)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
RemovalNotification<K,V>create(K key, V value, RemovalCause cause)
Creates a newRemovalNotification
for the givenkey
/value
pair, with the givencause
for the removal.RemovalCause
getCause()
Returns the cause for which the entry was removed.boolean
wasEvicted()
Returnstrue
if there was an automatic removal due to eviction (the cause is neitherRemovalCause.EXPLICIT
norRemovalCause.REPLACED
).
-
-
-
Field Detail
-
cause
private final RemovalCause cause
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RemovalNotification
private RemovalNotification(K key, V value, RemovalCause cause)
-
-
Method Detail
-
create
public static <K,V> RemovalNotification<K,V> create(K key, 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
public RemovalCause getCause()
Returns the cause for which the entry was removed.
-
wasEvicted
public boolean wasEvicted()
Returnstrue
if there was an automatic removal due to eviction (the cause is neitherRemovalCause.EXPLICIT
norRemovalCause.REPLACED
).
-
-