evcc-io/plugin/method_enumer.go
2025-05-29 09:47:04 +02:00

83 lines
1.9 KiB
Go

// Code generated by "enumer -type Method"; DO NOT EDIT.
package plugin
import (
"fmt"
"strings"
)
const _MethodName = "EnergyPowerSoc"
var _MethodIndex = [...]uint8{0, 6, 11, 14}
const _MethodLowerName = "energypowersoc"
func (i Method) String() string {
i -= 1
if i < 0 || i >= Method(len(_MethodIndex)-1) {
return fmt.Sprintf("Method(%d)", i+1)
}
return _MethodName[_MethodIndex[i]:_MethodIndex[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 _MethodNoOp() {
var x [1]struct{}
_ = x[Energy-(1)]
_ = x[Power-(2)]
_ = x[Soc-(3)]
}
var _MethodValues = []Method{Energy, Power, Soc}
var _MethodNameToValueMap = map[string]Method{
_MethodName[0:6]: Energy,
_MethodLowerName[0:6]: Energy,
_MethodName[6:11]: Power,
_MethodLowerName[6:11]: Power,
_MethodName[11:14]: Soc,
_MethodLowerName[11:14]: Soc,
}
var _MethodNames = []string{
_MethodName[0:6],
_MethodName[6:11],
_MethodName[11:14],
}
// MethodString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func MethodString(s string) (Method, error) {
if val, ok := _MethodNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _MethodNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Method values", s)
}
// MethodValues returns all values of the enum
func MethodValues() []Method {
return _MethodValues
}
// MethodStrings returns a slice of all String values of the enum
func MethodStrings() []string {
strs := make([]string, len(_MethodNames))
copy(strs, _MethodNames)
return strs
}
// IsAMethod returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Method) IsAMethod() bool {
for _, v := range _MethodValues {
if i == v {
return true
}
}
return false
}