Package: org.apache.groovy.ast.tools

## [Java] Class CopyWithUtils

- org.apache.groovy.ast.tools.CopyWithUtils

-     public final class CopyWithUtils
      extends Object

  Shared AST-generation glue for nested-path `copyWith`, used by both the `@Immutable` and `@RecordType` transforms so the generated code (and its evolution) stays identical across the two.

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static void` | `addCopyWithBlockMethod(ClassNode cNode)` The transactional block overload: `copyWith { name = 'x'; address.city = 'y' }`.
    `` | `public static void` | `addCopyWithIdentityMethod(ClassNode cNode)` Backward-compatibility shim: a no-arg `copyWith()` with its historical semantics (no changes → the same instance).
    `` | `public static Statement` | `nestedFlattenStmt(String mapParamName)` The leading statement of a nested-aware `copyWith(Map)`: `<mapParamName> = NestedCopyWithSupport.flatten(this, <mapParamName>)`.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static void addCopyWithBlockMethod(ClassNode cNode)

      The transactional block overload: `copyWith { name = 'x'; address.city = 'y' }`.

    - #### public static void addCopyWithIdentityMethod(ClassNode cNode)

      Backward-compatibility shim: a no-arg `copyWith()` with its historical semantics (no changes → the same instance). Needed once a `copyWith(Closure)` overload exists, otherwise the historically supported zero-arg call becomes ambiguous.

    - #### public static Statement nestedFlattenStmt(String mapParamName)

      The leading statement of a nested-aware `copyWith(Map)`: `<mapParamName> = NestedCopyWithSupport.flatten(this, <mapParamName>)`. Plain keys pass through unchanged, so flat usage is unaffected.