net.sf.gilead.core.beanlib.transformer
Class UnionCustomBeanTransformer

java.lang.Object
  extended by net.sf.gilead.core.beanlib.transformer.UnionCustomBeanTransformer

public class UnionCustomBeanTransformer
extends java.lang.Object

The UnionCustomBeanTransformer hold an array of CustomBeanTransformerSpi, checks if a given instance of a source class if transformable into a destination class iterating over the array of CustomBeanTransformerSpi finding the first appropriate one. Transforms the given instance of the source class into and instance of a destination class iterating over the array of CustomBeanTransformerSpi finding the first appropriate one. This is a copy and paste from http://groups.google.com/group/beanlib/browse_thread/thread/f300b5470c08f683

Author:
Hanson Char

Constructor Summary
UnionCustomBeanTransformer(CustomBeanTransformerSpi... customTransformers)
          Register the array of CustomBeanTransformerSpi used by the class
 
Method Summary
<T> boolean
isTransformable(java.lang.Object from, java.lang.Class<T> toClass, PropertyInfo propertyInfo)
          Iterate over the given array of CustomBeanTransformerSpi, checking if there is a valid transformer to transform the 'from' object, to the target 'toClass'
<T> T
transform(java.lang.Object in, java.lang.Class<T> toClass, PropertyInfo propertyInfo)
          Transforms 'in' object into an instance of class 'toClass', using the first valid transformer in the _customTransformers array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionCustomBeanTransformer

public UnionCustomBeanTransformer(CustomBeanTransformerSpi... customTransformers)
Register the array of CustomBeanTransformerSpi used by the class

Parameters:
customTransformers -
Method Detail

isTransformable

public <T> boolean isTransformable(java.lang.Object from,
                                   java.lang.Class<T> toClass,
                                   PropertyInfo propertyInfo)
Iterate over the given array of CustomBeanTransformerSpi, checking if there is a valid transformer to transform the 'from' object, to the target 'toClass'

Parameters:
from - the source object instance
toClass - the destination class to transform the 'from' object in
Returns:
true if a custom bean transformer was found, false if not

transform

public <T> T transform(java.lang.Object in,
                       java.lang.Class<T> toClass,
                       PropertyInfo propertyInfo)
Transforms 'in' object into an instance of class 'toClass', using the first valid transformer in the _customTransformers array. Returns null if no valid customTransmer is available.

Parameters:
in - the source object to be transformed
toClass - the destination class which the instance will be returned
propertyInfo - the property which will be passed on the to the valid CustomBeanTransformerSpi registered
Returns:
instance of the 'toClass' as a result of a transformation of the 'in' object