Record Class ReadOnlyEntry<K,V>

java.lang.Object
java.lang.Record
com.loomcache.server.compute.ReadOnlyEntry<K,V>
Type Parameters:
K - the type of the key
V - the type of the value
All Implemented Interfaces:
CacheEntryProcessor.Entry<K,V>, ReadOnlyCacheEntryProcessor.ReadOnlyEntry<K,V>

public record ReadOnlyEntry<K,V>(K key, @Nullable V value, boolean exists) extends Record implements ReadOnlyCacheEntryProcessor.ReadOnlyEntry<K,V>
Read-only wrapper implementation of Entry that throws UnsupportedOperationException on mutation attempts.

This class is used internally by EntryProcessorExecutor to provide a read-only view of an entry when a ReadOnlyCacheEntryProcessor is executed. Any attempt to call setValue or remove will throw UnsupportedOperationException.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ReadOnlyEntry(K key, @Nullable V value, boolean exists)
    Create a new read-only entry wrapper.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the exists record component.
    final int
    Returns a hash code value for this object.
    key()
    Returns the value of the key record component.
    void
    Remove this entry from the map.
    void
    setValue(@Nullable V value)
    Set the value of this entry.
    final String
    Returns a string representation of this record class.
    @Nullable V
    Returns the value of the value record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ReadOnlyEntry

      public ReadOnlyEntry(K key, @Nullable V value, boolean exists)
      Create a new read-only entry wrapper.
      Parameters:
      key - the key (must not be null)
      value - the value (may be null)
      exists - whether the entry exists in the map
      Throws:
      NullPointerException - if key is null
  • Method Details

    • setValue

      public void setValue(@Nullable V value)
      Description copied from interface: CacheEntryProcessor.Entry
      Set the value of this entry. This marks the entry for update within the processor execution.
      Specified by:
      setValue in interface CacheEntryProcessor.Entry<K,V>
      Parameters:
      value - the new value
    • remove

      public void remove()
      Description copied from interface: CacheEntryProcessor.Entry
      Remove this entry from the map. After calling this, CacheEntryProcessor.Entry.value() will return null.
      Specified by:
      remove in interface CacheEntryProcessor.Entry<K,V>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public K key()
      Returns the value of the key record component.
      Specified by:
      key in interface CacheEntryProcessor.Entry<K,V>
      Returns:
      the value of the key record component
    • value

      public @Nullable V value()
      Returns the value of the value record component.
      Specified by:
      value in interface CacheEntryProcessor.Entry<K,V>
      Returns:
      the value of the value record component
    • exists

      public boolean exists()
      Returns the value of the exists record component.
      Specified by:
      exists in interface CacheEntryProcessor.Entry<K,V>
      Returns:
      the value of the exists record component