Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / github.com / go-openapi / swag / convert_types.go
1 package swag
2
3 import "time"
4
5 // This file was taken from the aws go sdk
6
7 // String returns a pointer to of the string value passed in.
8 func String(v string) *string {
9         return &v
10 }
11
12 // StringValue returns the value of the string pointer passed in or
13 // "" if the pointer is nil.
14 func StringValue(v *string) string {
15         if v != nil {
16                 return *v
17         }
18         return ""
19 }
20
21 // StringSlice converts a slice of string values into a slice of
22 // string pointers
23 func StringSlice(src []string) []*string {
24         dst := make([]*string, len(src))
25         for i := 0; i < len(src); i++ {
26                 dst[i] = &(src[i])
27         }
28         return dst
29 }
30
31 // StringValueSlice converts a slice of string pointers into a slice of
32 // string values
33 func StringValueSlice(src []*string) []string {
34         dst := make([]string, len(src))
35         for i := 0; i < len(src); i++ {
36                 if src[i] != nil {
37                         dst[i] = *(src[i])
38                 }
39         }
40         return dst
41 }
42
43 // StringMap converts a string map of string values into a string
44 // map of string pointers
45 func StringMap(src map[string]string) map[string]*string {
46         dst := make(map[string]*string)
47         for k, val := range src {
48                 v := val
49                 dst[k] = &v
50         }
51         return dst
52 }
53
54 // StringValueMap converts a string map of string pointers into a string
55 // map of string values
56 func StringValueMap(src map[string]*string) map[string]string {
57         dst := make(map[string]string)
58         for k, val := range src {
59                 if val != nil {
60                         dst[k] = *val
61                 }
62         }
63         return dst
64 }
65
66 // Bool returns a pointer to of the bool value passed in.
67 func Bool(v bool) *bool {
68         return &v
69 }
70
71 // BoolValue returns the value of the bool pointer passed in or
72 // false if the pointer is nil.
73 func BoolValue(v *bool) bool {
74         if v != nil {
75                 return *v
76         }
77         return false
78 }
79
80 // BoolSlice converts a slice of bool values into a slice of
81 // bool pointers
82 func BoolSlice(src []bool) []*bool {
83         dst := make([]*bool, len(src))
84         for i := 0; i < len(src); i++ {
85                 dst[i] = &(src[i])
86         }
87         return dst
88 }
89
90 // BoolValueSlice converts a slice of bool pointers into a slice of
91 // bool values
92 func BoolValueSlice(src []*bool) []bool {
93         dst := make([]bool, len(src))
94         for i := 0; i < len(src); i++ {
95                 if src[i] != nil {
96                         dst[i] = *(src[i])
97                 }
98         }
99         return dst
100 }
101
102 // BoolMap converts a string map of bool values into a string
103 // map of bool pointers
104 func BoolMap(src map[string]bool) map[string]*bool {
105         dst := make(map[string]*bool)
106         for k, val := range src {
107                 v := val
108                 dst[k] = &v
109         }
110         return dst
111 }
112
113 // BoolValueMap converts a string map of bool pointers into a string
114 // map of bool values
115 func BoolValueMap(src map[string]*bool) map[string]bool {
116         dst := make(map[string]bool)
117         for k, val := range src {
118                 if val != nil {
119                         dst[k] = *val
120                 }
121         }
122         return dst
123 }
124
125 // Int returns a pointer to of the int value passed in.
126 func Int(v int) *int {
127         return &v
128 }
129
130 // IntValue returns the value of the int pointer passed in or
131 // 0 if the pointer is nil.
132 func IntValue(v *int) int {
133         if v != nil {
134                 return *v
135         }
136         return 0
137 }
138
139 // IntSlice converts a slice of int values into a slice of
140 // int pointers
141 func IntSlice(src []int) []*int {
142         dst := make([]*int, len(src))
143         for i := 0; i < len(src); i++ {
144                 dst[i] = &(src[i])
145         }
146         return dst
147 }
148
149 // IntValueSlice converts a slice of int pointers into a slice of
150 // int values
151 func IntValueSlice(src []*int) []int {
152         dst := make([]int, len(src))
153         for i := 0; i < len(src); i++ {
154                 if src[i] != nil {
155                         dst[i] = *(src[i])
156                 }
157         }
158         return dst
159 }
160
161 // IntMap converts a string map of int values into a string
162 // map of int pointers
163 func IntMap(src map[string]int) map[string]*int {
164         dst := make(map[string]*int)
165         for k, val := range src {
166                 v := val
167                 dst[k] = &v
168         }
169         return dst
170 }
171
172 // IntValueMap converts a string map of int pointers into a string
173 // map of int values
174 func IntValueMap(src map[string]*int) map[string]int {
175         dst := make(map[string]int)
176         for k, val := range src {
177                 if val != nil {
178                         dst[k] = *val
179                 }
180         }
181         return dst
182 }
183
184 // Int32 returns a pointer to of the int64 value passed in.
185 func Int32(v int32) *int32 {
186         return &v
187 }
188
189 // Int32Value returns the value of the int64 pointer passed in or
190 // 0 if the pointer is nil.
191 func Int32Value(v *int32) int32 {
192         if v != nil {
193                 return *v
194         }
195         return 0
196 }
197
198 // Int32Slice converts a slice of int64 values into a slice of
199 // int32 pointers
200 func Int32Slice(src []int32) []*int32 {
201         dst := make([]*int32, len(src))
202         for i := 0; i < len(src); i++ {
203                 dst[i] = &(src[i])
204         }
205         return dst
206 }
207
208 // Int32ValueSlice converts a slice of int32 pointers into a slice of
209 // int32 values
210 func Int32ValueSlice(src []*int32) []int32 {
211         dst := make([]int32, len(src))
212         for i := 0; i < len(src); i++ {
213                 if src[i] != nil {
214                         dst[i] = *(src[i])
215                 }
216         }
217         return dst
218 }
219
220 // Int32Map converts a string map of int32 values into a string
221 // map of int32 pointers
222 func Int32Map(src map[string]int32) map[string]*int32 {
223         dst := make(map[string]*int32)
224         for k, val := range src {
225                 v := val
226                 dst[k] = &v
227         }
228         return dst
229 }
230
231 // Int32ValueMap converts a string map of int32 pointers into a string
232 // map of int32 values
233 func Int32ValueMap(src map[string]*int32) map[string]int32 {
234         dst := make(map[string]int32)
235         for k, val := range src {
236                 if val != nil {
237                         dst[k] = *val
238                 }
239         }
240         return dst
241 }
242
243 // Int64 returns a pointer to of the int64 value passed in.
244 func Int64(v int64) *int64 {
245         return &v
246 }
247
248 // Int64Value returns the value of the int64 pointer passed in or
249 // 0 if the pointer is nil.
250 func Int64Value(v *int64) int64 {
251         if v != nil {
252                 return *v
253         }
254         return 0
255 }
256
257 // Int64Slice converts a slice of int64 values into a slice of
258 // int64 pointers
259 func Int64Slice(src []int64) []*int64 {
260         dst := make([]*int64, len(src))
261         for i := 0; i < len(src); i++ {
262                 dst[i] = &(src[i])
263         }
264         return dst
265 }
266
267 // Int64ValueSlice converts a slice of int64 pointers into a slice of
268 // int64 values
269 func Int64ValueSlice(src []*int64) []int64 {
270         dst := make([]int64, len(src))
271         for i := 0; i < len(src); i++ {
272                 if src[i] != nil {
273                         dst[i] = *(src[i])
274                 }
275         }
276         return dst
277 }
278
279 // Int64Map converts a string map of int64 values into a string
280 // map of int64 pointers
281 func Int64Map(src map[string]int64) map[string]*int64 {
282         dst := make(map[string]*int64)
283         for k, val := range src {
284                 v := val
285                 dst[k] = &v
286         }
287         return dst
288 }
289
290 // Int64ValueMap converts a string map of int64 pointers into a string
291 // map of int64 values
292 func Int64ValueMap(src map[string]*int64) map[string]int64 {
293         dst := make(map[string]int64)
294         for k, val := range src {
295                 if val != nil {
296                         dst[k] = *val
297                 }
298         }
299         return dst
300 }
301
302 // Uint returns a pouinter to of the uint value passed in.
303 func Uint(v uint) *uint {
304         return &v
305 }
306
307 // UintValue returns the value of the uint pouinter passed in or
308 // 0 if the pouinter is nil.
309 func UintValue(v *uint) uint {
310         if v != nil {
311                 return *v
312         }
313         return 0
314 }
315
316 // UintSlice converts a slice of uint values uinto a slice of
317 // uint pouinters
318 func UintSlice(src []uint) []*uint {
319         dst := make([]*uint, len(src))
320         for i := 0; i < len(src); i++ {
321                 dst[i] = &(src[i])
322         }
323         return dst
324 }
325
326 // UintValueSlice converts a slice of uint pouinters uinto a slice of
327 // uint values
328 func UintValueSlice(src []*uint) []uint {
329         dst := make([]uint, len(src))
330         for i := 0; i < len(src); i++ {
331                 if src[i] != nil {
332                         dst[i] = *(src[i])
333                 }
334         }
335         return dst
336 }
337
338 // UintMap converts a string map of uint values uinto a string
339 // map of uint pouinters
340 func UintMap(src map[string]uint) map[string]*uint {
341         dst := make(map[string]*uint)
342         for k, val := range src {
343                 v := val
344                 dst[k] = &v
345         }
346         return dst
347 }
348
349 // UintValueMap converts a string map of uint pouinters uinto a string
350 // map of uint values
351 func UintValueMap(src map[string]*uint) map[string]uint {
352         dst := make(map[string]uint)
353         for k, val := range src {
354                 if val != nil {
355                         dst[k] = *val
356                 }
357         }
358         return dst
359 }
360
361 // Uint32 returns a pouinter to of the uint64 value passed in.
362 func Uint32(v uint32) *uint32 {
363         return &v
364 }
365
366 // Uint32Value returns the value of the uint64 pouinter passed in or
367 // 0 if the pouinter is nil.
368 func Uint32Value(v *uint32) uint32 {
369         if v != nil {
370                 return *v
371         }
372         return 0
373 }
374
375 // Uint32Slice converts a slice of uint64 values uinto a slice of
376 // uint32 pouinters
377 func Uint32Slice(src []uint32) []*uint32 {
378         dst := make([]*uint32, len(src))
379         for i := 0; i < len(src); i++ {
380                 dst[i] = &(src[i])
381         }
382         return dst
383 }
384
385 // Uint32ValueSlice converts a slice of uint32 pouinters uinto a slice of
386 // uint32 values
387 func Uint32ValueSlice(src []*uint32) []uint32 {
388         dst := make([]uint32, len(src))
389         for i := 0; i < len(src); i++ {
390                 if src[i] != nil {
391                         dst[i] = *(src[i])
392                 }
393         }
394         return dst
395 }
396
397 // Uint32Map converts a string map of uint32 values uinto a string
398 // map of uint32 pouinters
399 func Uint32Map(src map[string]uint32) map[string]*uint32 {
400         dst := make(map[string]*uint32)
401         for k, val := range src {
402                 v := val
403                 dst[k] = &v
404         }
405         return dst
406 }
407
408 // Uint32ValueMap converts a string map of uint32 pouinters uinto a string
409 // map of uint32 values
410 func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
411         dst := make(map[string]uint32)
412         for k, val := range src {
413                 if val != nil {
414                         dst[k] = *val
415                 }
416         }
417         return dst
418 }
419
420 // Uint64 returns a pouinter to of the uint64 value passed in.
421 func Uint64(v uint64) *uint64 {
422         return &v
423 }
424
425 // Uint64Value returns the value of the uint64 pouinter passed in or
426 // 0 if the pouinter is nil.
427 func Uint64Value(v *uint64) uint64 {
428         if v != nil {
429                 return *v
430         }
431         return 0
432 }
433
434 // Uint64Slice converts a slice of uint64 values uinto a slice of
435 // uint64 pouinters
436 func Uint64Slice(src []uint64) []*uint64 {
437         dst := make([]*uint64, len(src))
438         for i := 0; i < len(src); i++ {
439                 dst[i] = &(src[i])
440         }
441         return dst
442 }
443
444 // Uint64ValueSlice converts a slice of uint64 pouinters uinto a slice of
445 // uint64 values
446 func Uint64ValueSlice(src []*uint64) []uint64 {
447         dst := make([]uint64, len(src))
448         for i := 0; i < len(src); i++ {
449                 if src[i] != nil {
450                         dst[i] = *(src[i])
451                 }
452         }
453         return dst
454 }
455
456 // Uint64Map converts a string map of uint64 values uinto a string
457 // map of uint64 pouinters
458 func Uint64Map(src map[string]uint64) map[string]*uint64 {
459         dst := make(map[string]*uint64)
460         for k, val := range src {
461                 v := val
462                 dst[k] = &v
463         }
464         return dst
465 }
466
467 // Uint64ValueMap converts a string map of uint64 pouinters uinto a string
468 // map of uint64 values
469 func Uint64ValueMap(src map[string]*uint64) map[string]uint64 {
470         dst := make(map[string]uint64)
471         for k, val := range src {
472                 if val != nil {
473                         dst[k] = *val
474                 }
475         }
476         return dst
477 }
478
479 // Float64 returns a pointer to of the float64 value passed in.
480 func Float64(v float64) *float64 {
481         return &v
482 }
483
484 // Float64Value returns the value of the float64 pointer passed in or
485 // 0 if the pointer is nil.
486 func Float64Value(v *float64) float64 {
487         if v != nil {
488                 return *v
489         }
490         return 0
491 }
492
493 // Float64Slice converts a slice of float64 values into a slice of
494 // float64 pointers
495 func Float64Slice(src []float64) []*float64 {
496         dst := make([]*float64, len(src))
497         for i := 0; i < len(src); i++ {
498                 dst[i] = &(src[i])
499         }
500         return dst
501 }
502
503 // Float64ValueSlice converts a slice of float64 pointers into a slice of
504 // float64 values
505 func Float64ValueSlice(src []*float64) []float64 {
506         dst := make([]float64, len(src))
507         for i := 0; i < len(src); i++ {
508                 if src[i] != nil {
509                         dst[i] = *(src[i])
510                 }
511         }
512         return dst
513 }
514
515 // Float64Map converts a string map of float64 values into a string
516 // map of float64 pointers
517 func Float64Map(src map[string]float64) map[string]*float64 {
518         dst := make(map[string]*float64)
519         for k, val := range src {
520                 v := val
521                 dst[k] = &v
522         }
523         return dst
524 }
525
526 // Float64ValueMap converts a string map of float64 pointers into a string
527 // map of float64 values
528 func Float64ValueMap(src map[string]*float64) map[string]float64 {
529         dst := make(map[string]float64)
530         for k, val := range src {
531                 if val != nil {
532                         dst[k] = *val
533                 }
534         }
535         return dst
536 }
537
538 // Time returns a pointer to of the time.Time value passed in.
539 func Time(v time.Time) *time.Time {
540         return &v
541 }
542
543 // TimeValue returns the value of the time.Time pointer passed in or
544 // time.Time{} if the pointer is nil.
545 func TimeValue(v *time.Time) time.Time {
546         if v != nil {
547                 return *v
548         }
549         return time.Time{}
550 }
551
552 // TimeSlice converts a slice of time.Time values into a slice of
553 // time.Time pointers
554 func TimeSlice(src []time.Time) []*time.Time {
555         dst := make([]*time.Time, len(src))
556         for i := 0; i < len(src); i++ {
557                 dst[i] = &(src[i])
558         }
559         return dst
560 }
561
562 // TimeValueSlice converts a slice of time.Time pointers into a slice of
563 // time.Time values
564 func TimeValueSlice(src []*time.Time) []time.Time {
565         dst := make([]time.Time, len(src))
566         for i := 0; i < len(src); i++ {
567                 if src[i] != nil {
568                         dst[i] = *(src[i])
569                 }
570         }
571         return dst
572 }
573
574 // TimeMap converts a string map of time.Time values into a string
575 // map of time.Time pointers
576 func TimeMap(src map[string]time.Time) map[string]*time.Time {
577         dst := make(map[string]*time.Time)
578         for k, val := range src {
579                 v := val
580                 dst[k] = &v
581         }
582         return dst
583 }
584
585 // TimeValueMap converts a string map of time.Time pointers into a string
586 // map of time.Time values
587 func TimeValueMap(src map[string]*time.Time) map[string]time.Time {
588         dst := make(map[string]time.Time)
589         for k, val := range src {
590                 if val != nil {
591                         dst[k] = *val
592                 }
593         }
594         return dst
595 }