The last time I had similar requirements, I came to the conclusion that manually creating code and tests to confirm that some values ββare being updated is inherently unstable and error prone.
I screened the fields in the bag object and generated the Java source files for both the package class itself and the copier at compile time. Thus, you can test the actual code (generator) and have the actual domain definition in one place, so the copy code cannot be outdated.
The property description language can be anything you prefer, from a JSON schema to XML to Java itself (Java example - user annotations should be used from a generator)
public class MyBag { @Prop public int oh; @Prop public String yeah; }
source share