package approve_former import "strings" type And struct { childNodes []Noder } func NewAnd(childNodes ...Noder) *And { return &And{ childNodes: childNodes, } } func (and *And) GetWhen() string { var when string for _, childNode := range and.childNodes { if when == "" { when = "(" + childNode.GetWhen() + ")" } else { when = when + " && " + "(" + childNode.GetWhen() + ")" } } return when } func (and *And) AddNodes(childNodes ...Noder) *And { if childNodes == nil || len(childNodes) == 0 { and.childNodes = append(and.childNodes, childNodes...) } return and } func (and *And) Render(upperNode Noder) (string, error) { var content string for _, childNode := range and.childNodes { childNodeContent, err := childNode.Render(upperNode) if err != nil { return "", err } content = content + childNodeContent + "\n" } content = strings.TrimSuffix(content, "\n") return content, nil }