Class BeanToPropertyValueTransformer<T,R> 
- Type Parameters:
- T- the type of the input to the function
- R- the type of the result of the function
- All Implemented Interfaces:
- Function<T,- R> 
 Transformer that outputs a property value.
 
 An implementation of Function that transforms the object provided by returning the value of a specified property of the object.
 The constructor for BeanToPropertyValueTransformer requires the name of the property that will be used in the transformation. The property can be a
 simple, nested, indexed, or mapped property as defined by org.apache.commons.beanutils2.PropertyUtils. If any object in the property path specified
 by propertyName</code> is <code>null then the
 outcome is based on the value of the ignoreNull attribute.
 
A typical usage might look like:
 // create the transformer
 BeanToPropertyValueTransformer transformer = new BeanToPropertyValueTransformer( "person.address.city" );
 // transform the Collection
 Collection peoplesCities = CollectionUtils.collect( peopleCollection, transformer );
 
 This would take a Collection</code> of person objects and return a <code>Collection of objects which represents the cities in which each person
 lived. Assuming...
 
- The top level object in the peopleCollectionis an object which represents a person.
- The person object has a getAddress()method which returns an object which represents a person's address.
- The address object has a getCity()method which returns an object which represents the city in which a person lives.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionBeanToPropertyValueTransformer(String propertyName) Constructs a Transformer which does not ignore nulls.BeanToPropertyValueTransformer(String propertyName, boolean ignoreNull) Constructs a Transformer and sets ignoreNull.
- 
Method SummaryModifier and TypeMethodDescriptionReturns the value of the property named in the transformer's constructor for the object provided.Returns the name of the property that will be used in the transformation of the bean.booleanReturns the flag which determines whethernullobjects in the property path will generate anIllegalArgumentException</code> or not. If set to <code>truethen if any objects in the property path evaluate tonullthen theIllegalArgumentException</code> throw by <code>PropertyUtilswill be logged but not re-thrown andnull</code> will be returned. If set to <code>falsethen if any objects in the property path evaluate tonullthen theIllegalArgumentException</code> throw by <code>PropertyUtilswill be logged and re-thrown.
- 
Constructor Details- 
BeanToPropertyValueTransformerConstructs a Transformer which does not ignore nulls. Constructor which takes the name of the property that will be used in the transformation and assumesignoreNull</code> to be <code>false.- Parameters:
- propertyName- The name of the property that will be used in the transformation.
- Throws:
- IllegalArgumentException- If the- propertyName</code> is <code>nullor empty.
 
- 
BeanToPropertyValueTransformerConstructs a Transformer and sets ignoreNull. Constructor which takes the name of the property that will be used in the transformation and a boolean which determines whethernullobjects in the property path will generate anIllegalArgumentExceptionor not.- Parameters:
- propertyName- The name of the property that will be used in the transformation.
- ignoreNull- Determines whether- nullobjects in the property path will generate an- IllegalArgumentExceptionor not.
- Throws:
- IllegalArgumentException- If the- propertyName</code> is <code>nullor empty.
 
 
- 
- 
Method Details- 
applyReturns the value of the property named in the transformer's constructor for the object provided. If any object in the property path leading up to the target property isnull</code> then the outcome will be based on the value of the <code>ignoreNullattribute. By default,ignoreNull</code> is <code>falseand would result in anIllegalArgumentExceptionif an object in the property path leading up to the target property isnull. @param object The object to be transformed. @return The value of the property named in the transformer's constructor for the object provided.- Specified by:
- applyin interface- Function<T,- R> 
- Throws:
- IllegalArgumentException- If an IllegalAccessException, InvocationTargetException, or NoSuchMethodException is thrown when trying to access the property specified on the object provided. Or if an object in the property path provided is- nulland- ignoreNull</code> is set to <code>false.
 
- 
getPropertyNameReturns the name of the property that will be used in the transformation of the bean.- Returns:
- The name of the property that will be used in the transformation of the bean.
 
- 
isIgnoreNullReturns the flag which determines whethernullobjects in the property path will generate anIllegalArgumentException</code> or not. If set to <code>truethen if any objects in the property path evaluate tonullthen theIllegalArgumentException</code> throw by <code>PropertyUtilswill be logged but not re-thrown andnull</code> will be returned. If set to <code>falsethen if any objects in the property path evaluate tonullthen theIllegalArgumentException</code> throw by <code>PropertyUtilswill be logged and re-thrown.- Returns:
- The flag which determines whether nullobjects in the property path will generate anIllegalArgumentExceptionor not.
 
 
-