Record Class CachedScanResult

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.scanner.CachedScanResult

public record CachedScanResult(String classpathHash, Set<String> classNames, String timestamp) extends Record
Cached Scan Result - Immutable record representing a cached class scan result 缓存扫描结果 - 表示缓存的类扫描结果的不可变记录

Stores the scan result along with a classpath hash for cache validation. If the classpath hash changes between runs, the cache is considered stale.

存储扫描结果及类路径哈希用于缓存验证。 如果类路径哈希在两次运行之间发生变化,则缓存视为过期。

Features | 主要功能:

  • Immutable record with defensive copy - 防御性拷贝的不可变记录
  • JSON serialization/deserialization - JSON 序列化/反序列化
  • Classpath hash validation - 类路径哈希验证

Usage Examples | 使用示例:

CachedScanResult result = new CachedScanResult(hash, classNames, timestamp);
String json = result.toJson();
CachedScanResult restored = CachedScanResult.fromJson(json);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-classloader V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CachedScanResult(String classpathHash, Set<String> classNames, String timestamp)
    Compact constructor with null checks, defensive copy, and sorted storage 紧凑构造器:null 校验、防御性拷贝和排序存储
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the classNames record component.
    Returns the value of the classpathHash record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Deserialize from JSON string 从 JSON 字符串反序列化
    final int
    Returns a hash code value for this object.
    Returns the value of the timestamp record component.
    Serialize to JSON string 序列化为 JSON 字符串
    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

    • CachedScanResult

      public CachedScanResult(String classpathHash, Set<String> classNames, String timestamp)
      Compact constructor with null checks, defensive copy, and sorted storage 紧凑构造器:null 校验、防御性拷贝和排序存储
  • Method Details

    • toJson

      public String toJson()
      Serialize to JSON string 序列化为 JSON 字符串
      Returns:
      JSON representation | JSON 表示
    • fromJson

      public static CachedScanResult fromJson(String json)
      Deserialize from JSON string 从 JSON 字符串反序列化
      Parameters:
      json - JSON string | JSON 字符串
      Returns:
      parsed result | 解析的结果
      Throws:
      IllegalArgumentException - if JSON is invalid | JSON 无效时抛出
    • 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.
    • classpathHash

      public String classpathHash()
      Returns the value of the classpathHash record component.
      Returns:
      the value of the classpathHash record component
    • classNames

      public Set<String> classNames()
      Returns the value of the classNames record component.
      Returns:
      the value of the classNames record component
    • timestamp

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