-
Notifications
You must be signed in to change notification settings - Fork 5
/
limit.go
51 lines (41 loc) · 853 Bytes
/
limit.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
package cypher
import "errors"
type Limit struct {
limitAmount NumberLiteral
key string
notNil bool
err error
}
func LimitCreate(number int) Limit {
if number == 0 {
return LimitError(errors.New("limit can not be zero"))
}
literal := NumberLiteralCreate1(number)
l := Limit{limitAmount: literal, notNil: true}
l.key = getAddress(&l)
return l
}
func LimitError(err error) Limit {
return Limit{
err: err,
}
}
func (l Limit) GetError() error {
return l.err
}
func (l Limit) isNotNil() bool {
return l.notNil
}
func (l Limit) getKey() string {
return l.key
}
func (l Limit) accept(visitor *CypherRenderer) {
visitor.enter(l)
l.limitAmount.accept(visitor)
visitor.leave(l)
}
func (l Limit) enter(renderer *CypherRenderer) {
renderer.append(" LIMIT ")
}
func (l Limit) leave(renderer *CypherRenderer) {
}