olg.csv.bean.impl
Class AbstractPropertyProcessor<B>

Package class diagram package AbstractPropertyProcessor
java.lang.Object
  extended by olg.csv.bean.impl.AbstractPropertyProcessor<B>
Type Parameters:
B - dedicated bean the Propertytransformer deals with
All Implemented Interfaces:
IPropertyProcessor<B>
Direct Known Subclasses:
ComplexPropertyProcessor, PropertyProcessor

public abstract class AbstractPropertyProcessor<B>
extends Object
implements IPropertyProcessor<B>

In reading process, Class responsible of bean properties instantiation from list of Strings. This class seems to be the same as BeanProcessor class. But its motivation is different : We want to instantiate a characteristic of a bean while Transformer allows to product bean completed with its properties set by PropertyTransformers


Field Summary
protected  Class<B> beanClass
          The class of the bean this transformer deals with.
protected  Method method
          the method used to set the property of a <B> bean.
 
Constructor Summary
AbstractPropertyProcessor()
           
 
Method Summary
 Class<B> getBeanClass()
          Returns the class of the bean this transformer deals with.
static
<T,P> IPropertyProcessor<T>
getComplexPropertyTransformer(IBeanProcessor<P> transformer, Class<T> beanClass, String propertyName)
          Returns a property processor which set a property of a bean with the help of a transformer.
static
<T,X> IPropertyProcessor<T>
getSimplePropertyTransformer(AbstractGetter getter, AbstractParser<X> parser, String propertyName, Class<T> clazz)
          Returns a simple property processor which set a property of bean with the help of a getter and a parser.
protected  B invoke(Object field, B bean)
          allows to set field of a bean.
abstract  B transform(Row line, B bean)
          Returns the bean after this transformer sets its property from a row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beanClass

protected Class<B> beanClass
The class of the bean this transformer deals with.


method

protected Method method
the method used to set the property of a <B> bean.

Constructor Detail

AbstractPropertyProcessor

public AbstractPropertyProcessor()
Method Detail

getBeanClass

public final Class<B> getBeanClass()
Returns the class of the bean this transformer deals with.

Returns:
the bean class.

transform

public abstract B transform(Row line,
                            B bean)
Description copied from interface: IPropertyProcessor
Returns the bean after this transformer sets its property from a row.

Specified by:
transform in interface IPropertyProcessor<B>
Parameters:
line - the row. list of strings which represents the property of the bean
bean - the bean this transformer set property (or properties).
Returns:
the given bean.If the given bean is null a new instance is created and returned.

invoke

protected final B invoke(Object field,
                         B bean)
allows to set field of a bean.

Parameters:
field - the value of the field
bean - the bean to set its field
Returns:
the bean, if B argument is null return a new bean with its field setted.

getSimplePropertyTransformer

public static final <T,X> IPropertyProcessor<T> getSimplePropertyTransformer(AbstractGetter getter,
                                                                             AbstractParser<X> parser,
                                                                             String propertyName,
                                                                             Class<T> clazz)
Returns a simple property processor which set a property of bean with the help of a getter and a parser. Typically the case when a property matches a string from a list of Strings.

Type Parameters:
T - the bean type
X - the property type
Parameters:
getter - the getter. Allows to extract a sting corresponding to the property to set. Must be not null.
parser - the parser. Allows to instantiate the property from a String. Must be not null.
propertyName - the name of the property to set. Must be not null .
clazz - the bean class. Must be not null.
Returns:
new instance of an basic property processor.
See Also:
transform(Row, Object)

getComplexPropertyTransformer

public static final <T,P> IPropertyProcessor<T> getComplexPropertyTransformer(IBeanProcessor<P> transformer,
                                                                              Class<T> beanClass,
                                                                              String propertyName)
Returns a property processor which set a property of a bean with the help of a transformer. Typically the case where we instanciate a bean from a list of Strings we want to set as a property of our final bean

Type Parameters:
T - the bean type
P - th property type
Parameters:
transformer - the transformer which products the value of the property to set. Must not be null.
beanClass - the class of the bean to return. Must not be null .
propertyName - the name of the property to set. Must not be null .
Returns:
new instance


Copyright © 2014. All Rights Reserved.