Coverage Report - org.mule.config.parsers.OutboundHeadersAnnotationParser
 
Classes in this File Line Coverage Branch Coverage Complexity
OutboundHeadersAnnotationParser
0%
0/8
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: OutboundHeadersAnnotationParser.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.parsers;
 11  
 
 12  
 import org.mule.api.annotations.meta.Evaluator;
 13  
 import org.mule.api.annotations.param.OutboundHeaders;
 14  
 import org.mule.api.expression.ExpressionAnnotationParser;
 15  
 import org.mule.expression.ExpressionConfig;
 16  
 import org.mule.expression.transformers.ExpressionArgument;
 17  
 
 18  
 import java.lang.annotation.Annotation;
 19  
 import java.util.Map;
 20  
 
 21  
 /**
 22  
  * Responsible for parsing the {@link org.mule.api.annotations.param.OutboundHeaders} annotation.  This is an iBeans
 23  
  * framework class and cannot be used in any other context.
 24  
  */
 25  0
 public class OutboundHeadersAnnotationParser implements ExpressionAnnotationParser
 26  
 {
 27  
     public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
 28  
     {
 29  0
         if(!Map.class.isAssignableFrom(parameterType))
 30  
         {
 31  0
             throw new IllegalArgumentException("The @OutboundHeaders annotation can only be set on a java.util.Map parameter");
 32  
         }
 33  0
         Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
 34  0
         if (evaluator != null)
 35  
         {
 36  0
             return new ExpressionArgument(null, new ExpressionConfig("", evaluator.value(), null), false);
 37  
         }
 38  
         else
 39  
         {
 40  0
             throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation");
 41  
         }
 42  
     }
 43  
 
 44  
     public boolean supports(Annotation annotation)
 45  
     {
 46  0
         return annotation instanceof OutboundHeaders;
 47  
     }
 48  
 }