-
Notifications
You must be signed in to change notification settings - Fork 5
/
Type16Enum.go
executable file
·72 lines (62 loc) · 1.51 KB
/
Type16Enum.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
package models
import(
"encoding/json"
)
/**
* Type definition for Type16Enum enum
*/
type Type16Enum int
/**
* Value collection for Type16Enum enum
*/
const (
Type16_KSTORAGEARRAY Type16Enum = 1 + iota
Type16_KVOLUME
)
func (r Type16Enum) MarshalJSON() ([]byte, error) {
s := Type16EnumToValue(r)
return json.Marshal(s)
}
func (r *Type16Enum) UnmarshalJSON(data []byte) error {
var s string
json.Unmarshal(data, &s)
v := Type16EnumFromValue(s)
*r = v
return nil
}
/**
* Converts Type16Enum to its string representation
*/
func Type16EnumToValue(type16Enum Type16Enum) string {
switch type16Enum {
case Type16_KSTORAGEARRAY:
return "kStorageArray"
case Type16_KVOLUME:
return "kVolume"
default:
return "kStorageArray"
}
}
/**
* Converts Type16Enum Array to its string Array representation
*/
func Type16EnumArrayToValue(type16Enum []Type16Enum) []string {
convArray := make([]string,len( type16Enum))
for i:=0; i<len(type16Enum);i++ {
convArray[i] = Type16EnumToValue(type16Enum[i])
}
return convArray
}
/**
* Converts given value to its enum representation
*/
func Type16EnumFromValue(value string) Type16Enum {
switch value {
case "kStorageArray":
return Type16_KSTORAGEARRAY
case "kVolume":
return Type16_KVOLUME
default:
return Type16_KSTORAGEARRAY
}
}