Newer Java user, finding myself doing something I'd like to do cleaner.
Suppose I have a class that get's updated through a call update(final Parameters params):
@Data // using lombok
class Updatable {
public int x = 0;
public String a = 'hello'
// some ctors/methods
public void update(final Parameters params) {
x = params.getX();
a = params.getA();
}
}
Where there Parameters POJO is simply:
@Value
class Parameters {
int x;
String a;
}
So the fields of the POJO will always (by convention, not contract). Is there a way to avoid calling the getter for each field an simply map the fields of the POJO to the corresponding fields of the class being updated?