-
Notifications
You must be signed in to change notification settings - Fork 5
/
expression_container.go
146 lines (116 loc) · 4.26 KB
/
expression_container.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package cypher
type ExpressionContainer struct {
expression Expression
}
func ExpressionWrap(expression Expression) ExpressionContainer {
return ExpressionContainer{
expression: expression,
}
}
func (e ExpressionContainer) Get() Expression {
return e.expression
}
func (e ExpressionContainer) As(alias string) ExpressionContainer {
e.expression = AliasedExpressionCreate(e.expression, alias)
return e
}
func (e ExpressionContainer) IsEqualTo(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, EQUALITY, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) IsNotEqualTo(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, INEQUALITY, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Lt(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, LESS_THAN, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Lte(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, LESS_THAN_OR_EQUAL_TO, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Gt(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, GREATER_THAN, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Gte(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, GREATER_THAN_OR_EQUAL_TO, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) IsTrue() ConditionContainer {
return e.IsEqualTo(BooleanLiteralCreate(true))
}
func (e ExpressionContainer) IsFalse() ConditionContainer {
return e.IsEqualTo(BooleanLiteralCreate(false))
}
func (e ExpressionContainer) Matches(expression Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, MATCHES, expression)
return ConditionContainer{e}
}
func (e ExpressionContainer) MatchesPattern(pattern string) ConditionContainer {
e.expression = ComparisonCreate(e.expression, MATCHES, StringLiteralCreate(pattern))
return ConditionContainer{e}
}
func (e ExpressionContainer) StartWiths(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, STARTS_WITH, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Contains(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, CONTAINS, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) EndsWith(rhs Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, ENDS_WITH, rhs)
return ConditionContainer{e}
}
func (e ExpressionContainer) Concat(rhs Expression) ExpressionContainer {
e.expression = OperationConcat(e.expression, rhs)
return e
}
func (e ExpressionContainer) Add(rhs Expression) ExpressionContainer {
e.expression = OperationAdd(e.expression, rhs)
return e
}
func (e ExpressionContainer) Subtract(rhs Expression) ExpressionContainer {
e.expression = OperationSubtract(e.expression, rhs)
return e
}
func (e ExpressionContainer) Multiply(rhs Expression) ExpressionContainer {
e.expression = OperationMultiply(e.expression, rhs)
return e
}
func (e ExpressionContainer) Divide(rhs Expression) ExpressionContainer {
e.expression = OperationDivide(e.expression, rhs)
return e
}
func (e ExpressionContainer) Remainder(rhs Expression) ExpressionContainer {
e.expression = OperationRemainder(e.expression, rhs)
return e
}
func (e ExpressionContainer) Pow(rhs Expression) ExpressionContainer {
e.expression = OperationPow(e.expression, rhs)
return e
}
func (e ExpressionContainer) IsNull() ConditionContainer {
e.expression = ComparisonCreate1(IS_NULL, e.expression)
return ConditionContainer{e}
}
func (e ExpressionContainer) IsNotNull() ConditionContainer {
e.expression = ComparisonCreate1(IS_NOT_NULL, e.expression)
return ConditionContainer{e}
}
func (e ExpressionContainer) In(haystack Expression) ConditionContainer {
e.expression = ComparisonCreate(e.expression, IN, haystack)
return ConditionContainer{e}
}
func (e ExpressionContainer) IsEmpty() ConditionContainer {
e.expression = Size(e.expression)
return e.IsEqualTo(NumberLiteralCreate1(0))
}
func (e ExpressionContainer) Descending() SortItem {
return CreateDescendingSortItem(e.expression)
}
func (e ExpressionContainer) Ascending() SortItem {
return CreateAscendingSortItem(e.expression)
}