Class ImmutableDetector

java.lang.Object
cloud.opencode.base.deepclone.internal.ImmutableDetector

public final class ImmutableDetector extends Object
Immutable Detector - Detects JDK immutable collection types 不可变检测器 - 检测 JDK 不可变集合类型

Detects JDK immutable/unmodifiable collections such as List.of(), Set.of(), Map.of(), and Collections.unmodifiable*(). These types do not need deep cloning and can be safely referenced.

检测 JDK 不可变/不可修改集合,如 List.of()Set.of()Map.of()Collections.unmodifiable*()。 这些类型不需要深度克隆,可以安全地引用。

Features | 主要功能:

  • Detects List.of(), Set.of(), Map.of() results - 检测 List.of()、Set.of()、Map.of() 结果
  • Detects Collections.unmodifiable* wrappers - 检测 Collections.unmodifiable* 包装器
  • Detects Collections.empty* instances - 检测 Collections.empty* 实例
  • Detects Collections.singleton* instances - 检测 Collections.singleton* 实例

Security | 安全性:

  • Thread-safe: Yes (stateless, uses class name matching) - 线程安全: 是(无状态,使用类名匹配)
Since:
JDK 25, opencode-base-deepclone V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • isImmutableCollection

      public static boolean isImmutableCollection(Object obj)
      Checks if the given object is a JDK immutable/unmodifiable collection 检查给定对象是否为 JDK 不可变/不可修改集合
      Parameters:
      obj - the object to check | 要检查的对象
      Returns:
      true if the object is an immutable collection | 如果是不可变集合返回 true
    • isImmutableCollectionType

      public static boolean isImmutableCollectionType(Class<?> type)
      Checks if the given class is a JDK immutable/unmodifiable collection type 检查给定类是否为 JDK 不可变/不可修改集合类型
      Parameters:
      type - the type to check | 要检查的类型
      Returns:
      true if the type is an immutable collection type | 如果是不可变集合类型返回 true