-
Notifications
You must be signed in to change notification settings - Fork 11
/
generated_impl.go
168 lines (137 loc) · 7.97 KB
/
generated_impl.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// This file was automatically generated by genny.
// Any changes will be lost if this file is regenerated.
// see https://github.com/cheekybits/genny
package yaml
import (
"strings"
"github.com/coveooss/gotemplate/v3/collections"
"github.com/coveooss/multilogger/errors"
)
// List implementation of IGenericList for yamlList
type List = yamlList
type yamlIList = collections.IGenericList
type yamlList []interface{}
var yamlLower = strings.ToLower("Yaml") // This is required because genny capitalize the type name in strings
func (l yamlList) AsArray() []interface{} { return []interface{}(l) }
func (l yamlList) Cap() int { return cap(l) }
func (l yamlList) Capacity() int { return cap(l) }
func (l yamlList) Clone() yamlIList { return yamlListHelper.Clone(l) }
func (l yamlList) Count() int { return len(l) }
func (l yamlList) Create(args ...int) yamlIList { return yamlListHelper.CreateList(args...) }
func (l yamlList) CreateDict(args ...int) yamlIDict { return yamlListHelper.CreateDictionary(args...) }
func (l yamlList) Find(element interface{}) yamlIList { return yamlListHelper.Find(l, element, false) }
func (l yamlList) First() interface{} { return yamlListHelper.GetIndexes(l, 0) }
func (l yamlList) Get(indexes ...int) interface{} { return yamlListHelper.GetIndexes(l, indexes...) }
func (l yamlList) GetKinds() yamlIList { return yamlListHelper.GetTypes(l, true) }
func (l yamlList) GetTypes() yamlIList { return yamlListHelper.GetTypes(l, false) }
func (l yamlList) Has(values ...interface{}) bool { return l.Contains(values...) }
func (l yamlList) HasStrict(values ...interface{}) bool { return l.ContainsStrict(values...) }
func (l yamlList) Join(sep interface{}) str { return l.StringArray().Join(sep) }
func (l yamlList) Last() interface{} { return yamlListHelper.GetIndexes(l, len(l)-1) }
func (l yamlList) Len() int { return len(l) }
func (l yamlList) New(args ...interface{}) yamlIList { return yamlListHelper.NewList(args...) }
func (l yamlList) Reverse() yamlIList { return yamlListHelper.Reverse(l) }
func (l yamlList) RemoveEmpty() yamlIList { return yamlListHelper.RemoveEmpty(l) }
func (l yamlList) RemoveNil() yamlIList { return yamlListHelper.RemoveNil(l) }
func (l yamlList) StringArray() strArray { return yamlListHelper.GetStringArray(l) }
func (l yamlList) Strings() []string { return yamlListHelper.GetStrings(l) }
func (l yamlList) Type() str { return yamlListHelper.Type(l) }
func (l yamlList) TypeName() str { return str(yamlLower) }
func (l yamlList) Unique() yamlIList { return yamlListHelper.Unique(l) }
func (l yamlList) GetHelpers() (collections.IDictionaryHelper, collections.IListHelper) {
return yamlDictHelper, yamlListHelper
}
func (l yamlList) Append(values ...interface{}) yamlIList {
return yamlListHelper.Add(l, false, values...)
}
func (l yamlList) Contains(values ...interface{}) bool {
return yamlListHelper.Contains(l, false, values...)
}
func (l yamlList) ContainsStrict(values ...interface{}) bool {
return yamlListHelper.Contains(l, true, values...)
}
func (l yamlList) FindStrict(element interface{}) yamlIList {
return yamlListHelper.Find(l, element, true)
}
func (l yamlList) Intersect(values ...interface{}) yamlIList {
return yamlListHelper.Intersect(l, values...)
}
func (l yamlList) Pop(indexes ...int) (interface{}, yamlIList) {
if len(indexes) == 0 {
indexes = []int{len(l) - 1}
}
return l.Get(indexes...), l.Remove(indexes...)
}
func (l yamlList) Prepend(values ...interface{}) yamlIList {
return yamlListHelper.Add(l, true, values...)
}
func (l yamlList) Remove(indexes ...int) yamlIList {
return yamlListHelper.Remove(l, indexes...)
}
func (l yamlList) Set(i int, v interface{}) (yamlIList, error) {
return yamlListHelper.SetIndex(l, i, v)
}
func (l yamlList) Union(values ...interface{}) yamlIList {
return yamlListHelper.Add(l, false, values...).Unique()
}
func (l yamlList) Without(values ...interface{}) yamlIList {
return yamlListHelper.Without(l, values...)
}
// Dictionary implementation of IDictionary for yamlDict
type Dictionary = yamlDict
type yamlIDict = collections.IDictionary
type yamlDict map[string]interface{}
func (d yamlDict) Add(key, v interface{}) yamlIDict { return yamlDictHelper.Add(d, key, v) }
func (d yamlDict) AsMap() map[string]interface{} { return (map[string]interface{})(d) }
func (d yamlDict) Clone(keys ...interface{}) yamlIDict { return yamlDictHelper.Clone(d, keys) }
func (d yamlDict) Count() int { return len(d) }
func (d yamlDict) Create(args ...int) yamlIDict { return yamlListHelper.CreateDictionary(args...) }
func (d yamlDict) CreateList(args ...int) yamlIList { return yamlHelper.CreateList(args...) }
func (d yamlDict) Flush(keys ...interface{}) yamlIDict { return yamlDictHelper.Flush(d, keys) }
func (d yamlDict) Get(keys ...interface{}) interface{} { return yamlDictHelper.Get(d, keys) }
func (d yamlDict) GetKeys() yamlIList { return yamlDictHelper.GetKeys(d) }
func (d yamlDict) GetKinds() yamlIDict { return yamlDictHelper.GetTypes(d, true) }
func (d yamlDict) GetTypes() yamlIDict { return yamlDictHelper.GetTypes(d, false) }
func (d yamlDict) GetValues() yamlIList { return yamlDictHelper.GetValues(d) }
func (d yamlDict) Has(keys ...interface{}) bool { return yamlDictHelper.Has(d, keys) }
func (d yamlDict) KeysAsString() strArray { return yamlDictHelper.KeysAsString(d) }
func (d yamlDict) Len() int { return len(d) }
func (d yamlDict) Native() interface{} { return must(collections.MarshalGo(d)) }
func (d yamlDict) Pop(keys ...interface{}) interface{} { return yamlDictHelper.Pop(d, keys) }
func (d yamlDict) Set(key, v interface{}) yamlIDict { return yamlDictHelper.Set(d, key, v) }
func (d yamlDict) Transpose() yamlIDict { return yamlDictHelper.Transpose(d) }
func (d yamlDict) Type() str { return yamlDictHelper.Type(d) }
func (d yamlDict) TypeName() str { return str(yamlLower) }
func (d yamlDict) GetHelpers() (collections.IDictionaryHelper, collections.IListHelper) {
return yamlDictHelper, yamlListHelper
}
func (d yamlDict) Default(key, defVal interface{}) interface{} {
return yamlDictHelper.Default(d, key, defVal)
}
func (d yamlDict) Delete(key interface{}, otherKeys ...interface{}) (yamlIDict, error) {
return yamlDictHelper.Delete(d, append([]interface{}{key}, otherKeys...))
}
func (d yamlDict) Merge(dict yamlIDict, otherDicts ...yamlIDict) yamlIDict {
return yamlDictHelper.Merge(d, append([]yamlIDict{dict}, otherDicts...))
}
func (d yamlDict) Omit(key interface{}, otherKeys ...interface{}) yamlIDict {
return yamlDictHelper.Omit(d, append([]interface{}{key}, otherKeys...))
}
// Generic helpers to simplify physical implementation
func yamlListConvert(list yamlIList) yamlIList { return yamlList(list.AsArray()) }
func yamlDictConvert(dict yamlIDict) yamlIDict { return yamlDict(dict.AsMap()) }
func needConversion(object interface{}, strict bool) bool {
return needConversionImpl(object, strict, "Yaml")
}
var yamlHelper = helperBase{ConvertList: yamlListConvert, ConvertDict: yamlDictConvert, NeedConversion: needConversion}
var yamlListHelper = helperList{BaseHelper: yamlHelper}
var yamlDictHelper = helperDict{BaseHelper: yamlHelper}
// DictionaryHelper gives public access to the basic dictionary functions
var DictionaryHelper collections.IDictionaryHelper = yamlDictHelper
// GenericListHelper gives public access to the basic list functions
var GenericListHelper collections.IListHelper = yamlListHelper
type (
str = collections.String
strArray = collections.StringArray
)
var must = errors.Must