Record Class WPCacheKeySnapshot<V>

java.lang.Object
java.lang.Record
net.ygbstudio.powerwp4j.models.entities.WPCacheKeySnapshot<V>
Type Parameters:
V - the type of the values in the cache subkey map. It is useful to think of this parameter as the kind of transformation that you apply to the cache subkeys. For example, JsonNode::asString will require a WPCacheKeySnapshot<String>.
Record Components:
cacheKey - the cache key represented by the CacheKeyEnum enum
cacheSubKeyMap - a map containing the cache subkeys represented by CacheSubKeyEnum and their corresponding values of type V.

public record WPCacheKeySnapshot<V>(CacheKeyEnum cacheKey, Map<CacheSubKeyEnum,@Nullable V> cacheSubKeyMap) extends Record
WPCacheKeySnapshot is a record that represents a snapshot of a cache key and its subkeys. Use this abstraction if you are getting nested values and a key exists. If the values are contained in an array or immediate value (not inside another JSON object), you can use

WPCacheAnalyzer.getCacheKeyValueStream(CacheKeyEnum)

Consumers must be wary that values in the subkey map can be null.

  • Constructor Details

    • WPCacheKeySnapshot

      public WPCacheKeySnapshot(CacheKeyEnum cacheKey, Map<CacheSubKeyEnum,@Nullable V> cacheSubKeyMap)
      Creates an instance of a WPCacheKeySnapshot record class.
      Parameters:
      cacheKey - the value for the cacheKey record component
      cacheSubKeyMap - the value for the cacheSubKeyMap record component
  • Method Details

    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • cacheKey

      public CacheKeyEnum cacheKey()
      Returns the value of the cacheKey record component.
      Returns:
      the value of the cacheKey record component
    • cacheSubKeyMap

      public Map<CacheSubKeyEnum,@Nullable V> cacheSubKeyMap()
      Returns the value of the cacheSubKeyMap record component.
      Returns:
      the value of the cacheSubKeyMap record component