forked from project-flogo/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
primatives.go
113 lines (87 loc) · 1.95 KB
/
primatives.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
package coerce
import (
"github.com/project-flogo/core/data/coerce"
"github.com/project-flogo/core/data/expression/function"
)
func init() {
function.Register(&fnToString{})
function.Register(&fnToInt{})
function.Register(&fnToInt32{})
function.Register(&fnToInt64{})
function.Register(&fnToFloat32{})
function.Register(&fnToFloat64{})
function.Register(&fnToBool{})
function.Register(&fnToBytes{})
}
type fnToString struct {
*baseFn
}
func (*fnToString) Name() string {
return "toString"
}
func (*fnToString) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToString(params[0])
}
type fnToInt struct {
*baseFn
}
func (*fnToInt) Name() string {
return "toInt"
}
func (*fnToInt) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToInt(params[0])
}
type fnToInt32 struct {
*baseFn
}
func (*fnToInt32) Name() string {
return "toInt32"
}
func (*fnToInt32) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToInt32(params[0])
}
type fnToInt64 struct {
*baseFn
}
func (*fnToInt64) Name() string {
return "toInt64"
}
func (*fnToInt64) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToInt64(params[0])
}
type fnToFloat32 struct {
*baseFn
}
func (*fnToFloat32) Name() string {
return "toFloat32"
}
func (*fnToFloat32) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToFloat32(params[0])
}
type fnToFloat64 struct {
*baseFn
}
func (*fnToFloat64) Name() string {
return "toFloat64"
}
func (*fnToFloat64) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToFloat64(params[0])
}
type fnToBool struct {
*baseFn
}
func (*fnToBool) Name() string {
return "toBool"
}
func (*fnToBool) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToBool(params[0])
}
type fnToBytes struct {
*baseFn
}
func (*fnToBytes) Name() string {
return "toBytes"
}
func (*fnToBytes) Eval(params ...interface{}) (interface{}, error) {
return coerce.ToBytes(params[0])
}