-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathstruct_level.go
44 lines (35 loc) · 1.06 KB
/
struct_level.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
package mold
import "reflect"
// StructLevel represents the interface for struct level modifier function
type StructLevel interface {
// Transformer represents a subset of the current *Transformer that is executing the current transformation.
Transformer() Transform
//
// Parent returns the top level parent of the current value return by Struct().
//
// This is used primarily for having the ability to nil out pointer type values.
//
// NOTE: that is there are several layers of abstractions eg. interface{} of interface{} of interface{} this
// function returns the first interface{}.
//
Parent() reflect.Value
// Struct returns the value of the current struct being modified.
Struct() reflect.Value
}
var (
_ StructLevel = (*structLevel)(nil)
)
type structLevel struct {
transformer *Transformer
parent reflect.Value
current reflect.Value
}
func (s structLevel) Transformer() Transform {
return s.transformer
}
func (s structLevel) Parent() reflect.Value {
return s.parent
}
func (s structLevel) Struct() reflect.Value {
return s.current
}