How about the reflection variant? You won't need to edit any of the target code.
Gary On Sun, Jul 9, 2023, 09:51 Gilles Sadowski <gillese...@gmail.com> wrote: > Hi. > > In the Javadoc of the "DiffBuilder" class[1]: > ---CUT--- > [...] > To use this class, write code as follows: > > public class Person implements Diffable<Person> { > String name; > int age; > boolean smoker; > [...] > ---CUT--- > > However, a common use-case would be that we can't directly > modify the class whose instances we want to compare. > Assuming that interfaces are given and non-modifiable (i.e. > they cannot implement "Diffable"): > ---CUT--- > public interface Content { > double getValue(); > } > > public interface Container { > Content[] getContentArray(); > } > ---CUT--- > and the modifiable user code is similar to > ---CUT--- > public class MyContent implements Content { > private final double c; > > public MyContent(double input) { > c = input: > } > > @Override > public double getValue() { > return c; > } > } > > public class MyContainer implements Container { > private final Content[] contentArr; > > MyContainer(double ... inputs) { > final int len = inputs.length; > contentArr = new Content[len]; > for (int i = 0; i < len; i++) { > contentArr[i] = new MyContent(inputs[i]); > } > } > > @Override > public Content[] getContentArray() { > return contentArr; > } > } > ---CUT--- > how should I go about in order to get the "diff" between instances > of "MyContainer"? > > Thanks, > Gilles > > [1] > https://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/builder/DiffBuilder.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > >