Package javax.cache.event
Class CacheEntryEvent<K,V>
java.lang.Object
java.util.EventObject
javax.cache.event.CacheEntryEvent<K,V>
- Type Parameters:
K
- the type of keyV
- the type of value
- All Implemented Interfaces:
Serializable
,Cache.Entry<K,
V>
A Cache entry event base class.
- Since:
- 1.0
- See Also:
-
Field Summary
FieldsFields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorsConstructorDescriptionCacheEntryEvent
(Cache source, EventType eventType) Constructs a cache entry event from a given cache as source -
Method Summary
Modifier and TypeMethodDescriptionfinal EventType
Gets the event type of this eventabstract V
Returns the previous value that existed for entry in the cache before modification or removal.final Cache
abstract V
getValue()
Returns the value stored in the cache when this entry was created or updated.abstract boolean
Whether the old value is available.Methods inherited from class java.util.EventObject
toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javax.cache.Cache.Entry
getKey, unwrap
-
Field Details
-
eventType
-
-
Constructor Details
-
CacheEntryEvent
Constructs a cache entry event from a given cache as source- Parameters:
source
- the cache that originated the eventeventType
- the event type for this event
-
-
Method Details
-
getSource
- Overrides:
getSource
in classEventObject
-
getValue
Returns the value stored in the cache when this entry was created or updated.The value will be available for
CacheEntryCreatedListener
andCacheEntryUpdatedListener
. Returns the same value asgetOldValue()
forCacheEntryExpiredListener
andCacheEntryRemovedListener
. Cache clients that need to maintain compatibility with JSR107 version 1.0 cache implementations, need to use this method for retrieving the expired or removed value. When using cache implementations compatible with JSR107 version 1.1, clients should prefer the methodgetOldValue()
.- Specified by:
getValue
in interfaceCache.Entry<K,
V> - Returns:
- the value corresponding to this entry
- See Also:
-
getOldValue
Returns the previous value that existed for entry in the cache before modification or removal. The old value will be available forCacheEntryUpdatedListener
,CacheEntryExpiredListener
andCacheEntryRemovedListener
ifCacheEntryListenerConfiguration.isOldValueRequired()
is true. The old value may be available forCacheEntryUpdatedListener
,CacheEntryExpiredListener
andCacheEntryRemovedListener
ifCacheEntryListenerConfiguration.isOldValueRequired()
is false.- Returns:
- the previous value or
null
if there was no previous value or the previous value is not available
-
isOldValueAvailable
public abstract boolean isOldValueAvailable()Whether the old value is available. The old value will be available forCacheEntryUpdatedListener
,CacheEntryExpiredListener
andCacheEntryRemovedListener
ifCacheEntryListenerConfiguration.isOldValueRequired()
is true. The old value may be available forCacheEntryUpdatedListener
,CacheEntryExpiredListener
andCacheEntryRemovedListener
ifCacheEntryListenerConfiguration.isOldValueRequired()
is false.- Returns:
- true if the old value is definitely available
-
getEventType
Gets the event type of this event- Returns:
- the event type.
-