I've an entity class that the user will construct the object using the setters. This object when passed to another layer, that layer will call the constructChangeDataMap()
method to identify the variables that must be updated in another framework.
Class Test {
private int a;
private int b;
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public Map<String, int> constructChangeDataMap() {
// check what values has been modified and construct the map
}
}
What am doing now-
To find the updated entities I'd have to have a boolean variable and when the setter is called, this boolean will be updated and when the construtctMap method is called, I'll put only the updated values in the map. However this doesn't feel right. Is there any other pattern or way to figure out the updated variable.