* A `LogicNode` that represents the composition of multiple `LogicNode` instances. * This is used when logic for a particular path is contributed by several distinct * builder branches that need to be merged.
| 416 | * builder branches that need to be merged. |
| 417 | */ |
| 418 | class CompositeLogicNode implements LogicNode { |
| 419 | /** The merged logic from all composed nodes. */ |
| 420 | readonly logic: LogicContainer; |
| 421 | |
| 422 | /** |
| 423 | * Constructs a `CompositeLogicNode`. |
| 424 | * @param all An array of `LogicNode` instances to compose. |
| 425 | */ |
| 426 | constructor(private all: LogicNode[]) { |
| 427 | this.logic = new LogicContainer([]); |
| 428 | for (const node of all) { |
| 429 | this.logic.mergeIn(node.logic); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Retrieves the child `LogicNode` by composing the results of `getChild` from all |
| 435 | * underlying `LogicNode` instances. |
| 436 | * @param key The property key of the child. |
| 437 | * @returns A `CompositeLogicNode` representing the composed child. |
| 438 | */ |
| 439 | getChild(key: PropertyKey): LogicNode { |
| 440 | return new CompositeLogicNode(this.all.flatMap((child) => child.getChild(key))); |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Checks whether the logic from a particular `AbstractLogicNodeBuilder` has been merged into this |
| 445 | * node. |
| 446 | * @param builder The builder to check for. |
| 447 | * @returns True if the builder has been merged, false otherwise. |
| 448 | */ |
| 449 | hasLogic(builder: AbstractLogicNodeBuilder): boolean { |
| 450 | return this.all.some((node) => node.hasLogic(builder)); |
| 451 | } |
| 452 | |
| 453 | hasRules(): boolean { |
| 454 | return this.all.some((node) => node.hasRules()); |
| 455 | } |
| 456 | |
| 457 | anyChildHasLogic(): boolean { |
| 458 | return this.all.some((child) => child.anyChildHasLogic()); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Gets all of the builders that contribute logic to the given child of the parent builder. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…