I am comparing two objects (using Javers 3.9.4) which have a structure like below:
MyClass
has a bunch of fields some of which are Objects with Lists.
The list Objects do show changes even when they are the same in both instances of objects.
class MyClass {
String s1;
Services services;
}
class Services {
ServiceS1 serviceS1;
ServiceS2 services2;
}
class ServiceS1 {
String id;
List devicesS1List;
}
class ServiceS1Devices {
String id;
String name;
Date date;
}
I create objects like this
ServiceS1Devices sd1 = new ServiceS1Devices("1", "d1", 1-2);
ServiceS1Devices sd2 = new ServiceS1Devices("2", "d2", 1-2);
List devicesS1List = new ArrayList<>();
devicesS1List.add(sd1);
devicesS1List.add(sd1);
ServiceS1 serviceS1 = new ServiceS1();
serviceS1.setId("ss1");
serviceS1.setDevicesS1List(devicesS1List);
Services services = new Services();
services.setServiceS1(serviceS1);
services.setServiceS2(serviceS2);
MyClass obj1 = new MyClass();
obj1.setS1("1");
obj1.setServices(services);
Create the exactly similar object with only one change like below:
MyClass obj2 = new MyClass();
obj2.setS1("2");
Everything else is the same, the Services
, etc.
Then I do a compare:
Javers javers = JaversBuilder.javers()
.withListCompareAlgorithm(LEVENSHTEIN_DISTANCE)
.build();
Diff diff = javers.compare(obj1, obj2);
It gives me following output:
changes - ListChange:3 ValueChange:1
Value Change 1 is expected, why is it showing as List changed too (not expected in this case)?