• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating an object using beanutils  RSS feed

 
Manu Somasekhar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am experimenting with Apache commons beanutils. Now i can copy an entire object using



or I can set any specified instance variable by



The problem i am facing is that I don't have the structure of sourceObject. It can vary at run time. Is there any api in Apache common BeanUtils so that i can make an object same as of sourceObject.

Thanks in advance.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful with this BeanUtil thing, Manu. It's meant to be used in frameworks such as Struts, where a large degree of flexibility is needed to make it useful for wide variety of applications. If you start using BeanUtils directly in regular code, you may be subjecting yourself and others to the dangers of unnecessary complexity. (I know, it's about Ruby but the same principles apply in any language, including Java)

That said, you don't need BeanUtils to make an object that's the same as sourceObject. Java already gives you the ability to create clones (Hint: search for 'clone')
 
Manu Somasekhar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Junilu. I got your point.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!