if I have a field of a type that has no empty constructor how do I go about doing a copy or deepCopy without access to the fields source,
e.g.
public class A {
private com.vividsolutions.jts.geom.Point point;
}
The class Point has no empty constructor, I do not have the source to add a constructor, how do I proceed? I cannot wrap Point with my own class as the source for the objects that contain Point are generated by an external system and passed on to me to use.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, this can be done with a custom bean transformer (CustomBeanTransformerSpi) when you instantiate and initialize a BeanReplicator. Will give you an example later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if I have a field of a type that has no empty constructor how do I go about doing a copy or deepCopy without access to the fields source,
e.g.
public class A {
private com.vividsolutions.jts.geom.Point point;
}
The class Point has no empty constructor, I do not have the source to add a constructor, how do I proceed? I cannot wrap Point with my own class as the source for the objects that contain Point are generated by an external system and passed on to me to use.
Yes, this can be done with a custom bean transformer (CustomBeanTransformerSpi) when you instantiate and initialize a BeanReplicator. Will give you an example later.
See some sample code of how this can be done via a custom transformer:
http://beanlib.svn.sourceforge.net/viewvc/beanlib/trunk/beanlib-test/src/net/sf/beanlib/spi/
Or,
http://beanlib.svn.sourceforge.net/viewvc/beanlib/trunk/beanlib-test/src/net/sf/beanlib/spi/BeanTransformerSpiTest.java?revision=235&view=markup
http://beanlib.svn.sourceforge.net/viewvc/beanlib/trunk/beanlib-test/src/net/sf/beanlib/spi/A.java?view=markup
http://beanlib.svn.sourceforge.net/viewvc/beanlib/trunk/beanlib-test/src/net/sf/beanlib/spi/Point.java?revision=235&view=markup
Also copied to google group:
http://groups.google.com/group/beanlib/browse_thread/thread/585820ebd1bb12dd/f9c2c96f22b38126#f9c2c96f22b38126
thanks for the info, i'll give it a try, if you don't hear from me it worked :)