-
Notifications
You must be signed in to change notification settings - Fork 53
/
compression_enum.go
90 lines (75 loc) · 2.66 KB
/
compression_enum.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
// Code generated by "enumer -transform upper -type Compression -trimprefix Compression -output compression_enum.go"; DO NOT EDIT.
package ch
import (
"fmt"
"strings"
)
const _CompressionName = "DISABLEDLZ4ZSTDNONELZ4HC"
var _CompressionIndex = [...]uint8{0, 8, 11, 15, 19, 24}
const _CompressionLowerName = "disabledlz4zstdnonelz4hc"
func (i Compression) String() string {
if i >= Compression(len(_CompressionIndex)-1) {
return fmt.Sprintf("Compression(%d)", i)
}
return _CompressionName[_CompressionIndex[i]:_CompressionIndex[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 _CompressionNoOp() {
var x [1]struct{}
_ = x[CompressionDisabled-(0)]
_ = x[CompressionLZ4-(1)]
_ = x[CompressionZSTD-(2)]
_ = x[CompressionNone-(3)]
_ = x[CompressionLZ4HC-(4)]
}
var _CompressionValues = []Compression{CompressionDisabled, CompressionLZ4, CompressionZSTD, CompressionNone, CompressionLZ4HC}
var _CompressionNameToValueMap = map[string]Compression{
_CompressionName[0:8]: CompressionDisabled,
_CompressionLowerName[0:8]: CompressionDisabled,
_CompressionName[8:11]: CompressionLZ4,
_CompressionLowerName[8:11]: CompressionLZ4,
_CompressionName[11:15]: CompressionZSTD,
_CompressionLowerName[11:15]: CompressionZSTD,
_CompressionName[15:19]: CompressionNone,
_CompressionLowerName[15:19]: CompressionNone,
_CompressionName[19:24]: CompressionLZ4HC,
_CompressionLowerName[19:24]: CompressionLZ4HC,
}
var _CompressionNames = []string{
_CompressionName[0:8],
_CompressionName[8:11],
_CompressionName[11:15],
_CompressionName[15:19],
_CompressionName[19:24],
}
// CompressionString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func CompressionString(s string) (Compression, error) {
if val, ok := _CompressionNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _CompressionNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Compression values", s)
}
// CompressionValues returns all values of the enum
func CompressionValues() []Compression {
return _CompressionValues
}
// CompressionStrings returns a slice of all String values of the enum
func CompressionStrings() []string {
strs := make([]string, len(_CompressionNames))
copy(strs, _CompressionNames)
return strs
}
// IsACompression returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Compression) IsACompression() bool {
for _, v := range _CompressionValues {
if i == v {
return true
}
}
return false
}