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 2023/06/02 18:06:18 UTC

[camel] branch main updated: (chores) camel-yaml-dsl-common: replacing inner classes with lambda (#10233)

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


The following commit(s) were added to refs/heads/main by this push:
     new 26168a5f8bf (chores) camel-yaml-dsl-common: replacing inner classes with lambda (#10233)
26168a5f8bf is described below

commit 26168a5f8bfa100ef855b67d129601863d4d6394
Author: Gilvan Filho <gi...@gmail.com>
AuthorDate: Fri Jun 2 15:06:10 2023 -0300

    (chores) camel-yaml-dsl-common: replacing inner classes with lambda (#10233)
---
 .../yaml/common/YamlDeserializationContext.java    | 64 +++++++++-------------
 1 file changed, 27 insertions(+), 37 deletions(-)

diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/main/java/org/apache/camel/dsl/yaml/common/YamlDeserializationContext.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/main/java/org/apache/camel/dsl/yaml/common/YamlDeserializationContext.java
index e54e6f7be60..e4882c943b6 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/main/java/org/apache/camel/dsl/yaml/common/YamlDeserializationContext.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/main/java/org/apache/camel/dsl/yaml/common/YamlDeserializationContext.java
@@ -24,7 +24,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.function.Function;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -148,17 +147,14 @@ public class YamlDeserializationContext extends StandardConstructor implements C
 
     public ConstructNode resolve(Class<?> type) {
         return CamelContextAware.trySetCamelContext(
-                new ConstructNode() {
-                    @Override
-                    public Object construct(Node node) {
-                        Node n = YamlSupport.setProperty(
-                                node,
-                                YamlDeserializationContext.class.getName(),
-                                YamlDeserializationContext.this);
-
-                        final ConstructNode answer = resolve(node, type.getName());
-                        return answer.construct(n);
-                    }
+                (Node n) -> {
+                    Node newNode = YamlSupport.setProperty(
+                            n,
+                            YamlDeserializationContext.class.getName(),
+                            YamlDeserializationContext.this);
+
+                    final ConstructNode answer = resolve(n, type.getName());
+                    return answer.construct(newNode);
                 },
                 camelContext);
     }
@@ -193,40 +189,34 @@ public class YamlDeserializationContext extends StandardConstructor implements C
         final ConstructNode answer = resolve(node, id);
 
         return CamelContextAware.trySetCamelContext(
-                new ConstructNode() {
-                    @Override
-                    public Object construct(Node node) {
-                        Node n = YamlSupport.setProperty(
-                                node,
-                                YamlDeserializationContext.class.getName(),
-                                YamlDeserializationContext.this);
-
-                        return answer.construct(
-                                ((MappingNode) n).getValue().get(0).getValueNode());
-                    }
+                (Node n) -> {
+                    YamlSupport.setProperty(
+                            n,
+                            YamlDeserializationContext.class.getName(),
+                            YamlDeserializationContext.this);
+
+                    return answer.construct(
+                            ((MappingNode) n).getValue().get(0).getValueNode());
                 },
                 camelContext);
     }
 
     public ConstructNode resolve(Node node, String id) {
-        return constructors.computeIfAbsent(id, new Function<String, ConstructNode>() {
-            @Override
-            public ConstructNode apply(String s) {
-                ConstructNode answer = null;
-
-                for (YamlDeserializerResolver resolver : resolvers) {
-                    answer = resolver.resolve(id);
-                    if (answer != null) {
-                        break;
-                    }
-                }
+        return constructors.computeIfAbsent(id, (String s) -> {
+            ConstructNode answer = null;
 
-                if (answer == null) {
-                    throw new UnknownNodeIdException(node, id);
+            for (YamlDeserializerResolver resolver : resolvers) {
+                answer = resolver.resolve(id);
+                if (answer != null) {
+                    break;
                 }
+            }
 
-                return answer;
+            if (answer == null) {
+                throw new UnknownNodeIdException(node, id);
             }
+
+            return answer;
         });
     }
 }