* Returns the child construct that has the id `Default` or `Resource`. * This is usually the construct that provides the bulk of the underlying functionality. * Useful for modifications of the underlying construct that are not available at the higher levels. * * @throws if there is more
()
| 170 | * @returns a construct or undefined if there is no default child |
| 171 | */ |
| 172 | public get defaultChild(): IConstruct | undefined { |
| 173 | if (this._defaultChild !== undefined) { |
| 174 | return this._defaultChild; |
| 175 | } |
| 176 | |
| 177 | const resourceChild = this.tryFindChild('Resource'); |
| 178 | const defaultChild = this.tryFindChild('Default'); |
| 179 | if (resourceChild && defaultChild) { |
| 180 | throw new Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`); |
| 181 | } |
| 182 | |
| 183 | return defaultChild || resourceChild; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Override the defaultChild property. |
nothing calls this directly
no test coverage detected