Coverage Report - org.mule.transformer.simple.GetBeanProperty
 
Classes in this File Line Coverage Branch Coverage Complexity
GetBeanProperty
0%
0/10
N/A
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transformer.simple;
 8  
 
 9  
 import org.mule.api.transformer.TransformerException;
 10  
 import org.mule.transformer.AbstractTransformer;
 11  
 import org.mule.transformer.types.DataTypeFactory;
 12  
 
 13  
 import org.apache.commons.beanutils.PropertyUtils;
 14  
 
 15  
 /**
 16  
  * Looks up a property from a JavaBean using PropertyUtils.getProperty().
 17  
  * Nested properties are valid, assuming they follow JavaBean conventions.
 18  
  * 
 19  
  *   <transformer name="ExtractCustomer" className="org.mule.transformer.simple.GetBeanProperty">
 20  
  *       <properties>
 21  
  *           <property name="propertyName" value="customerRequest.customer" />
 22  
  *       </properties>
 23  
  *   </transformer>
 24  
  */
 25  
 public class GetBeanProperty extends AbstractTransformer
 26  
 {
 27  
     private String propertyName;
 28  
     
 29  
     public GetBeanProperty()
 30  
     {
 31  0
         super();
 32  0
         registerSourceType(DataTypeFactory.OBJECT);
 33  0
         setReturnDataType(DataTypeFactory.OBJECT);
 34  0
     }
 35  
 
 36  
     @Override
 37  
     public Object doTransform(Object src, String encoding) throws TransformerException
 38  
     {
 39  
         try
 40  
         {
 41  0
             return PropertyUtils.getProperty(src, this.propertyName);
 42  
         }
 43  0
         catch (Exception e)
 44  
         {
 45  0
             throw new TransformerException(this, e);
 46  
         }
 47  
     }
 48  
 
 49  
     public String getPropertyName()
 50  
     {
 51  0
         return propertyName;
 52  
     }
 53  
 
 54  
     public void setPropertyName(String propertyName)
 55  
     {
 56  0
         this.propertyName = propertyName;
 57  0
     }
 58  
 
 59  
 }