Class OpenDeepCloneException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenDeepCloneException extends OpenException
Exception for deep clone operations 深度克隆操作异常

This exception is thrown when errors occur during object cloning, such as instantiation failures, field access errors, or circular reference issues.

当对象克隆过程中发生错误时抛出此异常,如实例化失败、字段访问错误或循环引用问题。

Features | 主要功能:

  • Target type tracking - 目标类型跟踪
  • Clone path tracking - 克隆路径跟踪
  • Factory methods for common errors - 常见错误的工厂方法

Usage Examples | 使用示例:

throw OpenDeepCloneException.instantiationFailed(MyClass.class, cause);
throw OpenDeepCloneException.maxDepthExceeded(100, "a.b.c.d");
throw OpenDeepCloneException.unsupportedType(SomeClass.class);

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
Since:
JDK 25, opencode-base-deepclone V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenDeepCloneException

      public OpenDeepCloneException(String message)
      Creates an exception with a message 使用消息创建异常
      Parameters:
      message - the error message | 错误消息
    • OpenDeepCloneException

      public OpenDeepCloneException(String message, Throwable cause)
      Creates an exception with a message and cause 使用消息和原因创建异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
    • OpenDeepCloneException

      public OpenDeepCloneException(Class<?> targetType, String path, String message)
      Creates an exception with target type, path, and message 使用目标类型、路径和消息创建异常
      Parameters:
      targetType - the type being cloned | 正在克隆的类型
      path - the clone path | 克隆路径
      message - the error message | 错误消息
    • OpenDeepCloneException

      public OpenDeepCloneException(Class<?> targetType, String path, String message, Throwable cause)
      Creates an exception with target type, path, message, and cause 使用目标类型、路径、消息和原因创建异常
      Parameters:
      targetType - the type being cloned | 正在克隆的类型
      path - the clone path | 克隆路径
      message - the error message | 错误消息
      cause - the cause | 原因
  • Method Details

    • getTargetType

      public Class<?> getTargetType()
      Gets the target type being cloned 获取正在克隆的目标类型
      Returns:
      the target type, may be null | 目标类型,可能为null
    • getPath

      public String getPath()
      Gets the clone path where the error occurred 获取发生错误的克隆路径
      Returns:
      the path, may be null | 路径,可能为null
    • maxDepthExceeded

      public static OpenDeepCloneException maxDepthExceeded(int depth, String path)
      Creates an exception for exceeding maximum clone depth 创建超过最大克隆深度的异常
      Parameters:
      depth - the depth reached | 达到的深度
      path - the clone path | 克隆路径
      Returns:
      the exception | 异常
    • unsupportedType

      public static OpenDeepCloneException unsupportedType(Class<?> type)
      Creates an exception for unsupported type 创建不支持类型的异常
      Parameters:
      type - the unsupported type | 不支持的类型
      Returns:
      the exception | 异常
    • instantiationFailed

      public static OpenDeepCloneException instantiationFailed(Class<?> type, Throwable cause)
      Creates an exception for instantiation failure 创建实例化失败的异常
      Parameters:
      type - the type that failed to instantiate | 无法实例化的类型
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • fieldAccessFailed

      public static OpenDeepCloneException fieldAccessFailed(String field, Class<?> type, Throwable cause)
      Creates an exception for field access failure 创建字段访问失败的异常
      Parameters:
      field - the field name | 字段名
      type - the declaring type | 声明类型
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • serializationFailed

      public static OpenDeepCloneException serializationFailed(Class<?> type, Throwable cause)
      Creates an exception for serialization failure 创建序列化失败的异常
      Parameters:
      type - the type that failed to serialize | 无法序列化的类型
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • circularReference

      public static OpenDeepCloneException circularReference(Class<?> type, String path)
      Creates an exception for circular reference detection 创建循环引用检测的异常
      Parameters:
      type - the type with circular reference | 存在循环引用的类型
      path - the clone path | 克隆路径
      Returns:
      the exception | 异常