Well, of course you can just Foo myFoo = (Foo) theirFoo.clone(); to copy an object.
But I want to create an ExtendedFoo out of a Foo. I can't cast the foo (or cloned foo) into an ExtendedFoo because it's not one. I need to create a new ExtendedFoo and copy all of the important stuff from the "foo" object into the "extendedFoo" object. Here's how I did it:
import org.apache.commons.beanutils.BeanUtils;
public class ExtendedFoo extends Foo {
public ExtendedFoo(Foo source) throws IllegalAccessException, InvocationTargetException {
BeanUtils.copyProperties(this, source);
}
...
}
Isn't that easy?
No Comments/Pingbacks for this post yet...
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |