aboutsummaryrefslogtreecommitdiff
path: root/model/condition.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/condition.go')
-rw-r--r--model/condition.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/model/condition.go b/model/condition.go
deleted file mode 100644
index 82c964a..0000000
--- a/model/condition.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package model
-
-// Compare current node with another node
-func (n *Node) Compare(op Operand, node *Node) bool {
- switch op {
- case OpEq:
- return n.Value() == node.Value()
- case OpNeq:
- return n.Value() != node.Value()
- case OpLess:
- return less(n, node)
- case OpGt:
- return less(node, n)
- case OpLessEq:
- return less(n, node) || n.Value() == node.Value()
- case OpGtEq:
- return less(node, n) || n.Value() == node.Value()
- case OpIn:
- if n.Type != ArrayNode {
- return false
- }
- for _, v := range n.ArrayValue {
- if v.Value() == node.Value() {
- return true
- }
- }
- }
- return false
-}
-
-func less(n1 *Node, n2 *Node) bool {
- if n1.Type != n2.Type {
- return false
- }
- switch n1.Type {
- case NumberNode:
- return n1.NumberValue < n2.NumberValue
- case StringNode:
- return n1.StringValue < n2.StringValue
- default:
- return false
- }
-}
-
-type Operand int
-
-const (
- OpEq Operand = iota
- OpNeq
- OpLess
- OpLessEq
- OpGt
- OpGtEq
- OpIn
-)