Guillaume Nodet created CAMEL-23412:
---------------------------------------

             Summary: Add getChildren() to NamedNode for uniform model tree 
traversal
                 Key: CAMEL-23412
                 URL: https://issues.apache.org/jira/browse/CAMEL-23412
             Project: Camel
          Issue Type: Improvement
            Reporter: Guillaume Nodet


h2. Problem

ChoiceDefinition's when/otherwise children are invisible to generic model tree 
walkers because getOutputs() returns List<ProcessorDefinition<?>> and neither 
WhenDefinition nor OtherwiseDefinition extends ProcessorDefinition. This forces 
every tree walker to special-case ChoiceDefinition — and several don't, 
creating gaps (e.g., gatherAllNodeIds() misses when/otherwise node IDs, 
forceAssignIds() skips them).

CAMEL-23402 switched the structure dumper from JMX-based to model-walking and 
added the missing OtherwiseDefinition to doFindType()'s special case. However, 
it did not address the fundamental design issue: every new tree walker must 
know to add the ChoiceDefinition special case, and the existing ones that don't 
have it silently miss when/otherwise nodes.

h2. Solution

Add a getChildren() default method on NamedNode that returns List<NamedNode>, 
providing a uniform API for tree traversal regardless of whether children are 
ProcessorDefinition subclasses or not.

This eliminates the ChoiceDefinition and TryDefinition special cases from 
ProcessorDefinitionHelper.doFindType() (reducing ~110 lines to ~15 lines) and 
fixes the gaps in gatherAllNodeIds(), resetAllAutoAssignedNodeIds(), and 
forceAssignIds().



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to