forked from manhcuongbk56/cypher-go-dsl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arguments.go
58 lines (49 loc) · 1.13 KB
/
arguments.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
package cypher
type Arguments struct {
expressions []Expression
key string
notNil bool
err error
}
func ArgumentsCreate(expression []Expression) Arguments {
for _, expr := range expression {
if expr != nil && expr.GetError() != nil {
return Arguments{err: expr.GetError()}
}
}
a := Arguments{
expressions: expression,
notNil: true,
}
a.key = getAddress(&a)
return a
}
func (a Arguments) GetError() error {
return a.err
}
func (a Arguments) isNotNil() bool {
return a.notNil
}
func (a Arguments) getKey() string {
return a.key
}
func (a Arguments) PrepareVisit(child Visitable) Visitable {
expression, isExpression := child.(Expression)
if !isExpression {
panic("Can not prepare un expression type In expression list")
}
return NameOrExpression(expression)
}
func (a Arguments) accept(visitor *CypherRenderer) {
visitor.enter(a)
for _, expression := range a.expressions {
a.PrepareVisit(expression).accept(visitor)
}
visitor.leave(a)
}
func (a Arguments) enter(renderer *CypherRenderer) {
renderer.append("(")
}
func (a Arguments) leave(renderer *CypherRenderer) {
renderer.append(")")
}