Interface CacheEntry<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
javax.cache.Cache.Entry<K,V>, javax.cache.processor.MutableEntry<K,V>

public interface CacheEntry<K,V> extends javax.cache.processor.MutableEntry<K,V>
Represents a single cache entry accessed within an entry processor.

Extends MutableEntry to provide JSR-107 compliance out of the box. Users can register either the native EntryProcessor or the standard EntryProcessor — both receive instances assignable to Cache.Entry, MutableEntry, and this interface.

Allows atomic read and write of cache entries.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if the entry exists.
    Get the key.
    @Nullable V
    Get the value.
    void
    Remove the entry.
    void
    setValue(@Nullable V value)
    Set the value.
    default <T> T
    unwrap(Class<T> clazz)
    Unwrap to the specified type, per JSR-107 contract.
  • Method Details

    • getKey

      K getKey()
      Get the key.
      Specified by:
      getKey in interface javax.cache.Cache.Entry<K,V>
    • getValue

      @Nullable V getValue()
      Get the value.
      Specified by:
      getValue in interface javax.cache.Cache.Entry<K,V>
      Specified by:
      getValue in interface javax.cache.processor.MutableEntry<K,V>
      Returns:
      the value, or null if not present
    • setValue

      void setValue(@Nullable V value)
      Set the value.
      Specified by:
      setValue in interface javax.cache.processor.MutableEntry<K,V>
      Parameters:
      value - the new value; null clears the entry (equivalent to remove())
    • exists

      boolean exists()
      Check if the entry exists.
      Specified by:
      exists in interface javax.cache.processor.MutableEntry<K,V>
    • remove

      void remove()
      Remove the entry.
      Specified by:
      remove in interface javax.cache.processor.MutableEntry<K,V>
    • unwrap

      default <T> T unwrap(Class<T> clazz)
      Unwrap to the specified type, per JSR-107 contract.
      Specified by:
      unwrap in interface javax.cache.Cache.Entry<K,V>
      Parameters:
      clazz - target type
      Returns:
      this entry if clazz is assignable; otherwise throws
      Throws:
      IllegalArgumentException - if clazz is not assignable from this entry