1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
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 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
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 | |
} |