• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

JavaBean to JavaBean mapper tool/Utility

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Java Gurus,
I was given the task of creating a java code generator/w GUI that will
mapped attributes from 1 object to another object and generate the source of
that said mapping.

For example
Class A{
String a;
String b;
String c;
getter/setter are provided
}

Class B{
String b1;
String b2;
getter/setter are provided
}
From the wizard, just think of it a object tree in 2 panels with drag n drop capability, wherein the developer, will drag and attribute
to corresponding attribute of the other object. When finish, the genereted code will look something like this : supposing i drag, a and b attribute
of A class to b1 attribute and b2 attribute of B class correspondingly

AtoB.java
public class AtoB{
public B assign( A a){
B b = new B();
b.setB1 (a.getA());
b.setB2( a.getB());
}
}

This is pretty straight forward isn't it? Thats what i thought also,
But when i consider the different constraints like
1. What if A as a subclass C which has a subclass and so on and so forth
2. What if B as a subclass C which has a subclass and so on and so forth
3. What if A has an attribute which is an array?
4. What if A has an attribute which has a subclass and also an array.

and so on and so forth.

I just opened a pandora's box!

My question is, is there any utility /tools (both open source and commercial) that works in similar fashion available? Or perhaps
an approach to dealing with this kind of dilemma.

Any help will be greatly appreciated

Ajing
reply
    Bookmark Topic Watch Topic
  • New Topic