-
Notifications
You must be signed in to change notification settings - Fork 23
/
cache-type-string.go
78 lines (63 loc) · 1.95 KB
/
cache-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
// Code generated by "enumer -type=CacheType -transform=lower -output=cache-type-string.go"; DO NOT EDIT.
package iface
import (
"fmt"
"strings"
)
const _CacheTypeName = "resultglobal"
var _CacheTypeIndex = [...]uint8{0, 6, 12}
const _CacheTypeLowerName = "resultglobal"
func (i CacheType) String() string {
if i < 0 || i >= CacheType(len(_CacheTypeIndex)-1) {
return fmt.Sprintf("CacheType(%d)", i)
}
return _CacheTypeName[_CacheTypeIndex[i]:_CacheTypeIndex[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 _CacheTypeNoOp() {
var x [1]struct{}
_ = x[Result-(0)]
_ = x[Global-(1)]
}
var _CacheTypeValues = []CacheType{Result, Global}
var _CacheTypeNameToValueMap = map[string]CacheType{
_CacheTypeName[0:6]: Result,
_CacheTypeLowerName[0:6]: Result,
_CacheTypeName[6:12]: Global,
_CacheTypeLowerName[6:12]: Global,
}
var _CacheTypeNames = []string{
_CacheTypeName[0:6],
_CacheTypeName[6:12],
}
// CacheTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func CacheTypeString(s string) (CacheType, error) {
if val, ok := _CacheTypeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _CacheTypeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to CacheType values", s)
}
// CacheTypeValues returns all values of the enum
func CacheTypeValues() []CacheType {
return _CacheTypeValues
}
// CacheTypeStrings returns a slice of all String values of the enum
func CacheTypeStrings() []string {
strs := make([]string, len(_CacheTypeNames))
copy(strs, _CacheTypeNames)
return strs
}
// IsACacheType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i CacheType) IsACacheType() bool {
for _, v := range _CacheTypeValues {
if i == v {
return true
}
}
return false
}