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  
  * 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.config.expression;
 8  
 
 9  
 import org.mule.api.annotations.expressions.Lookup;
 10  
 import org.mule.api.annotations.meta.Evaluator;
 11  
 import org.mule.api.expression.ExpressionAnnotationParser;
 12  
 import org.mule.expression.ExpressionConfig;
 13  
 import org.mule.expression.transformers.ExpressionArgument;
 14  
 import org.mule.util.StringUtils;
 15  
 
 16  
 import java.lang.annotation.Annotation;
 17  
 
 18  
 /**
 19  
  * Used to parse Expr parameter annotations
 20  
  *
 21  
  * @see org.mule.expression.StringExpressionEvaluator
 22  
  * @see org.mule.api.annotations.expressions.Expr
 23  
  *
 24  
  * @since 3.0
 25  
  */
 26  0
 public class LookupAnnotationParser implements ExpressionAnnotationParser
 27  
 {
 28  
     public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
 29  
     {
 30  0
         Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
 31  0
         if (evaluator != null)
 32  
         {
 33  0
             String expression = ((Lookup) annotation).value();
 34  0
             if(StringUtils.isEmpty(expression))
 35  
             {
 36  0
                 expression  = "type:" + parameterType.getName();
 37  
             }
 38  0
             return new ExpressionArgument(null, new ExpressionConfig(expression,
 39  
                     evaluator.value(), null), ((Lookup) annotation).optional(), parameterType);
 40  
         }
 41  
         else
 42  
         {
 43  0
             throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation");
 44  
         }
 45  
 
 46  
     }
 47  
 
 48  
     public boolean supports(Annotation annotation)
 49  
     {
 50  0
         return annotation instanceof Lookup;
 51  
     }
 52  
 }