-
Notifications
You must be signed in to change notification settings - Fork 3
/
triggersystem_enumer.go
98 lines (80 loc) · 2.7 KB
/
triggersystem_enumer.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
// Code generated by "enumer -type=triggerSystem -transform=kebab -trimprefix=trigger -json -text -yaml"; DO NOT EDIT.
//
package trigger
import (
"encoding/json"
"fmt"
)
const _triggerSystemName = "devicescriptnotification"
var _triggerSystemIndex = [...]uint8{0, 6, 12, 24}
func (i triggerSystem) String() string {
if i < 0 || i >= triggerSystem(len(_triggerSystemIndex)-1) {
return fmt.Sprintf("triggerSystem(%d)", i)
}
return _triggerSystemName[_triggerSystemIndex[i]:_triggerSystemIndex[i+1]]
}
var _triggerSystemValues = []triggerSystem{0, 1, 2}
var _triggerSystemNameToValueMap = map[string]triggerSystem{
_triggerSystemName[0:6]: 0,
_triggerSystemName[6:12]: 1,
_triggerSystemName[12:24]: 2,
}
// triggerSystemString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func triggerSystemString(s string) (triggerSystem, error) {
if val, ok := _triggerSystemNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to triggerSystem values", s)
}
// triggerSystemValues returns all values of the enum
func triggerSystemValues() []triggerSystem {
return _triggerSystemValues
}
// IsAtriggerSystem returns "true" if the value is listed in the enum definition. "false" otherwise
func (i triggerSystem) IsAtriggerSystem() bool {
for _, v := range _triggerSystemValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for triggerSystem
func (i triggerSystem) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for triggerSystem
func (i *triggerSystem) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("triggerSystem should be a string, got %s", data)
}
var err error
*i, err = triggerSystemString(s)
return err
}
// MarshalText implements the encoding.TextMarshaler interface for triggerSystem
func (i triggerSystem) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for triggerSystem
func (i *triggerSystem) UnmarshalText(text []byte) error {
var err error
*i, err = triggerSystemString(string(text))
return err
}
// MarshalYAML implements a YAML Marshaler for triggerSystem
func (i triggerSystem) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler for triggerSystem
func (i *triggerSystem) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
var err error
*i, err = triggerSystemString(s)
return err
}