1 /*****************************************************************************
5 * Creation date 05.10.2012
8 *****************************************************************************/
10 package org.splat.util;
12 import net.sf.beanlib.provider.BeanTransformer;
13 import net.sf.beanlib.provider.replicator.BeanReplicator;
16 * Helper class for beans. This class supplies : - methods to copy bean to an other bean
18 * @author Maria KRUCHININA
21 public final class BeanHelper {
24 * private constructor to make it abstract.
26 private BeanHelper() {
31 * copy a bean to a bean.
40 * the destination class
41 * @return an instance of the destination class
43 public static <T, D> D copyBean(final T from, final Class<D> clazz) {
49 BeanTransformer bt = new BeanTransformer(
50 new TimestampTransformerFactory(),
51 new DTOTransformerFactory());
52 // Don't check parameter types of getters and setters.
53 // Find them just by property name.
54 bt.initDetailedPropertyFilter(null);
56 BeanReplicator bp = new BeanReplicator(bt);
57 result = bp.replicateBean(from, clazz);