I’ve been searching around for an Eclipse plugin or utility that will automatically generate inline code to rougly duplicate the behavior of org.apache.commons.beanutils.BeanUtils.copyProperties().
This seems like something that would be useful for a few scenarios where copyProperties() may not be the best tool for the job; for example if you want to:
– copy all properties except one or a few
– ensure that a compiler error arises if someone changes an important property name in a view object
– have more direct control over how properties are copied
– increase performance by avoiding the reflection/introspection overhead of copyProperties()
In my case, it’s mostly a combination of the first two, as I’m finding it quite tedious to manually type (sometimes) dozens of “object1.setThing(object2.getThing());” statements in many of several dozen EJBs.
In this case, object1 is a model object, and object2 is a VO. In some methods, I want only some properties to be writeable, and in other methods I want all properties to be writable. In the latter case, I can just use the BeanUtils.copyProperties(), but in the former I find that inserting dozens of lines of set(get()) statements to be unnecessarily tedious.
I’m still fairly new to this stuff so perhaps I’m overlooking a pattern which people are already using for this kind of situation?
Any suggestions would be greatly appreciated! 😀
Thanks,
Josef