Annotation Interface CloneReference


@Retention(RUNTIME) @Target(FIELD) @Documented public @interface CloneReference
Annotation to mark fields that should be shallow copied (reference only) 标记克隆时仅复制引用的字段注解

Fields marked with this annotation will share the same reference in the cloned object. This is useful for shared resources like connection pools, thread pools, etc.

标记此注解的字段在克隆对象中将共享相同的引用。 适用于共享资源如连接池、线程池等。

Usage Examples | 使用示例:

public class Service {
    @CloneReference(reason = "Shared database connection pool")
    private DataSource dataSource;

    @CloneReference(reason = "Shared executor service")
    private ExecutorService executor;
}

Features | 主要功能:

  • Shallow copy annotated fields (reference only) - 浅拷贝注解字段(仅引用)
  • Runtime retention for reflection - 运行时保留用于反射

Security | 安全性:

  • Thread-safe: Yes (annotation is immutable) - 线程安全: 是(注解不可变)
Since:
JDK 25, opencode-base-deepclone V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Reason for using shallow copy (for documentation) 使用浅拷贝的原因(用于文档)
  • Element Details

    • reason

      String reason
      Reason for using shallow copy (for documentation) 使用浅拷贝的原因(用于文档)
      Returns:
      the reason | 原因
      Default:
      ""