net.sf.beanlib.hibernate
Class HibernateBeanReplicator

java.lang.Object
  extended by net.sf.beanlib.hibernate.HibernateBeanReplicator
Direct Known Subclasses:
Hibernate3BeanReplicator

public class HibernateBeanReplicator
extends Object

Hibernate Bean Replicator. Not thread safe.

Author:
Joe D. Velopar

Field Summary
private  BeanPopulatable beanPopulatable
           
private  Set<? extends CollectionPropertyName> collectionPropertyNameSet
           
private  Set<Class> entityBeanClassSet
           
private  BeanTransformerSpi hibernateBeanTransformer
           
private  BeanPopulatable vetoer
           
 
Constructor Summary
HibernateBeanReplicator(BeanTransformerSpi hibernateBeanTransformer)
           
 
Method Summary
<T> T
copy(Object from, Class<T> toClass)
          Returns an instance of the given class with values copied from the given object.
<T> T
copy(T from)
          Returns a copy of the given object.
<T> T
deepCopy(Object from, Class<T> toClass)
          Convenient method to deep copy the given object to an instance of the given class using the default behavior.
<T> T
deepCopy(T from)
          Convenient method to deep copy the given object using the default behavior.
 BeanPopulatable getBeanPopulatable()
           
 Set getCollectionPropertyNameSet()
           
 Set getEntityBeanClassSet()
           
 BeanPopulatable getVetoer()
           
 HibernateBeanReplicator initBeanPopulatable(BeanPopulatable beanPopulatable)
           
 HibernateBeanReplicator initBeanSourceHandler(BeanSourceHandler beanSourceHandler)
           
 HibernateBeanReplicator initCollectionPropertyNameSet(Set<? extends CollectionPropertyName> collectionPropertyNameSet)
          Used to specify the set of Collection fields to be populated.
 HibernateBeanReplicator initCustomTransformer(CustomBeanTransformerSpi.Factory customTransformerFactory)
           
 HibernateBeanReplicator initDebug(boolean debug)
           
 HibernateBeanReplicator initDetailedBeanPopulatable(DetailedBeanPopulatable detailedBeanPopulatable)
           
 HibernateBeanReplicator initEntityBeanClassSet(Set<Class> entityBeanClassSet)
          Used to specify the set of entity beans to be populated.
 HibernateBeanReplicator initSetterMethodCollector(BeanMethodCollector setterMethodFinder)
           
 HibernateBeanReplicator initVetoer(BeanPopulatable vetoer)
           
private  void setDefaultBehavior()
           
 HibernateBeanReplicator setReaderMethodFinder(BeanMethodFinder readerMethodFinder)
           
<T> T
shallowCopy(Object from, Class<T> toClass)
          Convenient method to shallow copy the given object to an instance of the given class using the default behavior.
<T> T
shallowCopy(T from)
          Convenient method to shallow copy the given object using the default behavior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hibernateBeanTransformer

private final BeanTransformerSpi hibernateBeanTransformer

entityBeanClassSet

private Set<Class> entityBeanClassSet

collectionPropertyNameSet

private Set<? extends CollectionPropertyName> collectionPropertyNameSet

beanPopulatable

private BeanPopulatable beanPopulatable

vetoer

private BeanPopulatable vetoer
Constructor Detail

HibernateBeanReplicator

public HibernateBeanReplicator(BeanTransformerSpi hibernateBeanTransformer)
Method Detail

copy

public final <T> T copy(T from)
Returns a copy of the given object.

Type Parameters:
T - type of the given object.
Parameters:
from - given object.

copy

public final <T> T copy(Object from,
                        Class<T> toClass)
Returns an instance of the given class with values copied from the given object.

Type Parameters:
T - type of the given object.
Parameters:
from - given object.
toClass - target class of the returned object.

deepCopy

public final <T> T deepCopy(T from)
Convenient method to deep copy the given object using the default behavior. Do not use this method if you want to plug in a different DetailedBeanPopulatable or BeanMethodCollector.

Type Parameters:
T - from object type.
Parameters:
from - given object to be copied.
Returns:
a deep clone of the from object.

deepCopy

public final <T> T deepCopy(Object from,
                            Class<T> toClass)
Convenient method to deep copy the given object to an instance of the given class using the default behavior. Do not use this method if you want to plug in a different DetailedBeanPopulatable or BeanMethodCollector.

Type Parameters:
T - to object type.
Parameters:
from - given object to be copied.
toClass - target class of the returned object.
Returns:
an instance of the given class with values deeply copied from the given object.

shallowCopy

public final <T> T shallowCopy(T from)
Convenient method to shallow copy the given object using the default behavior. Do not use this method if you want to plug in a different DetailedBeanPopulatable or BeanMethodCollector.

Type Parameters:
T - from object type.
Parameters:
from - given object to be copied.
Returns:
a shallow clone of the from object.

shallowCopy

public final <T> T shallowCopy(Object from,
                               Class<T> toClass)
Convenient method to shallow copy the given object to an instance of the given class using the default behavior. Do not use this method if you want to plug in a different DetailedBeanPopulatable or BeanMethodCollector.

Type Parameters:
T - to object type.
Parameters:
from - given object to be copied.
Returns:
an instance of the given class with values shallow copied from the given object.

setDefaultBehavior

private void setDefaultBehavior()

getBeanPopulatable

public final BeanPopulatable getBeanPopulatable()

initBeanPopulatable

public final HibernateBeanReplicator initBeanPopulatable(BeanPopulatable beanPopulatable)

initCustomTransformer

public final HibernateBeanReplicator initCustomTransformer(CustomBeanTransformerSpi.Factory customTransformerFactory)

initBeanSourceHandler

public final HibernateBeanReplicator initBeanSourceHandler(BeanSourceHandler beanSourceHandler)

initDebug

public final HibernateBeanReplicator initDebug(boolean debug)

initDetailedBeanPopulatable

public final HibernateBeanReplicator initDetailedBeanPopulatable(DetailedBeanPopulatable detailedBeanPopulatable)

getEntityBeanClassSet

public final Set getEntityBeanClassSet()

initEntityBeanClassSet

public final HibernateBeanReplicator initEntityBeanClassSet(Set<Class> entityBeanClassSet)
Used to specify the set of entity beans to be populated.

Parameters:
entityBeanClassSet - the set of entity beans to be populated; or null if all entity bean are to be populated.
Returns:
the current HibernateBeanReplicator instance for command chaining.

getCollectionPropertyNameSet

public final Set getCollectionPropertyNameSet()

initCollectionPropertyNameSet

public final HibernateBeanReplicator initCollectionPropertyNameSet(Set<? extends CollectionPropertyName> collectionPropertyNameSet)
Used to specify the set of Collection fields to be populated.

Parameters:
collectionPropertyNameSet - the set of Collection fields to be populated; or null if all Collection fields are to be populated.
Returns:
the current HibernateBeanReplicator instance for command chaining.

getVetoer

public final BeanPopulatable getVetoer()

initVetoer

public final HibernateBeanReplicator initVetoer(BeanPopulatable vetoer)

setReaderMethodFinder

public final HibernateBeanReplicator setReaderMethodFinder(BeanMethodFinder readerMethodFinder)

initSetterMethodCollector

public final HibernateBeanReplicator initSetterMethodCollector(BeanMethodCollector setterMethodFinder)