camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-7999: apt add support for @Value
Date Fri, 23 Jan 2015 13:19:03 GMT
CAMEL-7999: apt add support for @Value


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6559fdae
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6559fdae
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6559fdae

Branch: refs/heads/master
Commit: 6559fdae69d30f08774543771e25bea0c7f744c3
Parents: 30d08d1
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jan 23 14:18:14 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jan 23 14:18:14 2015 +0100

----------------------------------------------------------------------
 .../camel/tools/apt/EipAnnotationProcessor.java | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6559fdae/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
index ddfbd99..51e9bb8 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
@@ -39,6 +39,7 @@ import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
 
 import org.apache.camel.spi.Metadata;
 
@@ -231,6 +232,11 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
                     }
                 }
 
+                XmlValue value = fieldElement.getAnnotation(XmlValue.class);
+                if (value != null) {
+                    processValue(roundEnv, originalClassType, classElement, fieldElement,
fieldName, value, eipOptions, prefix);
+                }
+
                 XmlElements elements = fieldElement.getAnnotation(XmlElements.class);
                 if (elements != null) {
                     processElements(roundEnv, classElement, elements, fieldElement, eipOptions,
prefix);
@@ -327,6 +333,29 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
         return false;
     }
 
+    private void processValue(RoundEnvironment roundEnv, TypeElement originalClassType, TypeElement
classElement, VariableElement fieldElement, String fieldName, XmlValue value,
+        Set<EipOption> eipOptions, String prefix) {
+        Elements elementUtils = processingEnv.getElementUtils();
+
+        // XmlValue has no name attribute
+        String name = fieldName;
+
+        name = prefix + name;
+        TypeMirror fieldType = fieldElement.asType();
+        String fieldTypeName = fieldType.toString();
+
+        String defaultValue = findDefaultValue(fieldElement, fieldTypeName);
+        String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, name, classElement,
true);
+        boolean required = true;
+        // metadata may overrule element required
+        required = findRequired(fieldElement, required);
+
+        boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
+
+        EipOption ep = new EipOption(name, "value", fieldTypeName, required, defaultValue,
docComment, deprecated, false, null, false, null);
+        eipOptions.add(ep);
+    }
+
     private void processElement(RoundEnvironment roundEnv, TypeElement classElement, XmlElement
element, VariableElement fieldElement,
                                 Set<EipOption> eipOptions, String prefix) {
         Elements elementUtils = processingEnv.getElementUtils();


Mime
View raw message