You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/04/12 07:21:50 UTC

[camel] 01/03: CAMEL-17943: camel-core - Method call expression should not be required

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9dbff625e5730f0068fa99c32c2faee1da6ea525
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 12 08:51:24 2022 +0200

    CAMEL-17943: camel-core - Method call expression should not be required
---
 .../camel/model/language/MethodCallExpression.java | 12 +-----------
 .../camel/maven/packaging/SchemaGeneratorMojo.java | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
index b92a728225c..7cbcb05ef9b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
@@ -23,7 +23,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.spi.Metadata;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 
 /**
@@ -175,18 +174,9 @@ public class MethodCallExpression extends ExpressionDefinition {
         }
     }
 
-    private String beanName() {
-        if (ref != null) {
-            return ref;
-        } else if (instance != null) {
-            return ObjectHelper.className(instance);
-        }
-        return getExpression();
-    }
-
     @Override
     public String toString() {
-        String name = null;
+        String name;
         if (ref != null) {
             name = "ref:" + ref;
         } else if (beanTypeName != null) {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
index 514a0ae0135..5c4d9084ccd 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
@@ -455,15 +455,14 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
     private void processValue(
             Class<?> originalClassType, Class<?> classElement, Field fieldElement,
             String fieldName, Set<EipOptionModel> eipOptions, String prefix, String modelName) {
+
         // XmlValue has no name attribute
         String name = fieldName;
 
-        if ("method".equals(modelName) || "tokenize".equals(modelName) || "xtokenize".equals(modelName)) {
+        if ("expression".equals(name) && !expressionRequired(modelName)) {
             // skip expression attribute on these three languages as they are
             // solely configured using attributes
-            if ("expression".equals(name)) {
-                return;
-            }
+            return;
         }
 
         name = prefix + name;
@@ -949,8 +948,10 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
             }
 
             final String kind = "expression";
-            EipOptionModel ep = createOption(name, displayName, kind, fieldTypeName, true, "", label, docComment, deprecated,
-                    deprecationNote, false, null, oneOfTypes, asPredicate, false);
+            final boolean required = expressionRequired(name);
+            EipOptionModel ep
+                    = createOption(name, displayName, kind, fieldTypeName, required, "", label, docComment, deprecated,
+                            deprecationNote, false, null, oneOfTypes, asPredicate, false);
             eipOptions.add(ep);
         }
     }
@@ -1052,6 +1053,15 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
         return defaultValue;
     }
 
+    private boolean expressionRequired(String modelName) {
+        if ("method".equals(modelName) || "tokenize".equals(modelName) || "xtokenize".equals(modelName)) {
+            // skip expression attribute on these three languages as they are
+            // solely configured using attributes
+            return false;
+        }
+        return true;
+    }
+
     private boolean findRequired(Field fieldElement, boolean defaultValue) {
         Metadata metadata = fieldElement.getAnnotation(Metadata.class);
         if (metadata != null) {