-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_options.go
46 lines (38 loc) · 868 Bytes
/
node_options.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
package gofigure
type nodeOptions struct {
filepath string
mappingKey string
hasMappingKey bool
sequenceIndex int
hasSequenceIndex bool
parent *Node
}
type NodeOption interface {
apply(*nodeOptions)
}
type nodeOptionFunc func(*nodeOptions)
func (f nodeOptionFunc) apply(o *nodeOptions) {
f(o)
}
func NodeFilepath(path string) NodeOption {
return nodeOptionFunc(func(o *nodeOptions) {
o.filepath = path
})
}
func NodeSequenceIndex(index int) NodeOption {
return nodeOptionFunc(func(o *nodeOptions) {
o.sequenceIndex = index
o.hasSequenceIndex = true
})
}
func NodeMappingKey(key string) NodeOption {
return nodeOptionFunc(func(o *nodeOptions) {
o.mappingKey = key
o.hasMappingKey = true
})
}
func NodeParent(parent *Node) NodeOption {
return nodeOptionFunc(func(o *nodeOptions) {
o.parent = parent
})
}