* @return Never be null/undefined.
(condition: QueryConditionKindB)
| 590 | * @return Never be null/undefined. |
| 591 | */ |
| 592 | queryComponents(condition: QueryConditionKindB): ComponentModel[] { |
| 593 | const mainType = condition.mainType; |
| 594 | if (!mainType) { |
| 595 | return []; |
| 596 | } |
| 597 | |
| 598 | const index = condition.index; |
| 599 | const id = condition.id; |
| 600 | const name = condition.name; |
| 601 | const cmpts = this._componentsMap.get(mainType); |
| 602 | |
| 603 | if (!cmpts || !cmpts.length) { |
| 604 | return []; |
| 605 | } |
| 606 | |
| 607 | let result: ComponentModel[]; |
| 608 | |
| 609 | if (index != null) { |
| 610 | result = []; |
| 611 | each(modelUtil.normalizeToArray(index), function (idx) { |
| 612 | cmpts[idx] && result.push(cmpts[idx]); |
| 613 | }); |
| 614 | } |
| 615 | else if (id != null) { |
| 616 | result = queryByIdOrName('id', id, cmpts); |
| 617 | } |
| 618 | else if (name != null) { |
| 619 | result = queryByIdOrName('name', name, cmpts); |
| 620 | } |
| 621 | else { |
| 622 | // Return all non-empty components in that mainType |
| 623 | result = filter(cmpts, cmpt => !!cmpt); |
| 624 | } |
| 625 | |
| 626 | return filterBySubType(result, condition); |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * The interface is different from queryComponents, |
no test coverage detected