1
2
3
4
5
6
7 package org.mule.config.parsers;
8
9 import org.mule.api.annotations.meta.Evaluator;
10 import org.mule.api.annotations.param.Payload;
11 import org.mule.api.expression.ExpressionAnnotationParser;
12 import org.mule.expression.ExpressionConfig;
13 import org.mule.expression.transformers.ExpressionArgument;
14
15 import java.lang.annotation.Annotation;
16
17
18
19
20
21 public class PayloadAnnotationParser implements ExpressionAnnotationParser
22 {
23 public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
24 {
25 Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
26 if (evaluator != null)
27 {
28 return new ExpressionArgument(null, new ExpressionConfig(parameterType.getName(), evaluator.value(), null), false, parameterType);
29 }
30 else
31 {
32 throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation");
33 }
34 }
35
36 public boolean supports(Annotation annotation)
37 {
38 return annotation instanceof Payload;
39 }
40 }