View Javadoc

1   /*
2    * $Id:  $
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.module.json.config;
11  
12  import org.mule.api.annotations.expression.JsonPath;
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   * Responsible for parsing {@link org.mule.api.annotations.expression.JsonPath} parameter annotations
22   */
23  public class JsonPathAnnotationParser implements ExpressionAnnotationParser
24  {
25      public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
26      {
27          Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
28  
29          return new ExpressionArgument(null, new ExpressionConfig(((JsonPath) annotation).value(),
30                  evaluator.value(), null), ((JsonPath) annotation).optional(), parameterType);
31      }
32  
33      public boolean supports(Annotation annotation)
34      {
35          return annotation instanceof JsonPath;
36      }
37  }