-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewtype_enumer.go
78 lines (63 loc) · 1.92 KB
/
viewtype_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
// Code generated by "enumer -type=ViewType -trimprefix ViewType"; DO NOT EDIT.
package main
import (
"fmt"
"strings"
)
const _ViewTypeName = "MainHelp"
var _ViewTypeIndex = [...]uint8{0, 4, 8}
const _ViewTypeLowerName = "mainhelp"
func (i ViewType) String() string {
if i < 0 || i >= ViewType(len(_ViewTypeIndex)-1) {
return fmt.Sprintf("ViewType(%d)", i)
}
return _ViewTypeName[_ViewTypeIndex[i]:_ViewTypeIndex[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 _ViewTypeNoOp() {
var x [1]struct{}
_ = x[ViewTypeMain-(0)]
_ = x[ViewTypeHelp-(1)]
}
var _ViewTypeValues = []ViewType{ViewTypeMain, ViewTypeHelp}
var _ViewTypeNameToValueMap = map[string]ViewType{
_ViewTypeName[0:4]: ViewTypeMain,
_ViewTypeLowerName[0:4]: ViewTypeMain,
_ViewTypeName[4:8]: ViewTypeHelp,
_ViewTypeLowerName[4:8]: ViewTypeHelp,
}
var _ViewTypeNames = []string{
_ViewTypeName[0:4],
_ViewTypeName[4:8],
}
// ViewTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ViewTypeString(s string) (ViewType, error) {
if val, ok := _ViewTypeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ViewTypeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ViewType values", s)
}
// ViewTypeValues returns all values of the enum
func ViewTypeValues() []ViewType {
return _ViewTypeValues
}
// ViewTypeStrings returns a slice of all String values of the enum
func ViewTypeStrings() []string {
strs := make([]string, len(_ViewTypeNames))
copy(strs, _ViewTypeNames)
return strs
}
// IsAViewType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ViewType) IsAViewType() bool {
for _, v := range _ViewTypeValues {
if i == v {
return true
}
}
return false
}