Salome HOME
KnowledgeElementDTO is now used in KnowledgeElementFacade. Edit and rename knowledge...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / util / BeanHelper.java
index 167d41701ea497b8d1b2a3ecddce42a8dc5359d3..4e318662bb7b905da54270c22c9828857c0ab1cc 100644 (file)
@@ -7,46 +7,53 @@
  * @version        $Revision$
  *****************************************************************************/
 
-package org.splat.util; 
+package org.splat.util;
 
 import net.sf.beanlib.provider.BeanTransformer;
 import net.sf.beanlib.provider.replicator.BeanReplicator;
-import net.sf.beanlib.spi.BeanTransformerSpi;
-
 
 /**
- * Helper class for beans.
- * This class supplies :
- *             - methods to copy bean to an other bean
+ * Helper class for beans. This class supplies : - methods to copy bean to an other bean
+ * 
  * @author Maria KRUCHININA
- *
+ * 
  */
 public final class BeanHelper {
-       
+
        /**
         * private constructor to make it abstract.
         */
-       private BeanHelper(){
+       private BeanHelper() {
                super();
        }
-       
+
        /**
         * copy a bean to a bean.
-        * @param <T> the original type
-        * @param <D> the target type
-        * @param from the original bean
-        * @param clazz the destination class
+        * 
+        * @param <T>
+        *            the original type
+        * @param <D>
+        *            the target type
+        * @param from
+        *            the original bean
+        * @param clazz
+        *            the destination class
         * @return an instance of the destination class
         */
-       public static <T,D>D copyBean(final T from,final Class <D> clazz) {
+       public static <T, D> D copyBean(final T from, final Class<D> clazz) {
                D result;
-               
-               if(from == null) {
+
+               if (from == null) {
                        result = null;
                } else {
-                       BeanTransformerSpi transformer = new BeanTransformer(new TimestampTransformerFactory());
-                       BeanReplicator bp = new BeanReplicator(transformer);
-
+                       BeanTransformer bt = new BeanTransformer(
+                                       new TimestampTransformerFactory(),
+                                       new DTOTransformerFactory());
+                       // Don't check parameter types of getters and setters. 
+                       // Find them just by property name.
+                       bt.initDetailedPropertyFilter(null);
+                       
+                       BeanReplicator bp = new BeanReplicator(bt);
                        result = bp.replicateBean(from, clazz);
                }
                return result;