Class NestedCopyWithSupport

java.lang.Object
org.apache.groovy.transform.copywith.NestedCopyWithSupport

@Incubating public final class NestedCopyWithSupport extends Object
Runtime support for nested-path copyWith. Resolves dotted keys such as 'address.city' into a flat map of top-level property to its replacement value, by recursively applying copyWith to the affected nested nodes. Plain (non-dotted) keys pass through unchanged.

A nested node whose type does not provide copyWith(Map) fails with a clear, specific error rather than silent or partial behaviour. Identity is preserved transitively: an unchanged nested node yields its original reference, so an unchanged graph yields the original root.

Since:
6.0.0
  • Method Details

    • applyBlock

      public static Object applyBlock(Object self, Closure<?> block)
      Transactional-block form. Runs block against a recording delegate that captures plain assignments, nested-path navigation, and prop.modify { old -> ... } updates, then delegates to the (nested-aware) copyWith(Map). The block is thus pure sugar over the map form, inheriting its closed-type-domain and identity guarantees.
    • flatten

      public static Map<Object,Object> flatten(Object self, Map<Object,Object> raw)