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