class Foo(){
private String x,y;
//getters setters
}
main(){
Foo bar1 = new Foo();
Foo bar2 = new Foo();
bar1.setX("hey");
bar2.setX("hi");
bar2.setY(" there");
setNewValuesFromLeftToRight(bar1,bar2);//left:bar1
System.out.print(bar2.getX+bar2.getY)// hey there
}
setNewValuesFromLeftToRight : this method would get any 2 object with the same class and set field values of bar2 using field values,that are not null,of bar1
What is the best way to write the method setNewValuesFromLeftToRight ? sure it should be generic solution.
Will I use the Reflections?