forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_enumer.go
151 lines (134 loc) Β· 4.53 KB
/
class_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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Code generated by "enumer -type Class -trimprefix Class -transform=lower -text"; DO NOT EDIT.
package cmd
import (
"fmt"
"strings"
)
const _ClassName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsinfluxmessengersponsorship"
var _ClassIndex = [...]uint8{0, 10, 15, 22, 29, 35, 42, 46, 50, 58, 69, 74, 84, 86, 90, 96, 105, 116}
const _ClassLowerName = "configfilemeterchargervehicletariffcircuitsitemqttdatabasemodbusproxyeebusjavascriptgohemsinfluxmessengersponsorship"
func (i Class) String() string {
i -= 1
if i < 0 || i >= Class(len(_ClassIndex)-1) {
return fmt.Sprintf("Class(%d)", i+1)
}
return _ClassName[_ClassIndex[i]:_ClassIndex[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 _ClassNoOp() {
var x [1]struct{}
_ = x[ClassConfigFile-(1)]
_ = x[ClassMeter-(2)]
_ = x[ClassCharger-(3)]
_ = x[ClassVehicle-(4)]
_ = x[ClassTariff-(5)]
_ = x[ClassCircuit-(6)]
_ = x[ClassSite-(7)]
_ = x[ClassMqtt-(8)]
_ = x[ClassDatabase-(9)]
_ = x[ClassModbusProxy-(10)]
_ = x[ClassEEBus-(11)]
_ = x[ClassJavascript-(12)]
_ = x[ClassGo-(13)]
_ = x[ClassHEMS-(14)]
_ = x[ClassInflux-(15)]
_ = x[ClassMessenger-(16)]
_ = x[ClassSponsorship-(17)]
}
var _ClassValues = []Class{ClassConfigFile, ClassMeter, ClassCharger, ClassVehicle, ClassTariff, ClassCircuit, ClassSite, ClassMqtt, ClassDatabase, ClassModbusProxy, ClassEEBus, ClassJavascript, ClassGo, ClassHEMS, ClassInflux, ClassMessenger, ClassSponsorship}
var _ClassNameToValueMap = map[string]Class{
_ClassName[0:10]: ClassConfigFile,
_ClassLowerName[0:10]: ClassConfigFile,
_ClassName[10:15]: ClassMeter,
_ClassLowerName[10:15]: ClassMeter,
_ClassName[15:22]: ClassCharger,
_ClassLowerName[15:22]: ClassCharger,
_ClassName[22:29]: ClassVehicle,
_ClassLowerName[22:29]: ClassVehicle,
_ClassName[29:35]: ClassTariff,
_ClassLowerName[29:35]: ClassTariff,
_ClassName[35:42]: ClassCircuit,
_ClassLowerName[35:42]: ClassCircuit,
_ClassName[42:46]: ClassSite,
_ClassLowerName[42:46]: ClassSite,
_ClassName[46:50]: ClassMqtt,
_ClassLowerName[46:50]: ClassMqtt,
_ClassName[50:58]: ClassDatabase,
_ClassLowerName[50:58]: ClassDatabase,
_ClassName[58:69]: ClassModbusProxy,
_ClassLowerName[58:69]: ClassModbusProxy,
_ClassName[69:74]: ClassEEBus,
_ClassLowerName[69:74]: ClassEEBus,
_ClassName[74:84]: ClassJavascript,
_ClassLowerName[74:84]: ClassJavascript,
_ClassName[84:86]: ClassGo,
_ClassLowerName[84:86]: ClassGo,
_ClassName[86:90]: ClassHEMS,
_ClassLowerName[86:90]: ClassHEMS,
_ClassName[90:96]: ClassInflux,
_ClassLowerName[90:96]: ClassInflux,
_ClassName[96:105]: ClassMessenger,
_ClassLowerName[96:105]: ClassMessenger,
_ClassName[105:116]: ClassSponsorship,
_ClassLowerName[105:116]: ClassSponsorship,
}
var _ClassNames = []string{
_ClassName[0:10],
_ClassName[10:15],
_ClassName[15:22],
_ClassName[22:29],
_ClassName[29:35],
_ClassName[35:42],
_ClassName[42:46],
_ClassName[46:50],
_ClassName[50:58],
_ClassName[58:69],
_ClassName[69:74],
_ClassName[74:84],
_ClassName[84:86],
_ClassName[86:90],
_ClassName[90:96],
_ClassName[96:105],
_ClassName[105:116],
}
// ClassString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ClassString(s string) (Class, error) {
if val, ok := _ClassNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ClassNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Class values", s)
}
// ClassValues returns all values of the enum
func ClassValues() []Class {
return _ClassValues
}
// ClassStrings returns a slice of all String values of the enum
func ClassStrings() []string {
strs := make([]string, len(_ClassNames))
copy(strs, _ClassNames)
return strs
}
// IsAClass returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Class) IsAClass() bool {
for _, v := range _ClassValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for Class
func (i Class) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for Class
func (i *Class) UnmarshalText(text []byte) error {
var err error
*i, err = ClassString(string(text))
return err
}