/
enums_cachetype.go
64 lines (52 loc) · 1.69 KB
/
enums_cachetype.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
// Code generated by "enumer -type=cacheType -trimprefix=cacheType -text -transform=kebab -output enums_cachetype.go"; DO NOT EDIT.
//
package imagine
import (
"fmt"
)
const _cacheTypeName = "defaultnonelruranked"
var _cacheTypeIndex = [...]uint8{0, 7, 11, 14, 20}
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]]
}
var _cacheTypeValues = []cacheType{0, 1, 2, 3}
var _cacheTypeNameToValueMap = map[string]cacheType{
_cacheTypeName[0:7]: 0,
_cacheTypeName[7:11]: 1,
_cacheTypeName[11:14]: 2,
_cacheTypeName[14:20]: 3,
}
// 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
}
return 0, fmt.Errorf("%s does not belong to cacheType values", s)
}
// cacheTypeValues returns all values of the enum
func cacheTypeValues() []cacheType {
return _cacheTypeValues
}
// 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
}
// MarshalText implements the encoding.TextMarshaler interface for cacheType
func (i cacheType) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for cacheType
func (i *cacheType) UnmarshalText(text []byte) error {
var err error
*i, err = cacheTypeString(string(text))
return err
}