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

Instance, or List of Instances, of a Class inside a Class - Creating Diff

Open RA-AlexRees opened this issue 7 years ago • 2 comments

Hi there, I have a class which has instances of other classes declared inside. An example is below:

public class Person {

public int personID;
public String personName;
public String personCode;
public Transports transports;
public Categories categories;
public List<Insurance> insurance;

}

Transports, Categories & Insurance, are an instances, or list of instances, of a class, which can include another class inside, if that makes sense?

What I would like to have done is get the difference between 2 Person classes, whilst going in to the nested classes and only returning the difference.

I hope this makes sense!

Thanks, Alex

RA-AlexRees avatar Jan 29 '18 13:01 RA-AlexRees

I also have a similar requirement. Have you found a way to get it working? Without a way to find out exact difference in a particular property of 'Insurance' in the above example, the java object comparison isn't useful for me.

nitin-b avatar Jul 19 '18 13:07 nitin-b

This feature is supported. but you should implement the interface: de.danielbechler.diff.identity.IdentityStrategy

jianhong-li avatar Oct 17 '19 13:10 jianhong-li