/** * Returns 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 is <code>null * </code> then the outcome will be based on the value of the <code>ignoreNull</code> attribute. * By default, <code>ignoreNull</code> is <code>false</code> and would result in an <code> * IllegalArgumentException</code> if an object in the property path leading up to the target * property is <code>null</code>. * * @param object The object to be transformed. * @return The value of the property named in the transformer's constructor for the object * provided. * @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 <code>null</code> and <code> * ignoreNull</code> is set to <code>false</code>. */ public Object transform(Object object) { Object propertyValue = null; try { propertyValue = PropertyUtils.getProperty(object, propertyName); } catch (IllegalArgumentException e) { final String errorMsg = "Problem during transformation. Null value encountered in property path..."; if (ignoreNull) { log.warn("WARNING: " + errorMsg + e); } else { IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } } catch (IllegalAccessException e) { final String errorMsg = "Unable to access the property provided."; IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } catch (InvocationTargetException e) { final String errorMsg = "Exception occurred in property's getter"; IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } catch (NoSuchMethodException e) { final String errorMsg = "No property found for name [" + propertyName + "]"; IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } return propertyValue; }