evcc-io/plugin/method_enumer.go
2026-06-02 13:53:13 +02:00

99 lines
2.4 KiB
Go

// Code generated by "enumer -type Method -text"; DO NOT EDIT.
package plugin
import (
"fmt"
"strings"
)
const _MethodName = "EnergyReturnEnergyPowerSoc"
var _MethodIndex = [...]uint8{0, 6, 18, 23, 26}
const _MethodLowerName = "energyreturnenergypowersoc"
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[ReturnEnergy-(2)]
_ = x[Power-(3)]
_ = x[Soc-(4)]
}
var _MethodValues = []Method{Energy, ReturnEnergy, Power, Soc}
var _MethodNameToValueMap = map[string]Method{
_MethodName[0:6]: Energy,
_MethodLowerName[0:6]: Energy,
_MethodName[6:18]: ReturnEnergy,
_MethodLowerName[6:18]: ReturnEnergy,
_MethodName[18:23]: Power,
_MethodLowerName[18:23]: Power,
_MethodName[23:26]: Soc,
_MethodLowerName[23:26]: Soc,
}
var _MethodNames = []string{
_MethodName[0:6],
_MethodName[6:18],
_MethodName[18:23],
_MethodName[23:26],
}
// 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
}
// MarshalText implements the encoding.TextMarshaler interface for Method
func (i Method) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for Method
func (i *Method) UnmarshalText(text []byte) error {
var err error
*i, err = MethodString(string(text))
return err
}