-
Notifications
You must be signed in to change notification settings - Fork 5
/
multipart_element.go
61 lines (53 loc) · 1.33 KB
/
multipart_element.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cypher
type MultiPartElement struct {
precedingClauses []Visitable
with with
key string
notNil bool
err error
}
func MultiPartElementCreate(precedingClauses []Visitable, with with) MultiPartElement {
for _, clause := range precedingClauses {
if clause != nil && clause.GetError() != nil {
return MultiPartElement{err: clause.GetError()}
}
}
if with.GetError() != nil {
return MultiPartElement{err: with.GetError()}
}
var clauses []Visitable
if precedingClauses == nil || len(precedingClauses) == 0 {
clauses = make([]Visitable, 0)
} else {
clauses = make([]Visitable, 0)
clauses = append(clauses, precedingClauses...)
}
m := MultiPartElement{
precedingClauses: clauses,
with: with,
notNil: true,
}
m.key = getAddress(&m)
return m
}
func (m MultiPartElement) GetError() error {
return m.err
}
func (m MultiPartElement) accept(visitor *CypherRenderer) {
visitor.enter(m)
for _, clause := range m.precedingClauses {
clause.accept(visitor)
}
m.with.accept(visitor)
visitor.leave(m)
}
func (m MultiPartElement) enter(renderer *CypherRenderer) {
}
func (m MultiPartElement) leave(renderer *CypherRenderer) {
}
func (m MultiPartElement) getKey() string {
return m.key
}
func (m MultiPartElement) isNotNil() bool {
return m.notNil
}