• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any good design patterns for updating an Object based using fields from other Objects  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My application receives 3 object types. These are basic pojos A, B and C.
Each time I recieve A, B or C object I use it to update the values in another pojo type Z.

The setters and getters in both A, B & C match the getters and setters in type Z.

Is there any way to easier way to update Z using some design pattern?

i.e. I'd prefer not the do this for each update:
Z.setValue1(A.getValue1());
Z.setValue2(A.getValue2());

Someone mentioned the Visitor pattern but I'd need an example on how this could be used.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Observer Pattern?
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dar Var wrote:
i.e. I'd prefer not the do this for each update:
Z.setValue1(A.getValue1());
Z.setValue2(A.getValue2());


Why not? Somehow you will have to get the values from one object and set them on the other, right?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!