-
Notifications
You must be signed in to change notification settings - Fork 0
/
or_nil.go
293 lines (273 loc) · 5.17 KB
/
or_nil.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
package configmap
func (c *Configmap) GetByteOrNil(key string) *byte {
byteIntf := c.GetOrNil(key)
if byteIntf != nil {
switch byteIntf := byteIntf.(type) {
case byte:
b := byteIntf
return &b
case *byte:
return byteIntf
}
}
return nil
}
func (c *Configmap) GetBoolOrNil(key string) *bool {
boolIntf := c.GetOrNil(key)
if boolIntf != nil {
switch boolIntf := boolIntf.(type) {
case bool:
b := boolIntf
return &b
case *bool:
return boolIntf
}
}
return nil
}
func (c *Configmap) GetIntOrNil(key string) *int {
intIntf := c.GetOrNil(key)
if intIntf != nil {
switch intIntf := intIntf.(type) {
case int:
i := intIntf
return &i
case *int:
return intIntf
}
}
return nil
}
func (c *Configmap) GetUIntOrNil(key string) *uint {
uintIntf := c.GetOrNil(key)
if uintIntf != nil {
switch uintIntf := uintIntf.(type) {
case uint:
u := uintIntf
return &u
case *uint:
return uintIntf
}
}
return nil
}
func (c *Configmap) GetUIntPtrOrNil(key string) *uintptr {
uintptrIntf := c.GetOrNil(key)
if uintptrIntf != nil {
switch uintptrIntf := uintptrIntf.(type) {
case uintptr:
up := uintptrIntf
return &up
case *uintptr:
return uintptrIntf
}
}
return nil
}
func (c *Configmap) GetInt8OrNil(key string) *int8 {
intIntf := c.GetOrNil(key)
if intIntf != nil {
switch intIntf := intIntf.(type) {
case int8:
i := intIntf
return &i
case *int8:
return intIntf
}
}
return nil
}
func (c *Configmap) GetUInt8OrNil(key string) *uint8 {
uintIntf := c.GetOrNil(key)
if uintIntf != nil {
switch uintIntf := uintIntf.(type) {
case uint8:
u := uintIntf
return &u
case *uint8:
return uintIntf
}
}
return nil
}
func (c *Configmap) GetInt16OrNil(key string) *int16 {
intIntf := c.GetOrNil(key)
if intIntf != nil {
switch intIntf := intIntf.(type) {
case int16:
i := intIntf
return &i
case *int16:
return intIntf
}
}
return nil
}
func (c *Configmap) GetUInt16OrNil(key string) *uint16 {
uintIntf := c.GetOrNil(key)
if uintIntf != nil {
switch uintIntf := uintIntf.(type) {
case uint16:
u := uintIntf
return &u
case *uint16:
return uintIntf
}
}
return nil
}
func (c *Configmap) GetInt32OrNil(key string) *int32 {
intIntf := c.GetOrNil(key)
if intIntf != nil {
switch intIntf := intIntf.(type) {
case int32:
i := intIntf
return &i
case *int32:
return intIntf
}
}
return nil
}
func (c *Configmap) GetUInt32OrNil(key string) *uint32 {
uintIntf := c.GetOrNil(key)
if uintIntf != nil {
switch uintIntf := uintIntf.(type) {
case uint32:
u := uintIntf
return &u
case *uint32:
return uintIntf
}
}
return nil
}
func (c *Configmap) GetInt64OrNil(key string) *int64 {
intIntf := c.GetOrNil(key)
if intIntf != nil {
switch intIntf := intIntf.(type) {
case int64:
i := intIntf
return &i
case *int64:
return intIntf
}
}
return nil
}
func (c *Configmap) GetUInt64OrNil(key string) *uint64 {
uintIntf := c.GetOrNil(key)
if uintIntf != nil {
switch uintIntf := uintIntf.(type) {
case uint64:
u := uintIntf
return &u
case *uint64:
return uintIntf
}
}
return nil
}
func (c *Configmap) GetFloat32OrNil(key string) *float32 {
floatIntf := c.GetOrNil(key)
if floatIntf != nil {
switch floatIntf := floatIntf.(type) {
case float32:
f := floatIntf
return &f
case *float32:
return floatIntf
}
}
return nil
}
func (c *Configmap) GetFloat64OrNil(key string) *float64 {
floatIntf := c.GetOrNil(key)
if floatIntf != nil {
switch floatIntf := floatIntf.(type) {
case float64:
f := floatIntf
return &f
case *float64:
return floatIntf
}
}
return nil
}
func (c *Configmap) GetComplex64OrNil(key string) *complex64 {
cplxIntf := c.GetOrNil(key)
if cplxIntf != nil {
switch cplxIntf := cplxIntf.(type) {
case complex64:
cplx := cplxIntf
return &cplx
case *complex64:
return cplxIntf
}
}
return nil
}
func (c *Configmap) GetComplex128OrNil(key string) *complex128 {
cplxIntf := c.GetOrNil(key)
if cplxIntf != nil {
switch cplxIntf := cplxIntf.(type) {
case complex128:
cplx := cplxIntf
return &cplx
case *complex128:
return cplxIntf
}
}
return nil
}
func (c *Configmap) GetStringOrNil(key string) *string {
strIntf := c.GetOrNil(key)
if strIntf != nil {
switch strIntf := strIntf.(type) {
case string:
str := strIntf
return &str
case *string:
return strIntf
}
}
return nil
}
func (c *Configmap) GetMapSIOrNil(key string) *map[string]interface{} {
mapSIIntf := c.GetOrNil(key)
if mapSIIntf != nil {
switch mapSIIntf := mapSIIntf.(type) {
case map[string]interface{}:
mapSI := mapSIIntf
return &mapSI
case *map[string]interface{}:
return mapSIIntf
}
}
return nil
}
func (c *Configmap) GetConfigMapOrNil(key string) *ConfigMap {
cmIntf := c.GetOrNil(key)
if cmIntf != nil {
switch cmIntf := cmIntf.(type) {
case map[string]interface{}:
cm := New(cmIntf)
return &cm
case *map[string]interface{}:
cm := New(cmIntf)
return &cm
case ConfigMap:
cm := cmIntf
return &cm
case *ConfigMap:
return cmIntf
case Configmap:
newCM := New(cmIntf)
return &newCM
case *Configmap:
cm := New(cmIntf)
return &cm
}
}
return nil
}