net.sf.beanlib.hibernate3
Class LazyHibernateCustomBeanTransformer

java.lang.Object
  extended by net.sf.beanlib.hibernate3.LazyHibernateCustomBeanTransformer
All Implemented Interfaces:
CustomBeanTransformerSpi, Transformable

public class LazyHibernateCustomBeanTransformer
extends Object
implements CustomBeanTransformerSpi

A convenient custom bean transformer that can be used to replicate only the initialized properties/associations in a Hibernate object graph.

Sample Usage:

 HibernateBeanReplicator replicator = new Hibernate3BeanReplicator();
 replicator.initCustomTransformerFactory(new LazyHibernateCustomBeanTransformer.Factory());
 replicator.deepCopy(...);
 


Nested Class Summary
static class LazyHibernateCustomBeanTransformer.Factory
          The factory for a LazyHibernateCustomBeanTransformer.
 
Constructor Summary
LazyHibernateCustomBeanTransformer()
           
 
Method Summary
 boolean isTransformable(Object from, Class<?> toClass, PropertyInfo propertyInfo)
          Returns true if the given object is to be transformed by this transformer; false otherwise.
<T> T
transform(Object in, Class<T> toClass, PropertyInfo propertyInfo)
          Returns an object transformed from the input object with the given target class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyHibernateCustomBeanTransformer

public LazyHibernateCustomBeanTransformer()
Method Detail

isTransformable

public boolean isTransformable(Object from,
                               Class<?> toClass,
                               PropertyInfo propertyInfo)
Description copied from interface: CustomBeanTransformerSpi
Returns true if the given object is to be transformed by this transformer; false otherwise.

Specified by:
isTransformable in interface CustomBeanTransformerSpi
Parameters:
from - source object
toClass - target class
propertyInfo - If null, it means the in object is a root level object. Otherwise, propertyInfo contains information about the input object as a java bean property value to be transformed.

transform

public <T> T transform(Object in,
                       Class<T> toClass,
                       PropertyInfo propertyInfo)
Description copied from interface: Transformable
Returns an object transformed from the input object with the given target class.

Specified by:
transform in interface Transformable
Parameters:
in - the input object to be transformed. If propertyInfo is non-null, the input object is a JavaBean property value.
toClass - the target class to be transformed to.
propertyInfo - If null, it means the in object is a root level object. Otherwise, propertyInfo contains information about the input object as a java bean property value to be transformed.
Returns:
the transformed object.