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 2020/03/22 09:07:17 UTC

[camel] 10/13: CAMEL-14762: camel-core - Configurer to include API for method name and type

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

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

commit 718801e44e1548c3a6ba5f5bf2441aa817188a9d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 22 09:46:40 2020 +0100

    CAMEL-14762: camel-core - Configurer to include API for method name and type
---
 .../org/apache/camel/support/PropertyBindingSupport.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 14d698c..457f53f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -366,14 +366,18 @@ public final class PropertyBindingSupport {
         }
 
         // use configurer to get all the current options and its values
+        Map<String, Object> getterAllOption = null;
         if (configurer instanceof PropertyConfigurerGetter) {
             getter = (PropertyConfigurerGetter) configurer;
             final PropertyConfigurerGetter lambdaGetter = getter;
             final Object lambdaTarget = target;
-            // TODO: optimize to only load complex values as these are the only ones we
-            getter.getAllOptions(target).forEach((key, type) -> {
-                Object value = lambdaGetter.getOptionValue(lambdaTarget, key, true);
-                properties.put(key, value);
+            getterAllOption = getter.getAllOptions(target);
+            getterAllOption.forEach((key, type) -> {
+                // we only need the complex types
+                if (isComplexUserType((Class) type)) {
+                    Object value = lambdaGetter.getOptionValue(lambdaTarget, key, true);
+                    properties.put(key, value);
+                }
             });
         } else {
             // okay use reflection based
@@ -399,9 +403,9 @@ public final class PropertyBindingSupport {
             }
 
             Class<?> type;
-            if (getter != null) {
+            if (getterAllOption != null) {
                 // use getter configurer to know the property class type
-                type = (Class<?>) getter.getAllOptions(target).get(key);
+                type = (Class<?>) getterAllOption.get(key);
             } else {
                 // okay fallback to use reflection based
                 type = getGetterType(camelContext, target, key, false);