Record Class ConfigSnapshot

java.lang.Object
java.lang.Record
com.loomcache.server.config.ConfigSnapshot
Record Components:
entries - immutable map of all configuration entries (key -> ConfigEntry)
timestamp - the time (millis since epoch) when this snapshot was taken

public record ConfigSnapshot(Map<String, ConfigEntry> entries, long timestamp) extends Record
Immutable snapshot of all configuration entries at a point in time.

Provides atomic multi-key reads of the entire configuration state. Snapshots are read-only and can be safely shared across threads.

  • Constructor Details

    • ConfigSnapshot

      public ConfigSnapshot(Map<String, ConfigEntry> entries, long timestamp)
      Creates an instance of a ConfigSnapshot record class.
      Parameters:
      entries - the value for the entries record component
      timestamp - the value for the timestamp record component
  • Method Details

    • entries

      public Map<String, ConfigEntry> entries()
      Get all entries as an unmodifiable map.
      Returns:
      unmodifiable view of entries
    • size

      public int size()
      Get the number of configuration entries in this snapshot.
      Returns:
      entry count
    • containsKey

      public boolean containsKey(String key)
      Check if a key exists in this snapshot.
      Parameters:
      key - the configuration key
      Returns:
      true if the key exists
    • get

      public @Nullable ConfigEntry get(String key)
      Get a configuration entry by key.
      Parameters:
      key - the configuration key
      Returns:
      the ConfigEntry, or null if not found
    • 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.
    • timestamp

      public long timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component