java-diff-utils icon indicating copy to clipboard operation
java-diff-utils copied to clipboard

Added ability to apply patch to existing list inplace

Open andre161292 opened this issue 3 years ago • 0 comments

Motivation

I'm using java-diff-utils to update lists in JPA models from a DTOs. As Hibernate uses proxies and records any removal/add/swap, but has it's problems when using clear/addAll, this is the only option to make patching my lists work.

In older versions i accessed AbstractDelta's applyTo directly, but that fell away when it was made hidden in https://github.com/java-diff-utils/java-diff-utils/commit/307574225a45d3995f222e767112eef6741d6af2.

Changes

I added a the methods applyToExisting and it's opposite restoreToExisting to Patch, to make it possible to update lists in-place and updated JavaDoc accordingly.

Minor improvements

I corrected a typo in the method-name verifyAntApplyTo -> verifyAndApplyTo

andre161292 avatar Jul 28 '22 10:07 andre161292