-
Notifications
You must be signed in to change notification settings - Fork 24
/
event-type-string.go
79 lines (64 loc) · 1.93 KB
/
event-type-string.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
// Code generated by "enumer -type=EventType -output=event-type-string.go"; DO NOT EDIT.
package notifiers
import (
"fmt"
"strings"
)
const _EventTypeName = "WriteRemove"
var _EventTypeIndex = [...]uint8{0, 5, 11}
const _EventTypeLowerName = "writeremove"
func (i EventType) String() string {
i -= 1
if i >= EventType(len(_EventTypeIndex)-1) {
return fmt.Sprintf("EventType(%d)", i+1)
}
return _EventTypeName[_EventTypeIndex[i]:_EventTypeIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _EventTypeNoOp() {
var x [1]struct{}
_ = x[Write-(1)]
_ = x[Remove-(2)]
}
var _EventTypeValues = []EventType{Write, Remove}
var _EventTypeNameToValueMap = map[string]EventType{
_EventTypeName[0:5]: Write,
_EventTypeLowerName[0:5]: Write,
_EventTypeName[5:11]: Remove,
_EventTypeLowerName[5:11]: Remove,
}
var _EventTypeNames = []string{
_EventTypeName[0:5],
_EventTypeName[5:11],
}
// EventTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func EventTypeString(s string) (EventType, error) {
if val, ok := _EventTypeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _EventTypeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to EventType values", s)
}
// EventTypeValues returns all values of the enum
func EventTypeValues() []EventType {
return _EventTypeValues
}
// EventTypeStrings returns a slice of all String values of the enum
func EventTypeStrings() []string {
strs := make([]string, len(_EventTypeNames))
copy(strs, _EventTypeNames)
return strs
}
// IsAEventType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i EventType) IsAEventType() bool {
for _, v := range _EventTypeValues {
if i == v {
return true
}
}
return false
}