/
predicates.go
114 lines (94 loc) · 3.83 KB
/
predicates.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
// Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package predicate is a utility package to create predicate.
package predicate
import (
"github.com/hazelcast/hazelcast-go-client/internal/predicate"
)
// SQL returns a SQLPredicate with the given sql.
func SQL(sql string) interface{} {
return predicate.NewSQL(sql)
}
// And returns an AndPredicate with the given predicate.
func And(predicates ...interface{}) interface{} {
return predicate.NewAnd(predicates)
}
// Between returns a BetweenPredicate with the given parameters.
func Between(field string, from interface{}, to interface{}) interface{} {
return predicate.NewBetween(field, from, to)
}
// Equal returns an EqualPredicate with the given field and value.
func Equal(field string, value interface{}) interface{} {
return predicate.NewEqual(field, value)
}
// GreaterThan returns a GreaterLessPredicate with the given field and value.
// The returned GreaterLessPredicate behaves like greater than.
func GreaterThan(field string, value interface{}) interface{} {
return predicate.NewGreaterLess(field, value, false, false)
}
// GreaterEqual returns a GreaterLessPredicate with the given field and value.
// The returned GreaterLessPredicate behaves like greater equal.
func GreaterEqual(field string, value interface{}) interface{} {
return predicate.NewGreaterLess(field, value, true, false)
}
// LessThan returns a GreaterLessPredicate with the given field and value.
// The returned GreaterLessPredicate behaves like less than.
func LessThan(field string, value interface{}) interface{} {
return predicate.NewGreaterLess(field, value, false, true)
}
// LessEqual returns a GreaterLessPredicate with the given field and value.
// The returned GreaterLessPredicate behaves like less equal.
func LessEqual(field string, value interface{}) interface{} {
return predicate.NewGreaterLess(field, value, true, true)
}
// Like returns a LikePredicate with the given field and expr.
func Like(field string, expr string) interface{} {
return predicate.NewLike(field, expr)
}
// ILike returns an ILikePredicate with the given field and expr.
func ILike(field string, expr string) interface{} {
return predicate.NewILike(field, expr)
}
// In returns an InPredicate with the given field and values.
func In(field string, values ...interface{}) interface{} {
return predicate.NewIn(field, values)
}
// InstanceOf returns an InstanceOfPredicate with the given className.
func InstanceOf(className string) interface{} {
return predicate.NewInstanceOf(className)
}
// NotEqual returns a NotEqualPredicate with the given field and value.
func NotEqual(field string, value interface{}) interface{} {
return predicate.NewNotEqual(field, value)
}
// Not returns a NotPredicate with the given predicate.
func Not(predicates interface{}) interface{} {
return predicate.NewNot(predicates)
}
// Or returns an OrPredicate with the given predicate.
func Or(predicates ...interface{}) interface{} {
return predicate.NewOr(predicates)
}
// Regex returns a RegexPredicate with the given field and regex.
func Regex(field string, regex string) interface{} {
return predicate.NewRegex(field, regex)
}
// True returns a TruePredicate.
func True() interface{} {
return predicate.NewTrue()
}
// False returns a FalsePredicate.
func False() interface{} {
return predicate.NewFalse()
}