evcc-io/util/templates/class_enumer.go
2023-09-22 20:32:59 +02:00

87 lines
2 KiB
Go

// Code generated by "enumer -type Class"; DO NOT EDIT.
package templates
import (
"fmt"
"strings"
)
const _ClassName = "ChargerMeterVehicleTariff"
var _ClassIndex = [...]uint8{0, 7, 12, 19, 25}
const _ClassLowerName = "chargermetervehicletariff"
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[Charger-(1)]
_ = x[Meter-(2)]
_ = x[Vehicle-(3)]
_ = x[Tariff-(4)]
}
var _ClassValues = []Class{Charger, Meter, Vehicle, Tariff}
var _ClassNameToValueMap = map[string]Class{
_ClassName[0:7]: Charger,
_ClassLowerName[0:7]: Charger,
_ClassName[7:12]: Meter,
_ClassLowerName[7:12]: Meter,
_ClassName[12:19]: Vehicle,
_ClassLowerName[12:19]: Vehicle,
_ClassName[19:25]: Tariff,
_ClassLowerName[19:25]: Tariff,
}
var _ClassNames = []string{
_ClassName[0:7],
_ClassName[7:12],
_ClassName[12:19],
_ClassName[19:25],
}
// 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
}