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

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

commit f65b45a6ca84a1d0d0dd50b44902ac0b73ec93f2
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jan 26 13:09:51 2022 +0100

    CAMEL-17552: camel-core - Switch EIP that can optimize during bootstrap
---
 .../org/apache/camel/catalog/models.properties     |   1 +
 .../org/apache/camel/catalog/models/doSwitch.json  |  20 +++
 .../apache/camel/catalog/schemas/camel-spring.xsd  |  43 +++++++
 .../docs/modules/eips/examples/json/doSwitch.json  |   1 +
 .../src/main/docs/modules/eips/nav.adoc            |   1 +
 .../main/docs/modules/eips/pages/switch-eip.adoc   |  75 +++++++++++
 .../camel/language/simple/SimpleLanguage.java      |  10 +-
 .../services/org/apache/camel/model.properties     |   1 +
 .../resources/org/apache/camel/model/doSwitch.json |  20 +++
 .../resources/org/apache/camel/model/jaxb.index    |   1 +
 .../apache/camel/model/OtherwiseDefinition.java    |   4 +-
 .../apache/camel/model/ProcessorDefinition.java    |  12 ++
 ...erwiseDefinition.java => SwitchDefinition.java} |  34 +----
 .../org/apache/camel/reifier/ProcessorReifier.java |   8 +-
 .../org/apache/camel/reifier/SwitchReifier.java    |  96 ++++++++++++++
 .../apache/camel/model/ChoiceDefinitionTest.java   |   2 +-
 .../org/apache/camel/processor/DoSwitchTest.java   | 143 +++++++++++++++++++++
 .../java/org/apache/camel/xml/in/ModelParser.java  |  16 ++-
 .../dsl/yaml/deserializers/ModelDeserializers.java |  68 ++++++++++
 .../deserializers/ModelDeserializersResolver.java  |   3 +
 .../src/generated/resources/camel-yaml-dsl.json    |  35 +++++
 .../src/generated/resources/camelYamlDsl.json      |  32 +++++
 22 files changed, 587 insertions(+), 39 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
index 13b767f..8453518 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
@@ -41,6 +41,7 @@ description
 dnsServiceDiscovery
 doCatch
 doFinally
+doSwitch
 doTry
 dynamicRouter
 endpoint
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/doSwitch.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/doSwitch.json
new file mode 100644
index 0000000..227e075
--- /dev/null
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/doSwitch.json
@@ -0,0 +1,20 @@
+{
+  "model": {
+    "kind": "model",
+    "name": "doSwitch",
+    "title": "Do Switch",
+    "description": "Route messages based on a series of predicates (optimized 
during startup to select one predicate that will always be used)",
+    "deprecated": false,
+    "label": "eip,routing",
+    "javaType": "org.apache.camel.model.SwitchDefinition",
+    "abstract": false,
+    "input": true,
+    "output": false
+  },
+  "properties": {
+    "when": { "kind": "element", "displayName": "When", "required": false, 
"type": "array", "javaType": 
"java.util.List<org.apache.camel.model.WhenDefinition>", "oneOf": [ "when" ], 
"deprecated": false, "autowired": false, "secret": false, "asPredicate": true },
+    "otherwise": { "kind": "element", "displayName": "Otherwise", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.model.OtherwiseDefinition", "oneOf": [ "otherwise" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the otherwise node" },
+    "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Sets the id of this node" 
},
+    "description": { "kind": "element", "displayName": "Description", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.model.DescriptionDefinition", "deprecated": false, 
"autowired": false, "secret": false, "description": "Sets the description of 
this node" }
+  }
+}
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 631ce4f..65d252f 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -350,6 +350,15 @@ Path traversed when a try, catch, finally block exits
     </xs:annotation>
   </xs:element>
 
+  <xs:element name="doSwitch" type="tns:switchDefinition">
+    <xs:annotation>
+      <xs:documentation xml:lang="en"><![CDATA[
+Route messages based on a series of predicates (optimized during startup to
+select one predicate that will always be used)
+      ]]></xs:documentation>
+    </xs:annotation>
+  </xs:element>
+
   <xs:element name="doTry" type="tns:tryDefinition">
     <xs:annotation>
       <xs:documentation xml:lang="en"><![CDATA[
@@ -3020,6 +3029,7 @@ will fallback to use the fixed value if the Expression 
result was null or 0.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -3499,6 +3509,7 @@ should be intercepted by this exception type or not.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -3598,6 +3609,7 @@ should be intercepted by this exception type or not.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -3685,6 +3697,7 @@ should be intercepted by this exception type or not.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -3764,6 +3777,7 @@ should be intercepted by this exception type or not.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -4836,6 +4850,7 @@ org.apache.camel.spi.SendDynamicAware . Default value: 
true
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -4920,6 +4935,7 @@ Setting this allows to know if the filter predicate 
evaluated as true or false.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5058,6 +5074,7 @@ Global option value.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5236,6 +5253,7 @@ Set if validation is required for this input type. 
Default value: false
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5328,6 +5346,7 @@ configured, then all incoming messages is intercepted.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5427,6 +5446,7 @@ process its result.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5520,6 +5540,7 @@ specified using uri syntax, eg mynamecount=4&type=gold.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -5813,6 +5834,7 @@ To refer to a custom logger instance to lookup from the 
registry.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -8838,6 +8860,7 @@ decompressed size. Default value: 1073741824
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -9047,6 +9070,7 @@ should be invoked or not.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -9214,6 +9238,7 @@ failure. If this option is enabled then its considered 
handled as well.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -9575,6 +9600,7 @@ generate the log message from exchange.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -9711,6 +9737,7 @@ Include finding route builder from these java package 
names.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -9787,6 +9814,7 @@ Include finding route builder from these java package 
names.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -10320,6 +10348,7 @@ Name of property to remove.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -10601,6 +10630,7 @@ Reference to the routes in the xml dsl.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -10996,6 +11026,7 @@ compensation/completion exchange.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -11390,6 +11421,7 @@ Sets a reference to lookup for the comparator to use 
for sorting.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -11607,6 +11639,7 @@ the sake of backward compatibility. Default value: false
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -11633,6 +11666,14 @@ the sake of backward compatibility. Default value: 
false
     </xs:complexContent>
   </xs:complexType>
 
+  <xs:complexType name="switchDefinition">
+    <xs:complexContent>
+      <xs:extension base="tns:choiceDefinition">
+        <xs:sequence/>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
   <xs:complexType name="threadPoolProfileDefinition">
     <xs:complexContent>
       <xs:extension base="tns:optionalIdentifiedDefinition">
@@ -12030,6 +12071,7 @@ Whether to auto startup components when toD is starting 
up. Default value: true
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
@@ -12143,6 +12185,7 @@ Sets a reference to use for lookup the policy in the 
registry.
             <xs:element ref="tns:split"/>
             <xs:element ref="tns:step"/>
             <xs:element ref="tns:stop"/>
+            <xs:element ref="tns:doSwitch"/>
             <xs:element ref="tns:threads"/>
             <xs:element ref="tns:throttle"/>
             <xs:element ref="tns:throwException"/>
diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/examples/json/doSwitch.json 
b/core/camel-core-engine/src/main/docs/modules/eips/examples/json/doSwitch.json
new file mode 120000
index 0000000..b0512c4
--- /dev/null
+++ 
b/core/camel-core-engine/src/main/docs/modules/eips/examples/json/doSwitch.json
@@ -0,0 +1 @@
+../../../../../../../../camel-core-model/src/generated/resources/org/apache/camel/model/doSwitch.json
\ No newline at end of file
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc 
b/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc
index 67a091a..54c5822 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc
@@ -82,6 +82,7 @@
  ** xref:eips:split-eip.adoc[Split]
  ** xref:eips:step-eip.adoc[Step]
  ** xref:eips:stop-eip.adoc[Stop]
+ ** xref:eips:switch-eip.adoc[Switch]
  ** xref:eips:threads-eip.adoc[Threads]
  ** xref:eips:throttle-eip.adoc[Throttle]
  ** xref:eips:to-eip.adoc[To]
diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/switch-eip.adoc 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/switch-eip.adoc
new file mode 100644
index 0000000..c0e7e25
--- /dev/null
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/switch-eip.adoc
@@ -0,0 +1,75 @@
+= Switch EIP
+:doctitle: Switch
+:shortname: doSwitch
+:description: Route messages based on a series of predicates
+:since: 3.15.0
+:supportlevel: Stable
+
+The Switch EIP is an optimized 
http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html[Content
+Based Router] which selects a single branch (when/otherwise) during startup, 
and
+always executes the same branch. This allows to optimize the runtime Camel to 
avoid
+this evaluation process for every message; because they are supposed
+to always be routed on the same branch.
+
+NOTE: Because the Switch EIP evaluates the predicates during startup, then the 
predicates
+cannot be based on the content of the message. Therefore, the predicates would 
often
+be based on property placeholders, JVM system properties, or OS Environment 
variables.
+
+The Switch EIP combined with xref:manual:ROOT:route-template.adoc[Route 
Templates] allows
+for more flexible templates, as the template parameters can be used as the 
predicates in the Switch EIP;
+meaning that the Switch EIP is fully parameterized, but is optimized for best 
runtime performance.
+
+image::eip/ContentBasedRouter.gif[image]
+
+== Switch options
+
+// eip options: START
+include::partial$eip-options.adoc[]
+// eip options: END
+
+== Example
+
+The Camel xref:languages:simple-language.adoc[Simple] language
+is great to use with the Switch EIP to select a specific branch based
+on xref:manual:ROOT:using-propertyplaceholder.adoc[property placeholders].
+
+Here we select from the Switch the first predicate that matches. So if there is
+a property placeholder with the key `foo` then its select, and so on.
+Notice how we can use `{{?foo}}` to mark the property placeholder as optional.
+
+[source,java]
+----
+from("direct:a")
+    .doSwitch()
+        .when(simple("{{?foo}}")).to("direct:foo")
+        .when(simple("{{?bar}}")).to("direct:bar")
+        .otherwise().to("direct:other");
+----
+
+And the same example using XML DSL:
+
+[source,xml]
+----
+<route>
+    <from uri="direct:a"/>
+    <doSwitch>
+        <when>
+            <simple>{{?foo}}</simple>
+            <to uri="direct:foo"/>
+        </when>
+        <when>
+            <simple>{{?bar}}</simple>
+            <to uri="direct:bar"/>
+        </when>
+        <otherwise>
+            <to uri="direct:other"/>
+        </otherwise>
+    </choice>
+</route>
+----
+
+TIP: Otherwise, is optional, and if none of the predicates would match, then 
no branches is selected.
+
+=== Why can I not use otherwise in Java DSL
+
+See the same section at xref:choice-eip.adoc[Choice EIP].
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index ebdd23b..fb45da2 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -152,9 +152,12 @@ public class SimpleLanguage extends LanguageSupport 
implements StaticService {
     @Override
     public Predicate createPredicate(String expression, Object[] properties) {
         boolean trim = property(boolean.class, properties, 1, true);
-        if (trim) {
+        if (trim && expression != null) {
             expression = expression.trim();
         }
+        if (expression == null) {
+            expression = "${null}";
+        }
         return createPredicate(expression);
     }
 
@@ -162,9 +165,12 @@ public class SimpleLanguage extends LanguageSupport 
implements StaticService {
     public Expression createExpression(String expression, Object[] properties) 
{
         Class<?> resultType = property(Class.class, properties, 0, null);
         boolean trim = property(boolean.class, properties, 1, true);
-        if (trim) {
+        if (trim && expression != null) {
             expression = expression.trim();
         }
+        if (expression == null) {
+            expression = "${null}";
+        }
         return createExpression(expression, resultType);
     }
 
diff --git 
a/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties
 
b/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties
index 79cf05d..9a24bbf 100644
--- 
a/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties
+++ 
b/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties
@@ -39,6 +39,7 @@ description
 dnsServiceDiscovery
 doCatch
 doFinally
+doSwitch
 doTry
 dynamicRouter
 enrich
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/doSwitch.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/doSwitch.json
new file mode 100644
index 0000000..227e075
--- /dev/null
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/doSwitch.json
@@ -0,0 +1,20 @@
+{
+  "model": {
+    "kind": "model",
+    "name": "doSwitch",
+    "title": "Do Switch",
+    "description": "Route messages based on a series of predicates (optimized 
during startup to select one predicate that will always be used)",
+    "deprecated": false,
+    "label": "eip,routing",
+    "javaType": "org.apache.camel.model.SwitchDefinition",
+    "abstract": false,
+    "input": true,
+    "output": false
+  },
+  "properties": {
+    "when": { "kind": "element", "displayName": "When", "required": false, 
"type": "array", "javaType": 
"java.util.List<org.apache.camel.model.WhenDefinition>", "oneOf": [ "when" ], 
"deprecated": false, "autowired": false, "secret": false, "asPredicate": true },
+    "otherwise": { "kind": "element", "displayName": "Otherwise", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.model.OtherwiseDefinition", "oneOf": [ "otherwise" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the otherwise node" },
+    "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Sets the id of this node" 
},
+    "description": { "kind": "element", "displayName": "Description", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.model.DescriptionDefinition", "deprecated": false, 
"autowired": false, "secret": false, "description": "Sets the description of 
this node" }
+  }
+}
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/jaxb.index
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/jaxb.index
index d1cf5b7..6eb596d 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/jaxb.index
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/jaxb.index
@@ -89,6 +89,7 @@ SortDefinition
 SplitDefinition
 StepDefinition
 StopDefinition
+SwitchDefinition
 ThreadPoolProfileDefinition
 ThreadsDefinition
 ThrottleDefinition
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
index 34523f8..b1f881e 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
@@ -17,7 +17,6 @@
 package org.apache.camel.model;
 
 import java.util.List;
-import java.util.stream.Collectors;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -60,7 +59,6 @@ public class OtherwiseDefinition extends 
OutputDefinition<OtherwiseDefinition> {
 
     @Override
     public String getLabel() {
-        return getOutputs().stream().map(ProcessorDefinition::getLabel)
-                .collect(Collectors.joining(",", getShortName() + "[", "]"));
+        return "otherwise";
     }
 }
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 4822689..9f5cba5 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -1456,6 +1456,18 @@ public abstract class ProcessorDefinition<Type extends 
ProcessorDefinition<Type>
     }
 
     /**
+     * An optimized <a 
href="http://camel.apache.org/content-based-router.html";>Content Based Router 
EIP:</a> Optimized
+     * during startup to select one predicate that will always be used.
+     *
+     * @return the builder for a switch expression
+     */
+    public SwitchDefinition doSwitch() {
+        SwitchDefinition answer = new SwitchDefinition();
+        addOutput(answer);
+        return answer;
+    }
+
+    /**
      * Creates a try/catch block
      *
      * @return the builder for a tryBlock expression
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/SwitchDefinition.java
similarity index 58%
copy from 
core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
copy to 
core/camel-core-model/src/main/java/org/apache/camel/model/SwitchDefinition.java
index 34523f8..541a241 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OtherwiseDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/SwitchDefinition.java
@@ -16,51 +16,29 @@
  */
 package org.apache.camel.model;
 
-import java.util.List;
-import java.util.stream.Collectors;
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.spi.Metadata;
 
 /**
- * Route to be executed when all other choices evaluate to false
+ * Route messages based on a series of predicates (optimized during startup to 
select one predicate that will always be
+ * used)
  */
 @Metadata(label = "eip,routing")
-@XmlRootElement(name = "otherwise")
+@XmlRootElement(name = "doSwitch")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class OtherwiseDefinition extends OutputDefinition<OtherwiseDefinition> 
{
-
-    public OtherwiseDefinition() {
-    }
-
-    @Override
-    public List<ProcessorDefinition<?>> getOutputs() {
-        return outputs;
-    }
-
-    @XmlElementRef
-    @Override
-    public void setOutputs(List<ProcessorDefinition<?>> outputs) {
-        super.setOutputs(outputs);
-    }
+public class SwitchDefinition extends ChoiceDefinition {
 
     @Override
     public String toString() {
-        return "Otherwise[" + getOutputs() + "]";
+        return "Switch[" + getWhenClauses() + (getOtherwise() != null ? " " + 
getOtherwise() : "") + "]";
     }
 
     @Override
     public String getShortName() {
-        return "otherwise";
+        return "switch";
     }
 
-    @Override
-    public String getLabel() {
-        return getOutputs().stream().map(ProcessorDefinition::getLabel)
-                .collect(Collectors.joining(",", getShortName() + "[", "]"));
-    }
 }
diff --git 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
index 047eaa8..abef127 100644
--- 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
+++ 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
@@ -90,6 +90,7 @@ import org.apache.camel.model.SortDefinition;
 import org.apache.camel.model.SplitDefinition;
 import org.apache.camel.model.StepDefinition;
 import org.apache.camel.model.StopDefinition;
+import org.apache.camel.model.SwitchDefinition;
 import org.apache.camel.model.ThreadsDefinition;
 import org.apache.camel.model.ThrottleDefinition;
 import org.apache.camel.model.ThrowExceptionDefinition;
@@ -179,7 +180,12 @@ public abstract class ProcessorReifier<T extends 
ProcessorDefinition<?>> extends
         } else if (definition instanceof CatchDefinition) {
             return new CatchReifier(route, definition);
         } else if (definition instanceof ChoiceDefinition) {
-            return new ChoiceReifier(route, definition);
+            if (definition instanceof SwitchDefinition) {
+                // switch is an optimized choice
+                return new SwitchReifier(route, definition);
+            } else {
+                return new ChoiceReifier(route, definition);
+            }
         } else if (definition instanceof CircuitBreakerDefinition) {
             return new CircuitBreakerReifier(route, definition);
         } else if (definition instanceof ClaimCheckDefinition) {
diff --git 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SwitchReifier.java
 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SwitchReifier.java
new file mode 100644
index 0000000..b160867
--- /dev/null
+++ 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SwitchReifier.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.reifier;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExpressionFactory;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.SwitchDefinition;
+import org.apache.camel.model.WhenDefinition;
+import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.spi.ExpressionFactoryAware;
+import org.apache.camel.support.DefaultExchange;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SwitchReifier extends ProcessorReifier<SwitchDefinition> {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(SwitchReifier.class);
+
+    public SwitchReifier(Route route, ProcessorDefinition<?> definition) {
+        super(route, SwitchDefinition.class.cast(definition));
+    }
+
+    @Override
+    public Processor createProcessor() throws Exception {
+        // prepare when predicates
+        for (WhenDefinition whenClause : definition.getWhenClauses()) {
+            ExpressionDefinition exp = whenClause.getExpression();
+            if (exp.getExpressionType() != null) {
+                exp = exp.getExpressionType();
+            }
+            Predicate pre = exp.getPredicate();
+            if (pre instanceof ExpressionFactoryAware) {
+                ExpressionFactoryAware aware = (ExpressionFactoryAware) pre;
+                if (aware.getExpressionFactory() != null) {
+                    // if using the Java DSL then the expression may have been
+                    // set using the
+                    // ExpressionClause (implements ExpressionFactoryAware)
+                    // which is a fancy builder to define
+                    // expressions and predicates
+                    // using fluent builders in the DSL. However we need
+                    // afterwards a callback to
+                    // reset the expression to the expression type the
+                    // ExpressionClause did build for us
+                    ExpressionFactory model = aware.getExpressionFactory();
+                    if (model instanceof ExpressionDefinition) {
+                        whenClause.setExpression((ExpressionDefinition) model);
+                    }
+                }
+            }
+        }
+
+        // evaluate when predicates to optimize
+        Exchange dummy = new DefaultExchange(camelContext);
+        for (WhenDefinition whenClause : definition.getWhenClauses()) {
+            ExpressionDefinition exp = whenClause.getExpression();
+            exp.initPredicate(camelContext);
+
+            Predicate predicate = exp.getPredicate();
+            predicate.initPredicate(camelContext);
+
+            boolean matches = predicate.matches(dummy);
+            if (matches) {
+                LOG.debug("doSwitch selected: {}", whenClause.getLabel());
+                return createOutputsProcessor(whenClause.getOutputs());
+            }
+        }
+
+        if (definition.getOtherwise() != null) {
+            LOG.debug("doSwitch selected: otherwise");
+            return createProcessor(definition.getOtherwise());
+        }
+
+        // no cases were selected
+        LOG.debug("doSwitch no when or otherwise selected");
+        return null;
+    }
+
+}
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/model/ChoiceDefinitionTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/model/ChoiceDefinitionTest.java
index 2a12b74..4923eca 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/model/ChoiceDefinitionTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/model/ChoiceDefinitionTest.java
@@ -41,7 +41,7 @@ public class ChoiceDefinitionTest extends TestSupport {
         assertEquals(when1, choice.getOutputs().get(0));
         assertEquals(when2, choice.getOutputs().get(1));
         assertEquals(other, choice.getOutputs().get(2));
-        assertEquals("choice[when[{body contains Camel}],when[{body contains 
Donkey}],otherwise[]]", choice.getLabel());
+        assertEquals("choice[when[{body contains Camel}],when[{body contains 
Donkey}],otherwise]", choice.getLabel());
     }
 
     @Test
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/DoSwitchTest.java 
b/core/camel-core/src/test/java/org/apache/camel/processor/DoSwitchTest.java
new file mode 100644
index 0000000..f007e03
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/DoSwitchTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import java.util.Properties;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class DoSwitchTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testRed() throws Exception {
+        Properties init = new Properties();
+        init.setProperty("red", "true");
+        init.setProperty("blue", "false");
+        context.getPropertiesComponent().setInitialProperties(init);
+
+        context.addRoutes(createRouteBuilder());
+        context.start();
+
+        getMockEndpoint("mock:red").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello Red");
+
+        assertMockEndpointsSatisfied();
+
+        // doSwitch is optimized and we only have the selected node
+        Assertions.assertNull(context.getProcessor("mySwitch"));
+        Assertions.assertNotNull(context.getProcessor("myRed"));
+        Assertions.assertNull(context.getProcessor("myBlue"));
+        Assertions.assertNull(context.getProcessor("myYellow"));
+    }
+
+    @Test
+    public void testBlue() throws Exception {
+        Properties init = new Properties();
+        init.setProperty("red", "false");
+        init.setProperty("blue", "true");
+        context.getPropertiesComponent().setInitialProperties(init);
+
+        context.addRoutes(createRouteBuilder());
+        context.start();
+
+        getMockEndpoint("mock:blue").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello Blue");
+
+        assertMockEndpointsSatisfied();
+
+        // doSwitch is optimized and we only have the selected node
+        Assertions.assertNull(context.getProcessor("mySwitch"));
+        Assertions.assertNull(context.getProcessor("myRed"));
+        Assertions.assertNotNull(context.getProcessor("myBlue"));
+        Assertions.assertNull(context.getProcessor("myYellow"));
+    }
+
+    @Test
+    public void testYellow() throws Exception {
+        Properties init = new Properties();
+        init.setProperty("red", "false");
+        init.setProperty("blue", "false");
+        context.getPropertiesComponent().setInitialProperties(init);
+
+        context.addRoutes(createRouteBuilder());
+        context.start();
+
+        getMockEndpoint("mock:yellow").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello Yellow");
+
+        assertMockEndpointsSatisfied();
+
+        // doSwitch is optimized and we only have the selected node
+        Assertions.assertNull(context.getProcessor("mySwitch"));
+        Assertions.assertNull(context.getProcessor("myRed"));
+        Assertions.assertNull(context.getProcessor("myBlue"));
+        Assertions.assertNotNull(context.getProcessor("myYellow"));
+    }
+
+    @Test
+    public void testNone() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId("myRoute")
+                    .doSwitch().id("mySwitch")
+                        .when(simple("{{?red}}")).to("mock:red").id("myRed")
+                        .when(simple("{{?blue}}")).to("mock:blue").id("myBlue")
+                    .end()
+                    .to("mock:end");
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:end").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello Yellow");
+
+        assertMockEndpointsSatisfied();
+
+        // doSwitch is optimized and we only have the selected node
+        Assertions.assertNull(context.getProcessor("mySwitch"));
+        Assertions.assertNull(context.getProcessor("myRed"));
+        Assertions.assertNull(context.getProcessor("myBlue"));
+        Assertions.assertNull(context.getProcessor("myYellow"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").routeId("myRoute")
+                        .doSwitch().id("mySwitch")
+                        .when(simple("{{red}}")).to("mock:red").id("myRed")
+                        .when(simple("{{blue}}")).to("mock:blue").id("myBlue")
+                        .otherwise().to("mock:yellow").id("myYellow");
+            }
+        };
+    }
+
+}
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 7dd0167..04db450 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -220,16 +220,19 @@ public class ModelParser extends BaseParser {
         return doParse(new WhenDefinition(),
             processorDefinitionAttributeHandler(), 
outputExpressionNodeElementHandler(), noValueHandler());
     }
-    protected ChoiceDefinition doParseChoiceDefinition() throws IOException, 
XmlPullParserException {
-        return doParse(new ChoiceDefinition(),
-            processorDefinitionAttributeHandler(), (def, key) -> {
+    protected <T extends ChoiceDefinition> ElementHandler<T> 
choiceDefinitionElementHandler() {
+        return (def, key) -> {
             switch (key) {
                 case "when": doAdd(doParseWhenDefinition(), 
def.getWhenClauses(), def::setWhenClauses); break;
                 case "otherwise": 
def.setOtherwise(doParseOtherwiseDefinition()); break;
                 default: return 
optionalIdentifiedDefinitionElementHandler().accept(def, key);
             }
             return true;
-        }, noValueHandler());
+        };
+    }
+    protected ChoiceDefinition doParseChoiceDefinition() throws IOException, 
XmlPullParserException {
+        return doParse(new ChoiceDefinition(), 
+            processorDefinitionAttributeHandler(), 
choiceDefinitionElementHandler(), noValueHandler());
     }
     protected OtherwiseDefinition doParseOtherwiseDefinition() throws 
IOException, XmlPullParserException {
         return doParse(new OtherwiseDefinition(),
@@ -1355,6 +1358,10 @@ public class ModelParser extends BaseParser {
         return doParse(new StopDefinition(),
             processorDefinitionAttributeHandler(), 
optionalIdentifiedDefinitionElementHandler(), noValueHandler());
     }
+    protected SwitchDefinition doParseSwitchDefinition() throws IOException, 
XmlPullParserException {
+        return doParse(new SwitchDefinition(),
+            processorDefinitionAttributeHandler(), 
choiceDefinitionElementHandler(), noValueHandler());
+    }
     protected ThreadPoolProfileDefinition doParseThreadPoolProfileDefinition() 
throws IOException, XmlPullParserException {
         return doParse(new ThreadPoolProfileDefinition(), (def, key, val) -> {
             switch (key) {
@@ -3214,6 +3221,7 @@ public class ModelParser extends BaseParser {
             case "split": return doParseSplitDefinition();
             case "step": return doParseStepDefinition();
             case "stop": return doParseStopDefinition();
+            case "doSwitch": return doParseSwitchDefinition();
             case "threads": return doParseThreadsDefinition();
             case "throttle": return doParseThrottleDefinition();
             case "throwException": return doParseThrowExceptionDefinition();
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 8da72b9..d4041ac 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -88,6 +88,7 @@ import org.apache.camel.model.SortDefinition;
 import org.apache.camel.model.SplitDefinition;
 import org.apache.camel.model.StepDefinition;
 import org.apache.camel.model.StopDefinition;
+import org.apache.camel.model.SwitchDefinition;
 import org.apache.camel.model.ThreadPoolProfileDefinition;
 import org.apache.camel.model.ThreadsDefinition;
 import org.apache.camel.model.ThrottleDefinition;
@@ -15377,6 +15378,73 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
     }
 
     @YamlType(
+            types = org.apache.camel.model.SwitchDefinition.class,
+            order = 
org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
+            nodes = {
+                    "do-switch",
+                    "doSwitch"
+            },
+            properties = {
+                    @YamlProperty(name = "description", type = "string"),
+                    @YamlProperty(name = "id", type = "string"),
+                    @YamlProperty(name = "inherit-error-handler", type = 
"boolean"),
+                    @YamlProperty(name = "otherwise", type = 
"object:org.apache.camel.model.OtherwiseDefinition"),
+                    @YamlProperty(name = "steps", type = 
"array:org.apache.camel.model.ProcessorDefinition"),
+                    @YamlProperty(name = "when", type = 
"array:org.apache.camel.model.WhenDefinition")
+            }
+    )
+    public static class SwitchDefinitionDeserializer extends 
YamlDeserializerBase<SwitchDefinition> {
+        public SwitchDefinitionDeserializer() {
+            super(SwitchDefinition.class);
+        }
+
+        @Override
+        protected SwitchDefinition newInstance() {
+            return new SwitchDefinition();
+        }
+
+        @Override
+        protected boolean setProperty(SwitchDefinition target, String 
propertyKey,
+                String propertyName, Node node) {
+            switch(propertyKey) {
+                case "inherit-error-handler": {
+                    String val = asText(node);
+                    
target.setInheritErrorHandler(java.lang.Boolean.valueOf(val));
+                    break;
+                }
+                case "otherwise": {
+                    org.apache.camel.model.OtherwiseDefinition val = 
asType(node, org.apache.camel.model.OtherwiseDefinition.class);
+                    target.setOtherwise(val);
+                    break;
+                }
+                case "when": {
+                    java.util.List<org.apache.camel.model.WhenDefinition> val 
= asFlatList(node, org.apache.camel.model.WhenDefinition.class);
+                    target.setWhenClauses(val);
+                    break;
+                }
+                case "id": {
+                    String val = asText(node);
+                    target.setId(val);
+                    break;
+                }
+                case "description": {
+                    org.apache.camel.model.DescriptionDefinition val = 
asType(node, org.apache.camel.model.DescriptionDefinition.class);
+                    target.setDescription(val);
+                    break;
+                }
+                case "steps": {
+                    setSteps(target, node);
+                    break;
+                }
+                default: {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    @YamlType(
             types = org.apache.camel.model.dataformat.SyslogDataFormat.class,
             order = 
org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
             nodes = "syslog",
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
index a119dc4..78f5183 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
@@ -448,6 +448,9 @@ public final class ModelDeserializersResolver implements 
YamlDeserializerResolve
             case "org.apache.camel.model.StopDefinition": return new 
ModelDeserializers.StopDefinitionDeserializer();
             case "stream-config": return new 
ModelDeserializers.StreamResequencerConfigDeserializer();
             case "org.apache.camel.model.config.StreamResequencerConfig": 
return new ModelDeserializers.StreamResequencerConfigDeserializer();
+            case "do-switch": return new 
ModelDeserializers.SwitchDefinitionDeserializer();
+            case "doSwitch": return new 
ModelDeserializers.SwitchDefinitionDeserializer();
+            case "org.apache.camel.model.SwitchDefinition": return new 
ModelDeserializers.SwitchDefinitionDeserializer();
             case "syslog": return new 
ModelDeserializers.SyslogDataFormatDeserializer();
             case "org.apache.camel.model.dataformat.SyslogDataFormat": return 
new ModelDeserializers.SyslogDataFormatDeserializer();
             case "tar-file": return new 
ModelDeserializers.TarFileDataFormatDeserializer();
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
index 1145a04..0f4e15f 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
@@ -233,6 +233,12 @@
           "stop" : {
             "$ref" : 
"#/items/definitions/org.apache.camel.model.StopDefinition"
           },
+          "do-switch" : {
+            "$ref" : 
"#/items/definitions/org.apache.camel.model.SwitchDefinition"
+          },
+          "doSwitch" : {
+            "$ref" : 
"#/items/definitions/org.apache.camel.model.SwitchDefinition"
+          },
           "threads" : {
             "$ref" : 
"#/items/definitions/org.apache.camel.model.ThreadsDefinition"
           },
@@ -2952,6 +2958,35 @@
           }
         }
       },
+      "org.apache.camel.model.SwitchDefinition" : {
+        "type" : "object",
+        "properties" : {
+          "description" : {
+            "type" : "string"
+          },
+          "id" : {
+            "type" : "string"
+          },
+          "inherit-error-handler" : {
+            "type" : "boolean"
+          },
+          "otherwise" : {
+            "$ref" : 
"#/items/definitions/org.apache.camel.model.OtherwiseDefinition"
+          },
+          "steps" : {
+            "type" : "array",
+            "items" : {
+              "$ref" : 
"#/items/definitions/org.apache.camel.model.ProcessorDefinition"
+            }
+          },
+          "when" : {
+            "type" : "array",
+            "items" : {
+              "$ref" : 
"#/items/definitions/org.apache.camel.model.WhenDefinition"
+            }
+          }
+        }
+      },
       "org.apache.camel.model.ThreadPoolProfileDefinition" : {
         "type" : "object",
         "properties" : {
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camelYamlDsl.json 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camelYamlDsl.json
index a72a2b8..86e3bf8 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camelYamlDsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camelYamlDsl.json
@@ -158,6 +158,9 @@
           "stop" : {
             "$ref" : 
"#/items/definitions/org.apache.camel.model.StopDefinition"
           },
+          "doSwitch" : {
+            "$ref" : 
"#/items/definitions/org.apache.camel.model.SwitchDefinition"
+          },
           "threads" : {
             "$ref" : 
"#/items/definitions/org.apache.camel.model.ThreadsDefinition"
           },
@@ -2856,6 +2859,35 @@
           }
         }
       },
+      "org.apache.camel.model.SwitchDefinition" : {
+        "type" : "object",
+        "properties" : {
+          "description" : {
+            "type" : "string"
+          },
+          "id" : {
+            "type" : "string"
+          },
+          "inheritErrorHandler" : {
+            "type" : "boolean"
+          },
+          "otherwise" : {
+            "$ref" : 
"#/items/definitions/org.apache.camel.model.OtherwiseDefinition"
+          },
+          "steps" : {
+            "type" : "array",
+            "items" : {
+              "$ref" : 
"#/items/definitions/org.apache.camel.model.ProcessorDefinition"
+            }
+          },
+          "when" : {
+            "type" : "array",
+            "items" : {
+              "$ref" : 
"#/items/definitions/org.apache.camel.model.WhenDefinition"
+            }
+          }
+        }
+      },
       "org.apache.camel.model.ThreadPoolProfileDefinition" : {
         "type" : "object",
         "properties" : {

Reply via email to