-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsystemstatus_enumer.go
More file actions
119 lines (105 loc) · 3.58 KB
/
systemstatus_enumer.go
File metadata and controls
119 lines (105 loc) · 3.58 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Code generated by "enumer -type SystemStatus -linecomment"; DO NOT EDIT.
package wifire
import (
"fmt"
"strings"
)
const (
_SystemStatusName_0 = "sleepingreadyignitingheatingcooking"
_SystemStatusLowerName_0 = "sleepingreadyignitingheatingcooking"
_SystemStatusName_1 = "keep warmshutdown"
_SystemStatusLowerName_1 = "keep warmshutdown"
_SystemStatusName_2 = "offline"
_SystemStatusLowerName_2 = "offline"
)
var (
_SystemStatusIndex_0 = [...]uint8{0, 8, 13, 21, 28, 35}
_SystemStatusIndex_1 = [...]uint8{0, 9, 17}
_SystemStatusIndex_2 = [...]uint8{0, 7}
)
func (i SystemStatus) String() string {
switch {
case 2 <= i && i <= 6:
i -= 2
return _SystemStatusName_0[_SystemStatusIndex_0[i]:_SystemStatusIndex_0[i+1]]
case 8 <= i && i <= 9:
i -= 8
return _SystemStatusName_1[_SystemStatusIndex_1[i]:_SystemStatusIndex_1[i+1]]
case i == 99:
return _SystemStatusName_2
default:
return fmt.Sprintf("SystemStatus(%d)", i)
}
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _SystemStatusNoOp() {
var x [1]struct{}
_ = x[StatusSleeping-(2)]
_ = x[StatusReady-(3)]
_ = x[StatusIgniting-(4)]
_ = x[StatusHeating-(5)]
_ = x[StatusCooking-(6)]
_ = x[StatusKeepWarm-(8)]
_ = x[StatusShutdown-(9)]
_ = x[StatusOffline-(99)]
}
var _SystemStatusValues = []SystemStatus{StatusSleeping, StatusReady, StatusIgniting, StatusHeating, StatusCooking, StatusKeepWarm, StatusShutdown, StatusOffline}
var _SystemStatusNameToValueMap = map[string]SystemStatus{
_SystemStatusName_0[0:8]: StatusSleeping,
_SystemStatusLowerName_0[0:8]: StatusSleeping,
_SystemStatusName_0[8:13]: StatusReady,
_SystemStatusLowerName_0[8:13]: StatusReady,
_SystemStatusName_0[13:21]: StatusIgniting,
_SystemStatusLowerName_0[13:21]: StatusIgniting,
_SystemStatusName_0[21:28]: StatusHeating,
_SystemStatusLowerName_0[21:28]: StatusHeating,
_SystemStatusName_0[28:35]: StatusCooking,
_SystemStatusLowerName_0[28:35]: StatusCooking,
_SystemStatusName_1[0:9]: StatusKeepWarm,
_SystemStatusLowerName_1[0:9]: StatusKeepWarm,
_SystemStatusName_1[9:17]: StatusShutdown,
_SystemStatusLowerName_1[9:17]: StatusShutdown,
_SystemStatusName_2[0:7]: StatusOffline,
_SystemStatusLowerName_2[0:7]: StatusOffline,
}
var _SystemStatusNames = []string{
_SystemStatusName_0[0:8],
_SystemStatusName_0[8:13],
_SystemStatusName_0[13:21],
_SystemStatusName_0[21:28],
_SystemStatusName_0[28:35],
_SystemStatusName_1[0:9],
_SystemStatusName_1[9:17],
_SystemStatusName_2[0:7],
}
// SystemStatusString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func SystemStatusString(s string) (SystemStatus, error) {
if val, ok := _SystemStatusNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _SystemStatusNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to SystemStatus values", s)
}
// SystemStatusValues returns all values of the enum
func SystemStatusValues() []SystemStatus {
return _SystemStatusValues
}
// SystemStatusStrings returns a slice of all String values of the enum
func SystemStatusStrings() []string {
strs := make([]string, len(_SystemStatusNames))
copy(strs, _SystemStatusNames)
return strs
}
// IsASystemStatus returns "true" if the value is listed in the enum definition. "false" otherwise
func (i SystemStatus) IsASystemStatus() bool {
for _, v := range _SystemStatusValues {
if i == v {
return true
}
}
return false
}