Record Class FeatureSnapshot

java.lang.Object
java.lang.Record
cloud.opencode.base.feature.FeatureSnapshot
Record Components:
features - the feature map | 功能映射
timestamp - the snapshot timestamp | 快照时间戳

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
  • Null-safe: Partial (validates inputs) - 空值安全: 部分(验证输入)

public record FeatureSnapshot(Map<String,Feature> features, Instant timestamp) extends Record
Feature Snapshot 功能快照

Immutable snapshot of all features at a point in time.

某一时刻所有功能的不可变快照。

Features | 主要功能:

  • Capture feature state - 捕获功能状态
  • Restore feature state - 恢复功能状态
  • Point-in-time snapshot - 时间点快照

Usage Examples | 使用示例:

FeatureSnapshot snapshot = openFeature.snapshot();
// ... modify features ...
openFeature.restore(snapshot); // restore to previous state
Since:
JDK 25, opencode-base-feature V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    FeatureSnapshot(Map<String,Feature> features, Instant timestamp)
    Compact constructor with validation 带验证的紧凑构造函数
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if this snapshot contains a feature with the given key 检查此快照是否包含具有给定键的功能
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the features record component.
    final int
    Returns a hash code value for this object.
    int
    Get the number of features in this snapshot 获取此快照中的功能数量
    Returns the value of the timestamp record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • FeatureSnapshot

      public FeatureSnapshot(Map<String,Feature> features, Instant timestamp)
      Compact constructor with validation 带验证的紧凑构造函数
  • Method Details

    • size

      public int size()
      Get the number of features in this snapshot 获取此快照中的功能数量
      Returns:
      the size | 大小
    • contains

      public boolean contains(String key)
      Check if this snapshot contains a feature with the given key 检查此快照是否包含具有给定键的功能
      Parameters:
      key - the feature key | 功能键
      Returns:
      true if contains | 如果包含返回true
    • 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.
    • features

      public Map<String,Feature> features()
      Returns the value of the features record component.
      Returns:
      the value of the features record component
    • timestamp

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