如何Entity
使用 JaVers 按 id、属性比较包含对象的两个地图?
我想检测鲍勃在以下情况下将城市从伦敦更改为巴黎:
public void compareMaps() {
Javers javers = JaversBuilder.javers().build();
Map<Integer, Person> a = new HashMap<>();
Map<Integer, Person> b = new HashMap<>();
a.put(Integer.valueOf(1), new Person(1, "Bob", "London"));
b.put(Integer.valueOf(1), new Person(1, "Bob", "London"));
Diff diff = javers.compare(a, b);
assertThat(diff.getChanges()).hasSize(0);
b.get(Integer.valueOf(1)).setCity("Paris");
diff = javers.compare(a, b);
assertThat(diff.getChanges()).hasSize(1);
}
static public class Person {
@Id
int id;
String name;
String city;
@Override
public boolean equals(Object obj) {...}
@Override
public int hashCode() {...}
}