* 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
()
| 183 | * @returns a construct or undefined if there is no default child |
| 184 | */ |
| 185 | public get defaultChild(): IConstruct | undefined { |
| 186 | if (this._defaultChild !== undefined) { |
| 187 | return this._defaultChild; |
| 188 | } |
| 189 | |
| 190 | const resourceChild = this.tryFindChild('Resource'); |
| 191 | const defaultChild = this.tryFindChild('Default'); |
| 192 | if (resourceChild && defaultChild) { |
| 193 | throw new Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`); |
| 194 | } |
| 195 | |
| 196 | return defaultChild || resourceChild; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Override the defaultChild property. |
nothing calls this directly
no test coverage detected