-
Notifications
You must be signed in to change notification settings - Fork 329
/
values.go
76 lines (60 loc) · 1.12 KB
/
values.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
package expr
import (
"reflect"
)
type (
Type interface {
Type() string
Cast(interface{}) (TypedValue, error)
}
TypedValue interface {
Type
Assigner
Clone() (TypedValue, error)
Get() interface{}
}
Comparable interface {
Compare(TypedValue) (int, error)
}
typedValueWrap struct {
Value interface{} `json:"@value"`
Type string `json:"@type"`
}
Assigner interface {
Assign(interface{}) error
}
FieldSelector interface {
Has(k string) bool
Select(k string) (TypedValue, error)
}
FieldAssigner interface {
AssignFieldValue(string, TypedValue) error
}
DeepFieldAssigner interface {
AssignFieldValue(Pather, TypedValue) error
}
Iterator interface {
Each(func(k string, v TypedValue) error) error
}
TypeValueDecoder interface {
Decode(dst reflect.Value) error
}
Dict interface {
Dict() map[string]interface{}
}
Slice interface {
Slice() []interface{}
}
)
func UntypedValue(val interface{}) interface{} {
if tv, is := val.(TypedValue); is {
return tv.Get()
}
return val
}
func Must(v TypedValue, err error) TypedValue {
if err != nil {
panic(err)
}
return v
}