You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to compare two objects(of type Sample2) which have one list member of a custom object(of type sample). I wrote custom comparator for Sample class but javers code never hits the custom comparator.
For eg:
public class Sample {
private String one;
private final int two;
public Sample(String one, int two) {
this.one = one;
this.two = two;
}
}
public class Sample2 {
String id;
private List sample;
public Sample2(String id, List sample) {
this.id = id;
this.sample = sample;
}
}
CustomComparator:
public class CustomSampleComparator implements CustomPropertyComparator {
public ValueChange compare(Sample left, Sample right, GlobalId affectedId, Property property) {
System.out.println("Comparator called...");
return new ValueChange(affectedId, "testing", 3, 6);
}
}
Main class:
public class App {
public static void main(String[] args) {
Sample type1 = new Sample("34", 54);
Sample type2 = new Sample("55", 89);
List samples1 = new ArrayList();
samples1.add(type1);
samples1.add(type2);
Sample type3 = new Sample("34", 4);
Sample type4 = new Sample("55", 9);
List samples2 = new ArrayList();
samples2.add(type3);
samples2.add(type4);
Sample2 sam = new Sample2("1", samples1);
Sample2 sam2 = new Sample2("1", samples2);
Javers javers =
JaversBuilder.javers().registerCustomComparator(new CustomSampleComparator(), Sample.class)
.build();
Diff diff = javers.compare(sam, sam2);
System.out.println(diff.prettyPrint());
System.out.println("Hello World!");
}
}
Problem: My custom comparator is never bieng hit.
The text was updated successfully, but these errors were encountered:
For now, CustomPropertyComparator compares only property values and not items inside collections. We need to check if it possible to use it as a collections Comparator.
Hi
I want to compare two objects(of type Sample2) which have one list member of a custom object(of type sample). I wrote custom comparator for Sample class but javers code never hits the custom comparator.
For eg:
CustomComparator:
Main class:
Problem: My custom comparator is never bieng hit.
The text was updated successfully, but these errors were encountered: