1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package approve_former
- import "strings"
- type And struct {
- childNodes []Node
- }
- func NewAnd(childNodes ...Node) *And {
- return &And{
- childNodes: childNodes,
- }
- }
- func (and *And) GetDepends() string {
- var depends string
- for _, childNode := range and.childNodes {
- if depends == "" {
- depends = childNode.GetDepends()
- } else {
- depends = depends + " && " + childNode.GetDepends()
- }
- }
- return depends
- }
- 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) Render(upperNode Node) (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
- }
|