Class ArrayHandler

java.lang.Object
cloud.opencode.base.deepclone.handler.ArrayHandler
All Implemented Interfaces:
TypeHandler<Object>

public final class ArrayHandler extends Object implements TypeHandler<Object>
Handler for cloning array types 数组类型克隆处理器

Handles both primitive arrays (int[], double[], etc.) and object arrays. Primitive arrays are copied directly, object arrays have their elements deep cloned.

处理基本类型数组(int[]、double[]等)和对象数组。 基本类型数组直接复制,对象数组的元素会被深度克隆。

Usage Examples | 使用示例:

ArrayHandler handler = new ArrayHandler();
int[] intArray = {1, 2, 3};
int[] clonedInt = (int[]) handler.clone(intArray, cloner, context);

String[] strArray = {"a", "b", "c"};
String[] clonedStr = (String[]) handler.clone(strArray, cloner, context);

Features | 主要功能:

  • Primitive array direct copy - 基本类型数组直接复制
  • Object array recursive deep clone - 对象数组递归深度克隆
  • Preserves array component type - 保留数组组件类型

Security | 安全性:

  • Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
Since:
JDK 25, opencode-base-deepclone V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • ArrayHandler

      public ArrayHandler()
  • Method Details

    • clone

      public Object clone(Object array, Cloner cloner, CloneContext context)
      Description copied from interface: TypeHandler
      Clones the object 克隆对象
      Specified by:
      clone in interface TypeHandler<Object>
      Parameters:
      array - the original object | 原始对象
      cloner - the cloner for recursive cloning | 用于递归克隆的克隆器
      context - the clone context | 克隆上下文
      Returns:
      the cloned object | 克隆的对象
    • clonePrimitiveArray

      public Object clonePrimitiveArray(Object array, Class<?> componentType, int length)
      Clones a primitive type array 克隆基本类型数组
      Parameters:
      array - the original array | 原始数组
      componentType - the component type | 组件类型
      length - the array length | 数组长度
      Returns:
      the cloned array | 克隆的数组
    • clonePrimitiveArray

      public Object clonePrimitiveArray(Object array)
      Clones a primitive array (convenience method) 克隆基本类型数组(便捷方法)
      Parameters:
      array - the original array | 原始数组
      Returns:
      the cloned array | 克隆的数组
    • cloneObjectArray

      public <T> T[] cloneObjectArray(T[] array, Cloner cloner, CloneContext context)
      Clones an object array 克隆对象数组
      Type Parameters:
      T - the element type | 元素类型
      Parameters:
      array - the original array | 原始数组
      cloner - the cloner | 克隆器
      context - the context | 上下文
      Returns:
      the cloned array | 克隆的数组
    • supports

      public boolean supports(Class<?> type)
      Description copied from interface: TypeHandler
      Checks if this handler supports the given type 检查此处理器是否支持给定类型
      Specified by:
      supports in interface TypeHandler<Object>
      Parameters:
      type - the type to check | 要检查的类型
      Returns:
      true if supported | 如果支持返回true
    • priority

      public int priority()
      Description copied from interface: TypeHandler
      Gets the priority of this handler 获取此处理器的优先级

      Lower values indicate higher priority. Default is 100.

      较小的值表示较高的优先级。默认值为100。

      Specified by:
      priority in interface TypeHandler<Object>
      Returns:
      the priority | 优先级