gnodet opened a new pull request, #22932: URL: https://github.com/apache/camel/pull/22932
[CAMEL-23412](https://issues.apache.org/jira/browse/CAMEL-23412) ## Summary Adds a `getChildren()` default method on `NamedNode` that returns `List<NamedNode>`, providing a uniform API for model tree traversal that includes non-`ProcessorDefinition` children like `WhenDefinition` and `OtherwiseDefinition`. ## Problem `ChoiceDefinition`'s when/otherwise children are invisible to generic 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: - `gatherAllNodeIds()` missed when/otherwise node IDs - `resetAllAutoAssignedNodeIds()` skipped when/otherwise nodes - `forceAssignIds()` skipped when/otherwise nodes ## Relation to CAMEL-23402 [CAMEL-23402](https://issues.apache.org/jira/browse/CAMEL-23402) fixed a specific symptom (structure dumper missing `OtherwiseDefinition`) by adding it to `doFindType()`'s special case. This PR addresses the root cause: the lack of a uniform tree traversal API. With `getChildren()`, the special cases in `doFindType()` are no longer needed, and future tree walkers get correct behavior by default. ## Changes - **`NamedNode.getChildren()`**: new default method returning `List<NamedNode>` (empty by default) - **`ProcessorDefinition`**: overrides to delegate to `getOutputs()` - **`ChoiceDefinition`**: overrides to return when/otherwise nodes as direct children - **`WhenDefinition` / `OtherwiseDefinition`**: override to return their body processors - **`ProcessorDefinitionHelper.doFindType()`**: replaced ~110 lines of special-case code (ChoiceDefinition, TryDefinition, OutputDefinition, SendDefinition) with ~15 lines of generic `getChildren()` traversal - **`ProcessorDefinitionHelper.gatherAllNodeIds()` / `resetAllAutoAssignedNodeIds()`**: now traverse when/otherwise nodes via `getChildren()` - **`RouteDefinitionHelper.forceAssignIds()`**: now assigns IDs to when/otherwise nodes - **`CustomIdFactoryTest`**: updated expected IDs (when/otherwise nodes now get IDs assigned earlier) _Claude Code on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
