Coverage Report - org.mule.config.expression.LookupAnnotationParser
 
Classes in this File Line Coverage Branch Coverage Complexity
LookupAnnotationParser
0%
0/9
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: LookupAnnotationParser.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 package org.mule.config.expression;
 11  
 
 12  
 import org.mule.api.annotations.expressions.Lookup;
 13  
 import org.mule.api.annotations.meta.Evaluator;
 14  
 import org.mule.api.expression.ExpressionAnnotationParser;
 15  
 import org.mule.expression.ExpressionConfig;
 16  
 import org.mule.expression.transformers.ExpressionArgument;
 17  
 import org.mule.util.StringUtils;
 18  
 
 19  
 import java.lang.annotation.Annotation;
 20  
 
 21  
 /**
 22  
  * Used to parse Expr parameter annotations
 23  
  *
 24  
  * @see org.mule.expression.StringExpressionEvaluator
 25  
  * @see org.mule.api.annotations.expressions.Expr
 26  
  *
 27  
  * @since 3.0
 28  
  */
 29  0
 public class LookupAnnotationParser implements ExpressionAnnotationParser
 30  
 {
 31  
     public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
 32  
     {
 33  0
         Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
 34  0
         if (evaluator != null)
 35  
         {
 36  0
             String expression = ((Lookup) annotation).value();
 37  0
             if(StringUtils.isEmpty(expression))
 38  
             {
 39  0
                 expression  = "type:" + parameterType.getName();
 40  
             }
 41  0
             return new ExpressionArgument(null, new ExpressionConfig(expression,
 42  
                     evaluator.value(), null), ((Lookup) annotation).optional(), parameterType);
 43  
         }
 44  
         else
 45  
         {
 46  0
             throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation");
 47  
         }
 48  
 
 49  
     }
 50  
 
 51  
     public boolean supports(Annotation annotation)
 52  
     {
 53  0
         return annotation instanceof Lookup;
 54  
     }
 55  
 }