net.sf.beanlib.provider.replicator
Class BeanReplicator

java.lang.Object
  extended by net.sf.beanlib.provider.replicator.ReplicatorTemplate
      extended by net.sf.beanlib.provider.replicator.BeanReplicator
All Implemented Interfaces:
BeanReplicatorSpi
Direct Known Subclasses:
Hibernate3JavaBeanReplicator

public class BeanReplicator
extends ReplicatorTemplate
implements BeanReplicatorSpi

Default implementation of BeanReplicatorSpi.

Author:
Joe D. Velopar

Nested Class Summary
private static class BeanReplicator.Factory
          Factory for BeanReplicator
 
Field Summary
private static BeanReplicator.Factory factory
           
 
Fields inherited from class net.sf.beanlib.provider.replicator.ReplicatorTemplate
log
 
Constructor Summary
BeanReplicator()
          Convenient constructor to make use of the default BeanTransformer.
BeanReplicator(BeanTransformerSpi beanTransformer)
          Convenient constructor for passing in a bean transformer.
 
Method Summary
static BeanReplicator newBeanReplicatable()
          Convenient factory method to use the default BeanTransformer.
static BeanReplicator newBeanReplicatable(BeanTransformerSpi beanTransformer)
           
<V> V
replicateBean(V from)
          Replicates a given JavaBean object.
<V,T> T
replicateBean(V from, Class<T> toClass)
          Replicates the properties of a JavaBean object to an instance of a target class, which is selected from the given "from" and "to" classes, giving priority to the one which is more specific whenever possible.
protected
<V,T> T
replicateBean(V from, Class<T> toClass, V originalFrom)
          Replicates the properties of a JavaBean object to an instance of a target class, which is selected from the given "from" and "to" classes, giving priority to the one which is more specific whenever possible.
 
Methods inherited from class net.sf.beanlib.provider.replicator.ReplicatorTemplate
chooseClass, createToInstance, createToInstance, createToInstanceWithComparator, getTargetCloned, newInstanceAsPrivileged, populateBean, putTargetCloned, replicate, replicate, replicateByBeanReplicatable, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private static final BeanReplicator.Factory factory
Constructor Detail

BeanReplicator

public BeanReplicator(BeanTransformerSpi beanTransformer)
Convenient constructor for passing in a bean transformer.


BeanReplicator

public BeanReplicator()
Convenient constructor to make use of the default BeanTransformer.

Method Detail

newBeanReplicatable

public static BeanReplicator newBeanReplicatable(BeanTransformerSpi beanTransformer)

newBeanReplicatable

public static BeanReplicator newBeanReplicatable()
Convenient factory method to use the default BeanTransformer.


replicateBean

public <V> V replicateBean(V from)
Replicates a given JavaBean object.

Type Parameters:
V - from type
Parameters:
from - from bean to be replicated.

replicateBean

public <V,T> T replicateBean(V from,
                             Class<T> toClass)
Replicates the properties of a JavaBean object to an instance of a target class, which is selected from the given "from" and "to" classes, giving priority to the one which is more specific whenever possible.

Specified by:
replicateBean in interface BeanReplicatorSpi
Type Parameters:
V - from type
T - target type
Parameters:
from - from bean (after unenhancement) to be replicated
toClass - target class to be instantiated

replicateBean

protected <V,T> T replicateBean(V from,
                                Class<T> toClass,
                                V originalFrom)
Replicates the properties of a JavaBean object to an instance of a target class, which is selected from the given "from" and "to" classes, giving priority to the one which is more specific whenever possible.

Type Parameters:
V - from type
T - target type
Parameters:
from - from bean (after unenhancement) to be replicated
toClass - target class to be instantiated
originalFrom - the original from bean before any "unehancement"
Returns:
an instance of the replicated bean