View Javadoc
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.module.ibeans.annotations;
8   
9   import org.mule.util.StringUtils;
10  
11  import org.ibeans.api.InvocationContext;
12  import org.ibeans.api.ParamFactory;
13  
14  /**
15   * TODO
16   */
17  public class ReversePropertyParamFactory implements ParamFactory
18  {
19      private String propertyName;
20  
21      public ReversePropertyParamFactory(String propertyName)
22      {
23          this.propertyName = propertyName;
24      }
25  
26      public String create(String paramName, boolean optional, InvocationContext invocationContext)
27      {
28          String prop = (String) invocationContext.getIBeanConfig().getPropertyParams().get(propertyName);
29          if (prop == null && !optional)
30          {
31              throw new IllegalArgumentException("PropertyParam value was null for: " + propertyName);
32          }
33          return StringUtils.reverse(prop);
34      }
35  }