GetDefault gets the default value for the child attribute with the given name. It returns nil if the child attribute with the given name does not exist or if the child attribute does not have a default value.
(attName string)
| 557 | // name. It returns nil if the child attribute with the given name does not |
| 558 | // exist or if the child attribute does not have a default value. |
| 559 | func (a *AttributeExpr) GetDefault(attName string) any { |
| 560 | if o := AsObject(a.Type); o != nil { |
| 561 | att := o.Attribute(attName) |
| 562 | if att.DefaultValue != nil { |
| 563 | return att.DefaultValue |
| 564 | } |
| 565 | if ut, ok := att.Type.(UserType); ok && !IsObject(ut) { |
| 566 | return ut.Attribute().DefaultValue |
| 567 | } |
| 568 | } |
| 569 | return nil |
| 570 | } |
| 571 | |
| 572 | // SetDefault sets the default for the attribute. It also converts HashVal |
| 573 | // and ArrayVal to map and slice respectively. |
no test coverage detected