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