You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2019/06/06 07:04:56 UTC
[camel] 03/05: Use fluent builder syntax and move the javadoc on
the fluent method
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch endpoint-dsl
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 66a9c7c74095a3fcb875f9437897673826c0d7af
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jun 6 08:32:27 2019 +0200
Use fluent builder syntax and move the javadoc on the fluent method
---
.../apache/camel/maven/packaging/EndpointDslMojo.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
index 11155cb..14adb80 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
@@ -48,6 +48,7 @@ import org.apache.camel.maven.packaging.model.EndpointOptionModel;
import org.apache.camel.maven.packaging.srcgen.GenericType;
import org.apache.camel.maven.packaging.srcgen.GenericType.BoundType;
import org.apache.camel.maven.packaging.srcgen.JavaClass;
+import org.apache.camel.maven.packaging.srcgen.Method;
import org.apache.camel.maven.packaging.srcgen.Property;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
@@ -211,14 +212,17 @@ public class EndpointDslMojo extends AbstractMojo {
JavaClass commonClass = javaClass.addNestedType().setPublic().setStatic(true);
commonClass.setName(name.replace("Endpoint", "Common"));
commonClass.extendSuperType("EndpointConfiguration");
+ generateDummyClass(commonClass.getCanonicalName());
JavaClass consumerClass = javaClass.addNestedType().setPublic().setStatic(true);
consumerClass.setName(name.replace("Endpoint", "Consumer"));
consumerClass.extendSuperType(name.replace("Endpoint", "Common"));
+ generateDummyClass(consumerClass.getCanonicalName());
JavaClass producerClass = javaClass.addNestedType().setPublic().setStatic(true);
producerClass.setName(name.replace("Endpoint", "Producer"));
producerClass.extendSuperType(name.replace("Endpoint", "Common"));
+ generateDummyClass(producerClass.getCanonicalName());
String doc = "Generated by camel-package-maven-plugin - do not edit this file!";
if (!Strings.isBlank(model.getDescription())) {
@@ -240,21 +244,28 @@ public class EndpointDslMojo extends AbstractMojo {
}
}
+ GenericType ogtype;
GenericType gtype;
try {
Field field = findField(realComponentClass, realEndpointClass, option);
- gtype = new GenericType(GenericsUtil.resolveType(realEndpointClass, field));
- gtype = getType(javaClass, enumClasses, option.getEnums(), gtype.toString());
+ ogtype = new GenericType(GenericsUtil.resolveType(realEndpointClass, field));
+ gtype = getType(javaClass, enumClasses, option.getEnums(), ogtype.toString());
} catch (Exception e) {
throw new RuntimeException(e);
}
Property prop = target.addProperty(gtype, option.getName());
+ Method fluent = target.addMethod().setPublic().setName(option.getName())
+ .setReturnType(new GenericType(loadClass(target.getCanonicalName())))
+ .addParameter(PRIMITIVEMAP.containsKey(ogtype.toString()) ? ogtype : gtype, option.getName())
+ .setBody("this." + option.getName() + " = " + option.getName() + ";\n" +
+ "return (" + target.getName() + ") this;\n");
if ("true".equals(option.getDeprecated())) {
prop.getField().addAnnotation(Deprecated.class);
prop.getAccessor().addAnnotation(Deprecated.class);
prop.getMutator().addAnnotation(Deprecated.class);
+ fluent.addAnnotation(Deprecated.class);
}
if (!Strings.isBlank(option.getDescription())) {
String desc = option.getDescription();
@@ -262,7 +273,7 @@ public class EndpointDslMojo extends AbstractMojo {
desc = desc + ".";
}
desc = desc + " The option is a " + option.getJavaType() + " type.";
- prop.getField().getJavaDoc().setFullText(desc);
+ fluent.getJavaDoc().setFullText(desc);
}
}