-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconstants.go
49 lines (38 loc) · 899 Bytes
/
constants.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
package generate
type Constants []*Constant
func (cc Constants) init(ns *Namespace) {
for _, constant := range cc {
constant.init(ns)
}
}
func (cc Constants) versionList() Versions {
var versions Versions
for _, c := range cc {
if c.Version != "" {
versions = append(versions, VersionNew(c.Version))
}
}
return versions
}
func (cc Constants) entities() []Generatable {
var generatables []Generatable
for _, constant := range cc {
generatables = append(generatables, constant)
}
return generatables
}
func (cc Constants) forName(name string) *Constant {
for _, constant := range cc {
if constant.Name == name {
return constant
}
}
return nil
}
func (cc Constants) mergeAddenda(addenda Constants) {
for _, addendaContant := range addenda {
if constant := cc.forName(addendaContant.Name); constant != nil {
constant.mergeAddenda(addendaContant)
}
}
}